新增患者详情

This commit is contained in:
2023-09-18 14:17:40 +08:00
parent ce3168867f
commit dbe0e24241
13 changed files with 496 additions and 57 deletions
+1
View File
@@ -21,6 +21,7 @@ type User struct {
Age uint `gorm:"column:age;type:int(10) unsigned;comment:年龄" json:"age"`
Sex int `gorm:"column:sex;type:tinyint(1);default:0;comment:性别(0:未知 1:男 2:女)" json:"sex"`
Avatar string `gorm:"column:avatar;type:varchar(255);comment:头像" json:"avatar"`
DisableReason string `gorm:"column:disable_reason;type:varchar(255);comment:禁用理由" json:"disable_reason"`
LoginIp string `gorm:"column:login_ip;type:varchar(255);comment:登陆ip" json:"login_ip"`
LastLoginAt LocalTime `gorm:"column:last_login_at;type:datetime;comment:最后登陆时间" json:"last_login_at"`
CreatedBy string `gorm:"column:created_by;type:varchar(100);comment:创建者id(后台用户表id null:自己注册)" json:"created_by"`
+13 -11
View File
@@ -8,17 +8,19 @@ import (
// UserPatient 用户-患者表
type UserPatient struct {
PatientId int64 `gorm:"column:patient_id;type:bigint(19);primary_key;comment:主键id" json:"patient_id"`
UserId int64 `gorm:"column:user_id;type:bigint(19);comment:用户id;NOT NULL" json:"user_id"`
UserName string `gorm:"column:user_name;type:varchar(100);comment:用户名称" json:"user_name"`
OpenId string `gorm:"column:open_id;type:varchar(100);comment:微信open_id" json:"open_id"`
UnionId string `gorm:"column:union_id;type:varchar(100);comment:微信开放平台唯一标识" json:"union_id"`
WxSessionKey string `gorm:"column:wx_session_key;type:varchar(255);comment:微信会话密钥" json:"wx_session_key"`
Status int `gorm:"column:status;type:tinyint(1);default:1;comment:状态(0:禁用 1:正常 2:删除)" json:"status"`
IdcardStatus int `gorm:"column:idcard_status;type:tinyint(1);default:0;comment:实名认证状态(0:未认证 1:认证通过 2:认证失败)" json:"idcard_status"`
Avatar string `gorm:"column:avatar;type:varchar(255);comment:头像" json:"avatar"`
User *User `gorm:"foreignKey:UserId;references:user_id" json:"user"` // 用户
PatientFamily []*PatientFamily `gorm:"foreignKey:PatientId;references:patient_id" json:"patient_family"` // 家庭成员
PatientId int64 `gorm:"column:patient_id;type:bigint(19);primary_key;comment:主键id" json:"patient_id"`
UserId int64 `gorm:"column:user_id;type:bigint(19);comment:用户id;NOT NULL" json:"user_id"`
UserName string `gorm:"column:user_name;type:varchar(100);comment:用户名称" json:"user_name"`
OpenId string `gorm:"column:open_id;type:varchar(100);comment:微信open_id" json:"open_id"`
UnionId string `gorm:"column:union_id;type:varchar(100);comment:微信开放平台唯一标识" json:"union_id"`
WxSessionKey string `gorm:"column:wx_session_key;type:varchar(255);comment:微信会话密钥" json:"wx_session_key"`
Status int `gorm:"column:status;type:tinyint(1);default:1;comment:状态(0:禁用 1:正常 2:删除)" json:"status"`
IdcardStatus int `gorm:"column:idcard_status;type:tinyint(1);default:0;comment:实名认证状态(0:未认证 1:认证通过 2:认证失败)" json:"idcard_status"`
Avatar string `gorm:"column:avatar;type:varchar(255);comment:头像" json:"avatar"`
DisableReason string `gorm:"column:disable_reason;type:varchar(255);comment:禁用理由" json:"disable_reason"`
User *User `gorm:"foreignKey:UserId;references:user_id" json:"user"` // 用户
PatientFamily []*PatientFamily `gorm:"foreignKey:PatientId;references:patient_id" json:"patient_family"` // 家庭成员
UserShipAddress []*UserShipAddress `gorm:"foreignKey:UserId;references:user_id" json:"UserShipAddress"` // 收货地址
Model
}
+49
View File
@@ -0,0 +1,49 @@
package model
import (
"gorm.io/gorm"
"hospital-admin-api/global"
"time"
)
// UserShipAddress 用户收货地址表
type UserShipAddress struct {
AddressId int64 `gorm:"column:address_id;type:bigint(19);primary_key;comment:主键id" json:"address_id"`
UserId int64 `gorm:"column:user_id;type:bigint(19);comment:用户id;NOT NULL" json:"user_id"`
ProvinceId int `gorm:"column:province_id;type:int(11);comment:省份id" json:"province_id"`
Province string `gorm:"column:province;type:varchar(40);comment:省份" json:"province"`
CityId int `gorm:"column:city_id;type:int(11);comment:城市id" json:"city_id"`
City string `gorm:"column:city;type:varchar(40);comment:城市" json:"city"`
CountyId int `gorm:"column:county_id;type:int(11);comment:区县id" json:"county_id"`
County string `gorm:"column:county;type:varchar(255);comment:区县" json:"county"`
ConsigneeTownId int `gorm:"column:consignee_town_id;type:int(11);comment:镇id" json:"consignee_town_id"`
ConsigneeTown string `gorm:"column:consignee_town;type:varchar(150);comment:镇" json:"consignee_town"`
Address string `gorm:"column:address;type:varchar(255);comment:详细地址" json:"address"`
AddressMask string `gorm:"column:address_mask;type:varchar(255);comment:详细地址(掩码)" json:"address_mask"`
ConsigneeName string `gorm:"column:consignee_name;type:varchar(150);comment:收货人姓名;NOT NULL" json:"consignee_name"`
ConsigneeNameMask string `gorm:"column:consignee_name_mask;type:varchar(150);comment:收货人姓名(掩码)" json:"consignee_name_mask"`
ConsigneeTel string `gorm:"column:consignee_tel;type:varchar(100);comment:收货人电话;NOT NULL" json:"consignee_tel"`
ConsigneeTelMask string `gorm:"column:consignee_tel_mask;type:varchar(100);comment:收货人电话(掩码)" json:"consignee_tel_mask"`
ConsigneeZipCode string `gorm:"column:consignee_zip_code;type:varchar(20);comment:收货邮编" json:"consignee_zip_code"`
IsDefault int `gorm:"column:is_default;type:tinyint(1);default:0;comment:默认地址(0:否 1:是)" json:"is_default"`
Tag int `gorm:"column:tag;type:tinyint(1);comment:地址标签(1:家 2:公司 3:学校 4:其他)" json:"tag"`
Model
}
func (m *UserShipAddress) TableName() string {
return "gdxz_user_ship_address"
}
func (m *UserShipAddress) BeforeCreate(tx *gorm.DB) error {
if m.AddressId == 0 {
m.AddressId = global.Snowflake.Generate().Int64()
}
m.CreatedAt = LocalTime(time.Now())
tx.Statement.SetColumn("CreatedAt", m.CreatedAt)
m.UpdatedAt = LocalTime(time.Now())
tx.Statement.SetColumn("UpdatedAt", m.UpdatedAt)
return nil
}