total.go 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. package models
  2. //通用结构表
  3. type BaseModel struct {
  4. ID uint `gorm:"primarykey;autoIncrement" json:"id"`
  5. CreatedAt int64 `gorm:"comment:创建时间" json:"created_at"`
  6. UpdatedAt int64 `gorm:"comment:更新时间" json:"updated_at"`
  7. DeletedAt int64 `gorm:"comment:删除时间" json:"deleted_at"`
  8. IsDeleted int `gorm:"comment:是否删除 1:是 0:否" json:"is_deleted"`
  9. }
  10. // User 用户表结构
  11. type User struct {
  12. Username string `gorm:"type:varchar(50);uniqueIndex;not null;comment:用户名" json:"username"`
  13. Password string `gorm:"type:varchar(255);not null;comment:密码" json:"password"`
  14. Email string `gorm:"type:varchar(100);uniqueIndex;comment:邮箱" json:"email"`
  15. Phone string `gorm:"type:varchar(20);comment:手机号" json:"phone"`
  16. Nickname string `gorm:"type:varchar(50);comment:昵称" json:"nickname"`
  17. Avatar string `gorm:"type:varchar(255);comment:头像URL" json:"avatar"`
  18. Status int `gorm:"type:tinyint;default:1;comment:状态 1:正常 0:禁用" json:"status"`
  19. Role string `gorm:"type:varchar(20);default:'user';comment:角色" json:"role"`
  20. BaseModel
  21. }
  22. // TableName 指定表名
  23. func (User) TableName() string {
  24. return "user"
  25. }
  26. //推荐问题表
  27. type RecommendQuestion struct {
  28. BaseModel
  29. Question string `gorm:"type:varchar(255);not null;comment:问题" json:"question"`
  30. }
  31. // TableName 指定表名
  32. func (RecommendQuestion) TableName() string {
  33. return "recommend_question"
  34. }
  35. //反馈问题表
  36. type FeedbackQuestion struct {
  37. BaseModel
  38. FeedbackType int `gorm:"type:tinyint;not null;comment:反馈类型(1、问题反馈,2、界面优化,3、体验问题,4、其他)" json:"feedback_type"`
  39. FeedbackContent string `gorm:"type:varchar(255);not null;comment:反馈内容" json:"feedback_content"`
  40. FeedbackUserPhone string `gorm:"type:varchar(255);not null;comment:反馈用户手机号" json:"feedback_user_phone"`
  41. FeedbackImg string `gorm:"type:varchar(255);not null;comment:反馈图片" json:"feedback_img"`
  42. UserID uint `gorm:"type:int;not null;comment:用户ID" json:"user_id"`
  43. User User `gorm:"foreignKey:UserID;references:ID" json:"user"`
  44. }
  45. // TableName 指定表名
  46. func (FeedbackQuestion) TableName() string {
  47. return "feedback_question"
  48. }
  49. //政策文件表
  50. type PolicyFile struct {
  51. BaseModel
  52. PolicyName string `gorm:"type:varchar(255);not null;comment:政策名称" json:"policy_name"`
  53. PolicyContent string `gorm:"type:varchar(255);not null;comment:政策内容" json:"policy_content"`
  54. PolicyType int `gorm:"type:tinyint;not null;comment:政策类型(0、全部,1、国家法规,2、行业法规,3、地方法规,4、内部条例)" json:"policy_type"`
  55. PolicyFileUrl string `gorm:"type:varchar(255);not null;comment:政策文件URL" json:"policy_file_url"`
  56. //政策部门
  57. PolicyDepartment string `gorm:"type:varchar(255);not null;comment:政策部门" json:"policy_department"`
  58. //查看次数
  59. ViewCount int `gorm:"type:int;not null;comment:查看次数" json:"view_count"`
  60. //文件类型
  61. FileType int `gorm:"type:tinyint;not null;comment:文件类型(0、pdf,1、word,2、excel,3、ppt,4、txt,5、其他)" json:"file_type"`
  62. //文件标签
  63. FileTag string `gorm:"type:varchar(255);not null;comment:文件标签" json:"file_tag"`
  64. //颁布时间
  65. PublishTime int64 `gorm:"type:int;not null;comment:颁布时间" json:"publish_time"`
  66. }
  67. // TableName 指定表名
  68. func (PolicyFile) TableName() string {
  69. return "policy_file"
  70. }
  71. //AI问答和安全培训功能卡片表
  72. type FunctionCard struct {
  73. BaseModel
  74. FunctionTitle string `gorm:"type:varchar(255);not null;comment:功能标题" json:"function_title"`
  75. FunctionType int `gorm:"type:tinyint;not null;comment:功能类型(0、AI问答,1、安全培训)" json:"function_type"`
  76. FunctionContent string `gorm:"type:varchar(255);not null;comment:功能内容" json:"function_content"`
  77. //图标
  78. FunctionIcon string `gorm:"type:varchar(255);not null;comment:图标" json:"function_icon"`
  79. }
  80. // TableName 指定表名
  81. func (FunctionCard) TableName() string {
  82. return "function_card"
  83. }
  84. //AI问答和安全培训底部热点问题表
  85. type HotQuestion struct {
  86. BaseModel
  87. Question string `gorm:"type:varchar(255);not null;comment:问题" json:"question"`
  88. QuestionType int `gorm:"type:tinyint;not null;comment:问题类型(0、AI问答,1、安全培训)" json:"question_type"`
  89. //图标
  90. QuestionIcon string `gorm:"type:varchar(255);not null;comment:图标" json:"question_icon"`
  91. }
  92. // TableName 指定表名
  93. func (HotQuestion) TableName() string {
  94. return "hot_question"
  95. }