session.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. SentAt time.Time
  42. }
  43. func (*Session) TableName() string {
  44. return "tb_session"
  45. }
  46. func (*SessionMember) TableName() string {
  47. return "tb_session_member"
  48. }
  49. func (*SessionMessage) TableName() string {
  50. return "tb_session_message"
  51. }