db_struct.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // 数据结构
  2. package admin
  3. import (
  4. "time"
  5. "github.com/qor5/x/login"
  6. "gorm.io/gorm"
  7. )
  8. // -------------------------------------------------------------------------------- 用户
  9. // name 中文名称
  10. // index/edit/new 列表/编辑/新建 时是否显示 index:"-" 不显示
  11. // special:"-" ?
  12. // 用户
  13. type User struct {
  14. gorm.Model
  15. Categorize UserCategorize `name:"分类"` // 分类
  16. CategorizeId uint //
  17. NickName string `name:"昵称"` // 昵称
  18. TrueName string // 真名
  19. Sex uint // 性别
  20. LoginName string // 登陆名
  21. LoginPass string // 登陆密码
  22. LastIP string // 最后登陆IP
  23. LastTime time.Time // 最后登陆日期
  24. LoginNum uint // 登陆次数
  25. Active bool // 是否可用
  26. Tag string // 用户标签
  27. Like string // 爱好
  28. Addr string // 住址
  29. Tel string // 电话
  30. Age uint // 年龄
  31. IntroducerId uint // 介绍人ID
  32. login.UserPass
  33. login.OAuthInfo
  34. login.SessionSecure
  35. }
  36. // 用户收藏夹
  37. type UserFavorite struct {
  38. gorm.Model
  39. }
  40. // 用户关注
  41. type UserFollow struct {
  42. gorm.Model
  43. }
  44. // 用户分类
  45. type UserCategorize struct {
  46. gorm.Model
  47. UserId uint // 用户(管理员)给用户作的分类
  48. }
  49. // -------------------------------------------------------------------------------- 文章
  50. // 文章分类
  51. type DocumentCategorize struct {
  52. gorm.Model
  53. Title string `name:"标题"` // 分类标题
  54. Active bool `name:"可用"` // 可用
  55. Order uint `name:"顺序"` // 显示顺序
  56. Note string `name:"备注"` // 备注
  57. }
  58. // 文章
  59. type Document struct {
  60. gorm.Model
  61. Categorize DocumentCategorize // 分类
  62. CategorizeId uint //
  63. Title string `name:"标题"` // 文章标题
  64. Show bool `name:"显示"` // 是否显示
  65. Author string `name:"作者"` // 作者
  66. Source string `name:"来源"` // 来源
  67. Keyword string `name:"关键词"` // 关键词
  68. OrderBy uint `name:"排序"` // 排序
  69. UserCategorize UserCategorize // 用户分类
  70. UserCategorizeId uint //
  71. ReadPoints uint `name:"得积分"` // 阅读可获得积分
  72. ExpendPoints uint `name:"用积分"` // 阅读需要消耗积分
  73. ReadNum uint `name:"阅读数"` // 阅读数
  74. }