session.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package session
  2. import "time"
  3. // Session [...]
  4. type Session struct {
  5. SessionID int64 `gorm:"primaryKey;column:session_id;type:bigint(12);not null" json:"sessionId"`
  6. UserID int64 `gorm:"index:session_user;column:user_id;type:bigint(20);not null" json:"userId"`
  7. OpenID string `gorm:"column:open_id;type:varchar(32);not null" json:"openId"` // openid
  8. AccessToken string `gorm:"index:session_token;column:access_token;type:varchar(64);not null" json:"accessToken"`
  9. ExpireTime time.Time `gorm:"index:expire_time;column:expire_time;type:datetime;not null" json:"expireTime"`
  10. CreatedTime time.Time `gorm:"column:created_time;type:datetime;default:CURRENT_TIMESTAMP" json:"createdTime"` // 创建时间
  11. LastUpdatedTime time.Time `gorm:"column:last_updated_time;type:timestamp;not null;default:CURRENT_TIMESTAMP" json:"lastUpdatedTime"`
  12. }
  13. // TableName get sql table name.获取数据库表名
  14. func (m *Session) TableName() string {
  15. return "session"
  16. }
  17. // SessionColumns get sql column name.获取数据库列名
  18. var SessionColumns = struct {
  19. SessionID string
  20. UserID string
  21. OpenID string
  22. AccessToken string
  23. ExpireTime string
  24. CreatedTime string
  25. LastUpdatedTime string
  26. }{
  27. SessionID: "session_id",
  28. UserID: "user_id",
  29. OpenID: "open_id",
  30. AccessToken: "access_token",
  31. ExpireTime: "expire_time",
  32. CreatedTime: "created_time",
  33. LastUpdatedTime: "last_updated_time",
  34. }