dt_system.go 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. package daytask
  2. import (
  3. "time"
  4. )
  5. // DtAdmin 管理员表
  6. type DtAdmin struct {
  7. Id int64 `json:"id" gorm:"column:id;type:bigint;primarykey;comment:管理员ID"`
  8. Username string `json:"username" gorm:"column:username;type:varchar(64);not null;uniqueIndex:uk_username;comment:用户名"`
  9. Password string `json:"-" gorm:"column:password;type:varchar(128);not null;comment:密码"`
  10. Nickname string `json:"nickname" gorm:"column:nickname;type:varchar(64);comment:昵称"`
  11. Avatar string `json:"avatar" gorm:"column:avatar;type:varchar(255);comment:头像"`
  12. Email string `json:"email" gorm:"column:email;type:varchar(128);comment:邮箱"`
  13. Phone string `json:"phone" gorm:"column:phone;type:varchar(32);comment:手机号"`
  14. RoleId int64 `json:"roleId" gorm:"column:role_id;type:bigint;default:0;index:idx_role_id;comment:角色ID"`
  15. Status int8 `json:"status" gorm:"column:status;type:tinyint;default:1;comment:状态: 0=禁用 1=启用"`
  16. LastLoginTime int64 `json:"lastLoginTime" gorm:"column:last_login_time;type:bigint;comment:最后登录时间"`
  17. LastLoginIp string `json:"lastLoginIp" gorm:"column:last_login_ip;type:varchar(64);comment:最后登录IP"`
  18. CreatedAt int64 `json:"createdAt" gorm:"column:created_at;type:bigint;autoCreateTime;comment:创建时间"`
  19. UpdatedAt int64 `json:"updatedAt" gorm:"column:updated_at;type:bigint;autoUpdateTime;comment:更新时间"`
  20. DeletedAt *time.Time `json:"deletedAt,omitempty" gorm:"column:deleted_at;type:datetime;index;comment:删除时间"`
  21. }
  22. func (*DtAdmin) TableName() string {
  23. return "dt_admin"
  24. }
  25. func NewDtAdmin() *DtAdmin {
  26. return &DtAdmin{}
  27. }
  28. // DtRole 角色表
  29. type DtRole struct {
  30. Id int64 `json:"id" gorm:"column:id;type:bigint;primarykey;comment:角色ID"`
  31. Name string `json:"name" gorm:"column:name;type:varchar(64);not null;comment:角色名称"`
  32. Code string `json:"code" gorm:"column:code;type:varchar(64);not null;uniqueIndex:uk_code;comment:角色编码"`
  33. Description string `json:"description" gorm:"column:description;type:varchar(255);comment:角色描述"`
  34. MenuIds string `json:"menuIds" gorm:"column:menu_ids;type:json;comment:菜单权限ID列表"`
  35. Status int8 `json:"status" gorm:"column:status;type:tinyint;default:1;comment:状态: 0=禁用 1=启用"`
  36. Sort int `json:"sort" gorm:"column:sort;type:int;default:0;comment:排序"`
  37. CreatedAt int64 `json:"createdAt" gorm:"column:created_at;type:bigint;autoCreateTime;comment:创建时间"`
  38. UpdatedAt int64 `json:"updatedAt" gorm:"column:updated_at;type:bigint;autoUpdateTime;comment:更新时间"`
  39. DeletedAt *time.Time `json:"deletedAt,omitempty" gorm:"column:deleted_at;type:datetime;index;comment:删除时间"`
  40. }
  41. func (*DtRole) TableName() string {
  42. return "dt_role"
  43. }
  44. func NewDtRole() *DtRole {
  45. return &DtRole{}
  46. }
  47. // DtMenu 菜单表
  48. type DtMenu struct {
  49. Id int64 `json:"id" gorm:"column:id;type:bigint;primarykey;comment:菜单ID"`
  50. ParentId int64 `json:"parentId" gorm:"column:parent_id;type:bigint;default:0;index:idx_parent_id;comment:父级ID"`
  51. Name string `json:"name" gorm:"column:name;type:varchar(64);not null;comment:菜单名称"`
  52. Path string `json:"path" gorm:"column:path;type:varchar(255);comment:路由路径"`
  53. Component string `json:"component" gorm:"column:component;type:varchar(255);comment:组件路径"`
  54. Icon string `json:"icon" gorm:"column:icon;type:varchar(64);comment:图标"`
  55. Type int8 `json:"type" gorm:"column:type;type:tinyint;default:1;comment:类型: 1=目录 2=菜单 3=按钮"`
  56. Permission string `json:"permission" gorm:"column:permission;type:varchar(128);comment:权限标识"`
  57. Visible int8 `json:"visible" gorm:"column:visible;type:tinyint;default:1;comment:是否可见: 0=隐藏 1=显示"`
  58. Status int8 `json:"status" gorm:"column:status;type:tinyint;default:1;comment:状态: 0=禁用 1=启用"`
  59. Sort int `json:"sort" gorm:"column:sort;type:int;default:0;comment:排序"`
  60. CreatedAt int64 `json:"createdAt" gorm:"column:created_at;type:bigint;autoCreateTime;comment:创建时间"`
  61. UpdatedAt int64 `json:"updatedAt" gorm:"column:updated_at;type:bigint;autoUpdateTime;comment:更新时间"`
  62. }
  63. func (*DtMenu) TableName() string {
  64. return "dt_menu"
  65. }
  66. func NewDtMenu() *DtMenu {
  67. return &DtMenu{}
  68. }
  69. // DtConfig 系统配置表
  70. type DtConfig struct {
  71. Id int64 `json:"id" gorm:"column:id;type:bigint;primarykey;comment:配置ID"`
  72. Group string `json:"group" gorm:"column:group;type:varchar(64);not null;uniqueIndex:uk_group_key,priority:1;comment:配置分组"`
  73. Key string `json:"key" gorm:"column:key;type:varchar(128);not null;uniqueIndex:uk_group_key,priority:2;comment:配置键"`
  74. Value string `json:"value" gorm:"column:value;type:text;comment:配置值"`
  75. Type string `json:"type" gorm:"column:type;type:varchar(32);default:string;comment:类型: string/number/boolean/json"`
  76. Name string `json:"name" gorm:"column:name;type:varchar(128);comment:配置名称"`
  77. Description string `json:"description" gorm:"column:description;type:varchar(255);comment:配置描述"`
  78. Status int8 `json:"status" gorm:"column:status;type:tinyint;default:1;comment:状态: 0=禁用 1=启用"`
  79. Sort int `json:"sort" gorm:"column:sort;type:int;default:0;comment:排序"`
  80. CreatedAt int64 `json:"createdAt" gorm:"column:created_at;type:bigint;autoCreateTime;comment:创建时间"`
  81. UpdatedAt int64 `json:"updatedAt" gorm:"column:updated_at;type:bigint;autoUpdateTime;comment:更新时间"`
  82. }
  83. func (*DtConfig) TableName() string {
  84. return "dt_config"
  85. }
  86. func NewDtConfig() *DtConfig {
  87. return &DtConfig{}
  88. }
  89. // DtOperationLog 操作日志表
  90. type DtOperationLog struct {
  91. Id int64 `json:"id" gorm:"column:id;type:bigint;primarykey;comment:日志ID"`
  92. AdminId int64 `json:"adminId" gorm:"column:admin_id;type:bigint;default:0;index:idx_admin_id;comment:管理员ID"`
  93. AdminName string `json:"adminName" gorm:"column:admin_name;type:varchar(64);comment:管理员名称"`
  94. Module string `json:"module" gorm:"column:module;type:varchar(64);comment:操作模块"`
  95. Action string `json:"action" gorm:"column:action;type:varchar(64);comment:操作动作"`
  96. Method string `json:"method" gorm:"column:method;type:varchar(16);comment:请求方法"`
  97. Path string `json:"path" gorm:"column:path;type:varchar(255);comment:请求路径"`
  98. Params string `json:"params" gorm:"column:params;type:text;comment:请求参数"`
  99. Result string `json:"result" gorm:"column:result;type:text;comment:响应结果"`
  100. Ip string `json:"ip" gorm:"column:ip;type:varchar(64);comment:操作IP"`
  101. UserAgent string `json:"userAgent" gorm:"column:user_agent;type:varchar(512);comment:UserAgent"`
  102. Duration int `json:"duration" gorm:"column:duration;type:int;default:0;comment:耗时(ms)"`
  103. Status int8 `json:"status" gorm:"column:status;type:tinyint;default:1;comment:状态: 0=失败 1=成功"`
  104. CreatedAt int64 `json:"createdAt" gorm:"column:created_at;type:bigint;autoCreateTime;index:idx_created_at;comment:创建时间"`
  105. }
  106. func (*DtOperationLog) TableName() string {
  107. return "dt_operation_log"
  108. }
  109. func NewDtOperationLog() *DtOperationLog {
  110. return &DtOperationLog{}
  111. }
  112. // DtDailyStats 每日统计表
  113. type DtDailyStats struct {
  114. Id int64 `json:"id" gorm:"column:id;type:bigint;primarykey;comment:ID"`
  115. Date string `json:"date" gorm:"column:date;type:date;not null;uniqueIndex:uk_date;comment:统计日期"`
  116. NewUserCount int `json:"newUserCount" gorm:"column:new_user_count;type:int;default:0;comment:新增用户数"`
  117. ActiveUserCount int `json:"activeUserCount" gorm:"column:active_user_count;type:int;default:0;comment:活跃用户数"`
  118. TaskPublishCount int `json:"taskPublishCount" gorm:"column:task_publish_count;type:int;default:0;comment:发布任务数"`
  119. TaskCompleteCount int `json:"taskCompleteCount" gorm:"column:task_complete_count;type:int;default:0;comment:完成任务数"`
  120. WithdrawCount int `json:"withdrawCount" gorm:"column:withdraw_count;type:int;default:0;comment:提现笔数"`
  121. WithdrawAmount float64 `json:"withdrawAmount" gorm:"column:withdraw_amount;type:decimal(18,2);default:0.00;comment:提现金额"`
  122. TaskRewardAmount float64 `json:"taskRewardAmount" gorm:"column:task_reward_amount;type:decimal(18,2);default:0.00;comment:任务奖励金额"`
  123. InviteRewardAmount float64 `json:"inviteRewardAmount" gorm:"column:invite_reward_amount;type:decimal(18,2);default:0.00;comment:推广奖励金额"`
  124. LevelPurchaseAmount float64 `json:"levelPurchaseAmount" gorm:"column:level_purchase_amount;type:decimal(18,2);default:0.00;comment:等级购买金额"`
  125. CreatedAt int64 `json:"createdAt" gorm:"column:created_at;type:bigint;autoCreateTime;comment:创建时间"`
  126. }
  127. func (*DtDailyStats) TableName() string {
  128. return "dt_daily_stats"
  129. }
  130. func NewDtDailyStats() *DtDailyStats {
  131. return &DtDailyStats{}
  132. }