session.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package models
  2. import (
  3. "encoding/json"
  4. "time"
  5. "gorm.io/gorm"
  6. )
  7. type Session struct {
  8. ID string `gorm:"primarykey"`
  9. CreatedAt time.Time
  10. UpdatedAt time.Time
  11. DeletedAt gorm.DeletedAt `gorm:"index"`
  12. // Name string
  13. MembersCount int
  14. Type string
  15. CreatedBy string
  16. }
  17. type SessionMember struct {
  18. ID string `gorm:"primarykey"`
  19. CreatedAt time.Time
  20. UpdatedAt time.Time
  21. DeletedAt gorm.DeletedAt `gorm:"index"`
  22. SessionId string
  23. RefId string
  24. RefType string
  25. AccountIdentity string
  26. JoinTime time.Time
  27. }
  28. type SessionMessage struct {
  29. ID string `gorm:"primarykey"`
  30. CreatedAt time.Time
  31. UpdatedAt time.Time
  32. DeletedAt gorm.DeletedAt `gorm:"index"`
  33. SessionId string
  34. Receiver string
  35. Sender string
  36. Type int8
  37. ContentType uint8
  38. Content json.RawMessage `gorm:"type:json"`
  39. IsRead BitBool
  40. Received BitBool
  41. }
  42. func (*Session) TableName() string {
  43. return "tb_session"
  44. }
  45. func (*SessionMember) TableName() string {
  46. return "tb_session_member"
  47. }
  48. func (*SessionMessage) TableName() string {
  49. return "tb_session_message"
  50. }