dbmodels.go 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. package models
  2. import "time"
  3. //检测项目
  4. type CheckItem struct {
  5. Id int `json:"id" gorm:"type:int(11) auto_increment; NOT NULL; primary_key; COMMENT:'检测项目ID'" description:"检测项目ID"`
  6. CheckItemNumber int `json:"check_item_number" gorm:"type:int(11); COMMENT:'排序'" description:"排序"`
  7. Language string `json:"language" gorm:"type:varchar(255); COMMENT:'cn: 中文 en 英文'" description:"cn: 中文 en 英文"`
  8. NameEn string `json:"name_en" gorm:"type:varchar(255); COMMENT:'检测项目英文名'" description:"检测项目英文名"`
  9. NameCn string `json:"name_cn" gorm:"type:varchar(255); COMMENT:'检测项目中文名'" description:"检测项目中文名"`
  10. DeviceType string `json:"device_type" gorm:"type:varchar(11); COMMENT:'设备类型'" description:"设备类型"`
  11. CheckType string `json:"check_type" gorm:"type:varchar(255); COMMENT:'检测类型(试纸类型)'" description:"检测类型(试纸类型)"`
  12. ReferenceValue string `json:"reference_value" gorm:"type:varchar(255); COMMENT:' 参考值'" description:" 参考值"`
  13. ScopeList string `json:"scope_list" gorm:"type:text; COMMENT:'范围value 值,type =1为正常、2及以上为异 常'" description:"范围value 值,type =1为正常、2及以上为异 常"`
  14. Text string `json:"text" gorm:"type:varchar(255); COMMENT:'文本'" description:"文本"`
  15. Details string `json:"details" gorm:"type:text; COMMENT:'描述'" description:"描述"`
  16. Unit string `json:"unit" gorm:"type:varchar(255); COMMENT:'单位'" description:"单位"`
  17. Remark string `json:"remark" gorm:"type:varchar(255); COMMENT:'备注'" description:"备注"`
  18. Ctime time.Time `json:"ctime" gorm:"type:datetime; DEFAULT: CURRENT_TIMESTAMP; COMMENT:'创建时间'" description:"创建时间"`
  19. Mtime time.Time `json:"mtime" gorm:"type:datetime; DEFAULT: CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; COMMENT:'更新时间 '" description:"更新时间 "`
  20. DeleteFlag int `json:"delete_flag" gorm:"type:int(11); COMMENT:'删除标志'" description:"删除标志"`
  21. }
  22. func (CheckItem) TableName() string {
  23. return "check_item"
  24. }
  25. //检测记录
  26. type CheckRecord struct {
  27. Id int64 `json:"id" gorm:"type:bigint(20); NOT NULL; primary_key; COMMENT:'检测记录ID'" description:"检测记录ID"`
  28. CheckType string `json:"check_type" gorm:"type:varchar(255); COMMENT:'检测类型(试纸类型)'" description:"检测类型(试纸类型)"`
  29. PutSources string `json:"put_sources" gorm:"type:varchar(255); COMMENT:'上传数据来源'" description:"上传数据来源"`
  30. DeviceId uint64 `json:"device_id" gorm:"type:bigint(20) unsigned; COMMENT:'设备ID'" description:"设备ID"`
  31. DeviceStatus int `json:"device_status" gorm:"type:int(2); COMMENT:'设备状态'" description:"设备状态"`
  32. MessageId string `json:"message_id" gorm:"type:varchar(255); COMMENT:'设备消息id'" description:"设备消息id"`
  33. UserId uint64 `json:"user_id" gorm:"type:bigint(20) unsigned; DEFAULT:'0'; COMMENT:'用户ID'" description:"用户ID"`
  34. UserHealthProfileId int64 `json:"user_health_profile_id" gorm:"type:bigint(20); DEFAULT:'0'; COMMENT:'健康档案ID'" description:"健康档案ID"`
  35. View int `json:"view" gorm:"type:int(11); DEFAULT:'0'; COMMENT:'查看:1(已查看) 0(未查看)'" description:"查看:1(已查看) 0(未查看)"`
  36. AlertItemIds string `json:"alert_item_ids" gorm:"type:varchar(255); COMMENT:'异常项目id (1,2,3)'" description:"异常项目id (1,2,3)"`
  37. Acc int `json:"acc" gorm:"type:int(10); COMMENT:'设备检测次数'" description:"设备检测次数"`
  38. Ctime time.Time `json:"ctime" gorm:"type:datetime; DEFAULT: CURRENT_TIMESTAMP; COMMENT:'创建时间 '" description:"创建时间 "`
  39. Mtime time.Time `json:"mtime" gorm:"type:datetime; DEFAULT: CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; COMMENT:'更新时间'" description:"更新时间"`
  40. DeleteFlag int `json:"delete_flag" gorm:"type:int(1); DEFAULT:'0'; COMMENT:'删除标志'" description:"删除标志"`
  41. }
  42. func (CheckRecord) TableName() string {
  43. return "check_record"
  44. }
  45. //检测记录详情
  46. type CheckRecordItem struct {
  47. Id int64 `json:"id" gorm:"type:bigint(20) auto_increment; NOT NULL; primary_key"`
  48. CheckId int64 `json:"check_id" gorm:"type:bigint(20); NOT NULL; DEFAULT:'0'"`
  49. CheckItemId int `json:"check_item_id" gorm:"type:int(11); COMMENT:'检测项目id'" description:"检测项目id"`
  50. CheckValue string `json:"check_value" gorm:"type:varchar(255); COMMENT:'检测结果数值'" description:"检测结果数值"`
  51. CheckValueIndex int `json:"check_value_index" gorm:"type:int(3); COMMENT:'check_item value index'" description:"check_item value index"`
  52. Ctime time.Time `json:"ctime" gorm:"type:datetime; DEFAULT: CURRENT_TIMESTAMP"`
  53. Mtime time.Time `json:"mtime" gorm:"type:datetime; DEFAULT: CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"`
  54. DeleteFlag int `json:"delete_flag" gorm:"type:int(11); COMMENT:'删除标志'" description:"删除标志"`
  55. }
  56. func (CheckRecordItem) TableName() string {
  57. return "check_record_item"
  58. }
  59. //设备表
  60. type Device struct {
  61. Id uint64 `json:"id" gorm:"type:bigint(20) unsigned auto_increment; NOT NULL; primary_key; COMMENT:'设备ID'" description:"设备ID"`
  62. Name string `json:"name" gorm:"type:varchar(255); COMMENT:'设备名称'" description:"设备名称"`
  63. Serialno string `json:"serialno" gorm:"type:varchar(64); COMMENT:'设备编号'" description:"设备编号"`
  64. DeviceName string `json:"device_name" gorm:"type:varchar(255); COMMENT:'设备名称'" description:"设备名称"`
  65. DeviceType string `json:"device_type" gorm:"type:varchar(11); COMMENT:'设备类型'" description:"设备类型"`
  66. InformType int `json:"inform_type" gorm:"type:int(1); COMMENT:'通知类型:0跳转小程序、1跳转网页 、默认跳转小程序'" description:"通知类型:0跳转小程序、1跳转网页 、默认跳转小程序"`
  67. Mac string `json:"mac" gorm:"type:varchar(255)"`
  68. Mcu string `json:"mcu" gorm:"type:varchar(255)"`
  69. BatchNumber int `json:"batch_number" gorm:"type:int(10); COMMENT:'批号'" description:"批号"`
  70. ProductionDateNumber int `json:"production_date_number" gorm:"type:int(10); COMMENT:'生产日期'" description:"生产日期"`
  71. Number int `json:"number" gorm:"type:int(10); COMMENT:'序号'" description:"序号"`
  72. QrCodeId int64 `json:"qr_code_id" gorm:"type:bigint(20)"`
  73. EmqPassword string `json:"emq_password" gorm:"type:varchar(255); COMMENT:'emq密码'" description:"emq密码"`
  74. Status int `json:"status" gorm:"type:int(2); DEFAULT:'0'; COMMENT:'状态(0:未分配 1:已分配 2:包装中 3:待出厂 6:废弃 99:已出厂 100:销售中 101:已售出)'" description:"状态(0:未分配 1:已分配 2:包装中 3:待出厂 6:废弃 99:已出厂 100:销售中 101:已售出)"`
  75. Ver string `json:"ver" gorm:"type:varchar(255); COMMENT:'软件版本'" description:"软件版本"`
  76. OemCompany int `json:"oem_company" gorm:"type:int(11); NOT NULL; DEFAULT:'0'; COMMENT:'厂商(0:自营 1:艾玛OEM)'" description:"厂商(0:自营 1:艾玛OEM)"`
  77. McuType string `json:"mcu_type" gorm:"type:varchar(32); COMMENT:'MCU芯片类型'" description:"MCU芯片类型"`
  78. SensorMode string `json:"sensor_mode" gorm:"type:varchar(32); COMMENT:'传感放大倍数'" description:"传感放大倍数"`
  79. Language string `json:"language" gorm:"type:varchar(32); COMMENT:'语言'" description:"语言"`
  80. PaperCheck int `json:"paper_check" gorm:"type:int(11); COMMENT:'试纸检查状态'" description:"试纸检查状态"`
  81. WifiVer string `json:"wifi_ver" gorm:"type:varchar(32); COMMENT:'WIFI版本'" description:"WIFI版本"`
  82. Ctime time.Time `json:"ctime" gorm:"type:datetime; DEFAULT: CURRENT_TIMESTAMP; COMMENT:'创建时间'" description:"创建时间"`
  83. Mtime time.Time `json:"mtime" gorm:"type:datetime; DEFAULT: CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; COMMENT:'更新时间 '" description:"更新时间 "`
  84. DeleteFlag int `json:"delete_flag" gorm:"type:int(11); DEFAULT:'0'; COMMENT:'删除标志'" description:"删除标志"`
  85. }
  86. func (Device) TableName() string {
  87. return "device"
  88. }
  89. //设备消息日志
  90. type DeviceMessageLog struct {
  91. Id uint64 `json:"id" gorm:"type:bigint(20) unsigned auto_increment; NOT NULL; primary_key"`
  92. MessageId string `json:"message_id" gorm:"type:varchar(255)"`
  93. DeviceName string `json:"device_name" gorm:"type:varchar(255)"`
  94. Topic string `json:"topic" gorm:"type:varchar(255)"`
  95. EventType string `json:"event_type" gorm:"type:varchar(255)"`
  96. Content string `json:"content" gorm:"type:text; COMMENT:'消息内容'" description:"消息内容"`
  97. Ctime time.Time `json:"ctime" gorm:"type:datetime; DEFAULT: CURRENT_TIMESTAMP; COMMENT:'创建时间'" description:"创建时间"`
  98. }
  99. func (DeviceMessageLog) TableName() string {
  100. return "device_message_log"
  101. }
  102. //设备绑定表
  103. type DeviceRelate struct {
  104. Id int64 `json:"id" gorm:"type:bigint(20) auto_increment; NOT NULL; primary_key; COMMENT:'id'" description:"id"`
  105. Name string `json:"name" gorm:"type:varchar(255); COMMENT:'名称'" description:"名称"`
  106. DeviceId uint64 `json:"device_id" gorm:"type:bigint(20) unsigned; COMMENT:'设备Id'" description:"设备Id"`
  107. UserId uint64 `json:"user_id" gorm:"type:bigint(20) unsigned; COMMENT:'会员Id'" description:"会员Id"`
  108. Ctime time.Time `json:"ctime" gorm:"type:datetime; DEFAULT: CURRENT_TIMESTAMP; COMMENT:'创建时间'" description:"创建时间"`
  109. Mtime time.Time `json:"mtime" gorm:"type:datetime; DEFAULT: CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; COMMENT:'更新时间 '" description:"更新时间 "`
  110. DeleteFlag int `json:"delete_flag" gorm:"type:int(11); DEFAULT:'0'; COMMENT:'删除标志(解绑时标记为删除)'" description:"删除标志(解绑时标记为删除)"`
  111. }
  112. func (DeviceRelate) TableName() string {
  113. return "device_relate"
  114. }
  115. type SysDictionary struct {
  116. Id int `json:"id" gorm:"type:int(11) auto_increment; NOT NULL; primary_key"`
  117. NameEn string `json:"name_en" gorm:"type:varchar(255)"`
  118. NameCh string `json:"name_ch" gorm:"type:text"`
  119. Type string `json:"type" gorm:"type:varchar(255)"`
  120. ParentId int `json:"parent_id" gorm:"type:int(11)"`
  121. Ctime time.Time `json:"ctime" gorm:"type:datetime; DEFAULT: CURRENT_TIMESTAMP"`
  122. DeleteFlag int `json:"delete_flag" gorm:"type:int(11); NOT NULL; DEFAULT:'0'; COMMENT:'删除标志'" description:"删除标志"`
  123. }
  124. func (SysDictionary) TableName() string {
  125. return "sys_dictionary"
  126. }
  127. //用户健康档案
  128. type UserHealthProfile struct {
  129. Id uint64 `json:"id" gorm:"type:bigint(20) unsigned auto_increment; NOT NULL; primary_key; COMMENT:'Primary Key ID'" description:"Primary Key ID"`
  130. UserId uint64 `json:"user_id" gorm:"type:bigint(20) unsigned; NOT NULL; COMMENT:'用户ID'" description:"用户ID"`
  131. RealName string `json:"real_name" gorm:"type:varchar(64); COMMENT:'真实姓名'" description:"真实姓名"`
  132. IdCard string `json:"id_card" gorm:"type:varchar(64); COMMENT:'身份证号'" description:"身份证号"`
  133. InpatientRegPhone string `json:"inpatient_reg_phone" gorm:"type:varchar(32); COMMENT:'住院登记手机号'" description:"住院登记手机号"`
  134. Gender int `json:"gender" gorm:"type:int(11); DEFAULT:'0'; COMMENT:'性别(0:未知 1:男 2:女)'" description:"性别(0:未知 1:男 2:女)"`
  135. Height int `json:"height" gorm:"type:int(11); COMMENT:'身高'" description:"身高"`
  136. Weight int `json:"weight" gorm:"type:int(11); COMMENT:'体重'" description:"体重"`
  137. BloodType string `json:"blood_type" gorm:"type:varchar(32); COMMENT:'血型'" description:"血型"`
  138. Birthday time.Time `json:"birthday" gorm:"type:datetime; COMMENT:'生日'" description:"生日"`
  139. IllnessState string `json:"illness_state" gorm:"type:varchar(255); COMMENT:'病情'" description:"病情"`
  140. RenalFunctionStatus int `json:"renal_function_status" gorm:"type:int(11); COMMENT:'肾功能情况(0:未透析,1: 血液透析,2:腹膜透析,3:肾脏移植)'" description:"肾功能情况(0:未透析,1: 血液透析,2:腹膜透析,3:肾脏移植)"`
  141. Creatinine int `json:"creatinine" gorm:"type:int(11); NOT NULL; DEFAULT:'0'; COMMENT:'血肌酐'" description:"血肌酐"`
  142. CreatinineUnit string `json:"creatinine_unit" gorm:"type:varchar(32); COMMENT:'肌酐单位(umol/L,mg/dl)'" description:"肌酐单位(umol/L,mg/dl)"`
  143. CreatineTime time.Time `json:"creatine_time" gorm:"type:datetime; COMMENT:'肌酐检测时间'" description:"肌酐检测时间"`
  144. UrineProtein24hUnit string `json:"urine_protein_24h_unit" gorm:"column:urine_protein_24h_unit; type:varchar(32); COMMENT:'24小时尿蛋白单位(g/24h,mg/24h)'" description:"24小时尿蛋白单位(g/24h,mg/24h)"`
  145. UrineProtein24h int `json:"urine_protein_24h" gorm:"column:urine_protein_24h;type:int(11); NOT NULL; DEFAULT:'0'; COMMENT:'24小时尿蛋白'" description:"24小时尿蛋白"`
  146. UrineProtein24hTime time.Time `json:"urine_protein_24h_time" gorm:"column:urine_protein_24h_time;type:datetime; COMMENT:'24小时尿蛋白检测时间'" description:"24小时尿蛋白检测时间"`
  147. UrineProtein int `json:"urine_protein" gorm:"type:int(11); NOT NULL; DEFAULT:'0'; COMMENT:'尿蛋白'" description:"尿蛋白"`
  148. UrineProteinUnit string `json:"urine_protein_unit" gorm:"column:urine_protein_unit; type:varchar(32); COMMENT:'尿蛋白单位(g,mg)'" description:"尿蛋白单位(g,mg)"`
  149. UrineProteinTime time.Time `json:"urine_protein_time" gorm:"column:urine_protein_time;type:datetime; COMMENT:'尿蛋白检测时间'" description:"尿蛋白检测时间"`
  150. Status int `json:"status" gorm:"type:int(11); DEFAULT:'1'; COMMENT:'状态(1:有效 0:无效 )'" description:"状态(1:有效 0:无效 )"`
  151. Ctime time.Time `json:"ctime" gorm:"type:datetime; DEFAULT: CURRENT_TIMESTAMP; COMMENT:'创建时间'" description:"创建时间"`
  152. Mtime time.Time `json:"mtime" gorm:"type:datetime; DEFAULT: CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; COMMENT:'更新时间 '" description:"更新时间 "`
  153. }
  154. func (UserHealthProfile) TableName() string {
  155. return "user_health_profile"
  156. }
  157. //小程序用户表(个人中心)
  158. type XcxUser struct {
  159. Id uint64 `json:"id" gorm:"type:bigint(20) unsigned auto_increment; NOT NULL; primary_key; COMMENT:'Primary Key ID'" description:"Primary Key ID"`
  160. Phone string `json:"phone" gorm:"type:varchar(32); COMMENT:'手机号码'" description:"手机号码"`
  161. Email string `json:"email" gorm:"type:varchar(255); COMMENT:'邮件'" description:"邮件"`
  162. OpenId string `json:"open_id" gorm:"type:varchar(255); COMMENT:'OpenID'" description:"OpenID"`
  163. UnionId string `json:"union_id" gorm:"type:varchar(255); COMMENT:'unionid'" description:"unionid"`
  164. NickName string `json:"nick_name" gorm:"type:varchar(64); COMMENT:'昵称'" description:"昵称"`
  165. Avatar string `json:"avatar" gorm:"type:varchar(255); COMMENT:'头像'" description:"头像"`
  166. Status int `json:"status" gorm:"type:int(11); DEFAULT:'1'; COMMENT:'状态(1:有效 0: 无效)'" description:"状态(1:有效 0: 无效)"`
  167. RoleType int `json:"role_type" gorm:"type:int(2); COMMENT:'角色类型 0或空:普通 1:管理员 2:测试'" description:"角色类型 0或空:普通 1:管理员 2:测试"`
  168. Source string `json:"source" gorm:"type:varchar(255); COMMENT:'用户来源'" description:"用户来源"`
  169. PrivacyProtocolVersions int `json:"privacy_protocol_versions" gorm:"type:int(2); COMMENT:'隐私政策版本'" description:"隐私政策版本"`
  170. Ctime time.Time `json:"ctime" gorm:"type:datetime; DEFAULT: CURRENT_TIMESTAMP; COMMENT:'创建时间'" description:"创建时间"`
  171. Mtime time.Time `json:"mtime" gorm:"type:datetime; DEFAULT: CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; COMMENT:'更新时间 '" description:"更新时间 "`
  172. SessionKey string `json:"session_key" gorm:"-"`
  173. }
  174. func (XcxUser) TableName() string {
  175. return "xcx_user"
  176. }