dbmodels.go 13KB

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