441 lines
14 KiB
Go
441 lines
14 KiB
Go
// Code generated by gorm.io/gen. DO NOT EDIT.
|
|
// Code generated by gorm.io/gen. DO NOT EDIT.
|
|
// Code generated by gorm.io/gen. DO NOT EDIT.
|
|
|
|
package dao
|
|
|
|
import (
|
|
"context"
|
|
|
|
"gorm.io/gorm"
|
|
"gorm.io/gorm/clause"
|
|
"gorm.io/gorm/schema"
|
|
|
|
"gorm.io/gen"
|
|
"gorm.io/gen/field"
|
|
|
|
"gorm.io/plugin/dbresolver"
|
|
|
|
"mini-chat/internal/repository/mysql/model"
|
|
)
|
|
|
|
func newPatient(db *gorm.DB, opts ...gen.DOOption) patient {
|
|
_patient := patient{}
|
|
|
|
_patient.patientDo.UseDB(db, opts...)
|
|
_patient.patientDo.UseModel(&model.Patient{})
|
|
|
|
tableName := _patient.patientDo.TableName()
|
|
_patient.ALL = field.NewAsterisk(tableName)
|
|
_patient.ID = field.NewInt32(tableName, "id")
|
|
_patient.Mobile = field.NewString(tableName, "mobile")
|
|
_patient.Username = field.NewString(tableName, "username")
|
|
_patient.Sex = field.NewInt32(tableName, "sex")
|
|
_patient.Password = field.NewString(tableName, "password")
|
|
_patient.Avatar = field.NewString(tableName, "avatar")
|
|
_patient.IDNumber = field.NewString(tableName, "id_number")
|
|
_patient.Birthday = field.NewTime(tableName, "birthday")
|
|
_patient.BirthWeight = field.NewInt32(tableName, "birth_weight")
|
|
_patient.OperativeDate = field.NewTime(tableName, "operative_date")
|
|
_patient.NextFollowDate = field.NewTime(tableName, "next_follow_date")
|
|
_patient.ParityNumber = field.NewInt32(tableName, "parity_number")
|
|
_patient.BirthNumber = field.NewInt32(tableName, "birth_number")
|
|
_patient.ConceptionType = field.NewInt32(tableName, "conception_type")
|
|
_patient.GestationalWeek = field.NewInt32(tableName, "gestational_week")
|
|
_patient.PrenatalCheckType = field.NewInt32(tableName, "prenatal_check_type")
|
|
_patient.PrenatalCheckRemark = field.NewString(tableName, "prenatal_check_remark")
|
|
_patient.DeliveryType = field.NewInt32(tableName, "delivery_type")
|
|
_patient.RiskType = field.NewInt32(tableName, "risk_type")
|
|
_patient.RiskValue = field.NewString(tableName, "risk_value")
|
|
_patient.HeightGenerateCurveType = field.NewInt32(tableName, "height_generate_curve_type")
|
|
_patient.WeightGenerateCurveType = field.NewInt32(tableName, "weight_generate_curve_type")
|
|
_patient.LoginStatus = field.NewInt32(tableName, "login_status")
|
|
_patient.LastLoginTime = field.NewTime(tableName, "last_login_time")
|
|
_patient.LastLoginIP = field.NewString(tableName, "last_login_ip")
|
|
_patient.LastLoginHash = field.NewString(tableName, "last_login_hash")
|
|
_patient.WxUserID = field.NewString(tableName, "wx_user_id")
|
|
_patient.CreatedUser = field.NewString(tableName, "created_user")
|
|
_patient.CreatedAt = field.NewTime(tableName, "created_at")
|
|
_patient.UpdatedUser = field.NewString(tableName, "updated_user")
|
|
_patient.UpdatedAt = field.NewTime(tableName, "updated_at")
|
|
|
|
_patient.fillFieldMap()
|
|
|
|
return _patient
|
|
}
|
|
|
|
// patient 患者表
|
|
type patient struct {
|
|
patientDo
|
|
|
|
ALL field.Asterisk
|
|
ID field.Int32 // 主键
|
|
Mobile field.String // 手机号
|
|
Username field.String // 姓名
|
|
Sex field.Int32 // 性别(1:男 2:女)
|
|
Password field.String // 密码
|
|
Avatar field.String // 头像地址
|
|
IDNumber field.String // 身份证号
|
|
Birthday field.Time // 出生日期
|
|
BirthWeight field.Int32 // 出生体重(克)
|
|
OperativeDate field.Time // 手术日期
|
|
NextFollowDate field.Time // 下次随访时间
|
|
ParityNumber field.Int32 // 胎次(0:未知 1:1胎 2:胎 3:胎 4:≥4胎)
|
|
BirthNumber field.Int32 // 产次(0:未知 1:1产 2:2产 3:≥3产)
|
|
ConceptionType field.Int32 // 受孕方式(0:未知 1:自然受孕 2:辅助生殖技术)
|
|
GestationalWeek field.Int32 // 孕周
|
|
PrenatalCheckType field.Int32 // 产检是否异常(0:未知 1:有 2:无)
|
|
PrenatalCheckRemark field.String // 产检异常备注
|
|
DeliveryType field.Int32 // 分娩方式(0:未知 1:顺产 2:剖宫产)
|
|
RiskType field.Int32 // 风险类型(0:未知 1:低危 2:中危 3:高危)
|
|
RiskValue field.String // 风险值
|
|
HeightGenerateCurveType field.Int32 // 身高生长曲线类型(0:未知 1:轻度偏离 2:正常 3:重度偏离)
|
|
WeightGenerateCurveType field.Int32 // 体重生长曲线类型(0:未知 1:轻度偏离 2:正常 3:重度偏离)
|
|
LoginStatus field.Int32 // 登录状态(1:启用 0:禁用)
|
|
LastLoginTime field.Time // 最后一次登录时间
|
|
LastLoginIP field.String // 最后一次登录IP
|
|
LastLoginHash field.String // 最后一次登录 Hash
|
|
WxUserID field.String // 微信ID
|
|
CreatedUser field.String // 创建人
|
|
CreatedAt field.Time // 创建时间
|
|
UpdatedUser field.String // 更新人
|
|
UpdatedAt field.Time // 更新时间
|
|
|
|
fieldMap map[string]field.Expr
|
|
}
|
|
|
|
func (p patient) Table(newTableName string) *patient {
|
|
p.patientDo.UseTable(newTableName)
|
|
return p.updateTableName(newTableName)
|
|
}
|
|
|
|
func (p patient) As(alias string) *patient {
|
|
p.patientDo.DO = *(p.patientDo.As(alias).(*gen.DO))
|
|
return p.updateTableName(alias)
|
|
}
|
|
|
|
func (p *patient) updateTableName(table string) *patient {
|
|
p.ALL = field.NewAsterisk(table)
|
|
p.ID = field.NewInt32(table, "id")
|
|
p.Mobile = field.NewString(table, "mobile")
|
|
p.Username = field.NewString(table, "username")
|
|
p.Sex = field.NewInt32(table, "sex")
|
|
p.Password = field.NewString(table, "password")
|
|
p.Avatar = field.NewString(table, "avatar")
|
|
p.IDNumber = field.NewString(table, "id_number")
|
|
p.Birthday = field.NewTime(table, "birthday")
|
|
p.BirthWeight = field.NewInt32(table, "birth_weight")
|
|
p.OperativeDate = field.NewTime(table, "operative_date")
|
|
p.NextFollowDate = field.NewTime(table, "next_follow_date")
|
|
p.ParityNumber = field.NewInt32(table, "parity_number")
|
|
p.BirthNumber = field.NewInt32(table, "birth_number")
|
|
p.ConceptionType = field.NewInt32(table, "conception_type")
|
|
p.GestationalWeek = field.NewInt32(table, "gestational_week")
|
|
p.PrenatalCheckType = field.NewInt32(table, "prenatal_check_type")
|
|
p.PrenatalCheckRemark = field.NewString(table, "prenatal_check_remark")
|
|
p.DeliveryType = field.NewInt32(table, "delivery_type")
|
|
p.RiskType = field.NewInt32(table, "risk_type")
|
|
p.RiskValue = field.NewString(table, "risk_value")
|
|
p.HeightGenerateCurveType = field.NewInt32(table, "height_generate_curve_type")
|
|
p.WeightGenerateCurveType = field.NewInt32(table, "weight_generate_curve_type")
|
|
p.LoginStatus = field.NewInt32(table, "login_status")
|
|
p.LastLoginTime = field.NewTime(table, "last_login_time")
|
|
p.LastLoginIP = field.NewString(table, "last_login_ip")
|
|
p.LastLoginHash = field.NewString(table, "last_login_hash")
|
|
p.WxUserID = field.NewString(table, "wx_user_id")
|
|
p.CreatedUser = field.NewString(table, "created_user")
|
|
p.CreatedAt = field.NewTime(table, "created_at")
|
|
p.UpdatedUser = field.NewString(table, "updated_user")
|
|
p.UpdatedAt = field.NewTime(table, "updated_at")
|
|
|
|
p.fillFieldMap()
|
|
|
|
return p
|
|
}
|
|
|
|
func (p *patient) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
|
_f, ok := p.fieldMap[fieldName]
|
|
if !ok || _f == nil {
|
|
return nil, false
|
|
}
|
|
_oe, ok := _f.(field.OrderExpr)
|
|
return _oe, ok
|
|
}
|
|
|
|
func (p *patient) fillFieldMap() {
|
|
p.fieldMap = make(map[string]field.Expr, 31)
|
|
p.fieldMap["id"] = p.ID
|
|
p.fieldMap["mobile"] = p.Mobile
|
|
p.fieldMap["username"] = p.Username
|
|
p.fieldMap["sex"] = p.Sex
|
|
p.fieldMap["password"] = p.Password
|
|
p.fieldMap["avatar"] = p.Avatar
|
|
p.fieldMap["id_number"] = p.IDNumber
|
|
p.fieldMap["birthday"] = p.Birthday
|
|
p.fieldMap["birth_weight"] = p.BirthWeight
|
|
p.fieldMap["operative_date"] = p.OperativeDate
|
|
p.fieldMap["next_follow_date"] = p.NextFollowDate
|
|
p.fieldMap["parity_number"] = p.ParityNumber
|
|
p.fieldMap["birth_number"] = p.BirthNumber
|
|
p.fieldMap["conception_type"] = p.ConceptionType
|
|
p.fieldMap["gestational_week"] = p.GestationalWeek
|
|
p.fieldMap["prenatal_check_type"] = p.PrenatalCheckType
|
|
p.fieldMap["prenatal_check_remark"] = p.PrenatalCheckRemark
|
|
p.fieldMap["delivery_type"] = p.DeliveryType
|
|
p.fieldMap["risk_type"] = p.RiskType
|
|
p.fieldMap["risk_value"] = p.RiskValue
|
|
p.fieldMap["height_generate_curve_type"] = p.HeightGenerateCurveType
|
|
p.fieldMap["weight_generate_curve_type"] = p.WeightGenerateCurveType
|
|
p.fieldMap["login_status"] = p.LoginStatus
|
|
p.fieldMap["last_login_time"] = p.LastLoginTime
|
|
p.fieldMap["last_login_ip"] = p.LastLoginIP
|
|
p.fieldMap["last_login_hash"] = p.LastLoginHash
|
|
p.fieldMap["wx_user_id"] = p.WxUserID
|
|
p.fieldMap["created_user"] = p.CreatedUser
|
|
p.fieldMap["created_at"] = p.CreatedAt
|
|
p.fieldMap["updated_user"] = p.UpdatedUser
|
|
p.fieldMap["updated_at"] = p.UpdatedAt
|
|
}
|
|
|
|
func (p patient) clone(db *gorm.DB) patient {
|
|
p.patientDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
return p
|
|
}
|
|
|
|
func (p patient) replaceDB(db *gorm.DB) patient {
|
|
p.patientDo.ReplaceDB(db)
|
|
return p
|
|
}
|
|
|
|
type patientDo struct{ gen.DO }
|
|
|
|
func (p patientDo) Debug() *patientDo {
|
|
return p.withDO(p.DO.Debug())
|
|
}
|
|
|
|
func (p patientDo) WithContext(ctx context.Context) *patientDo {
|
|
return p.withDO(p.DO.WithContext(ctx))
|
|
}
|
|
|
|
func (p patientDo) ReadDB() *patientDo {
|
|
return p.Clauses(dbresolver.Read)
|
|
}
|
|
|
|
func (p patientDo) WriteDB() *patientDo {
|
|
return p.Clauses(dbresolver.Write)
|
|
}
|
|
|
|
func (p patientDo) Session(config *gorm.Session) *patientDo {
|
|
return p.withDO(p.DO.Session(config))
|
|
}
|
|
|
|
func (p patientDo) Clauses(conds ...clause.Expression) *patientDo {
|
|
return p.withDO(p.DO.Clauses(conds...))
|
|
}
|
|
|
|
func (p patientDo) Returning(value interface{}, columns ...string) *patientDo {
|
|
return p.withDO(p.DO.Returning(value, columns...))
|
|
}
|
|
|
|
func (p patientDo) Not(conds ...gen.Condition) *patientDo {
|
|
return p.withDO(p.DO.Not(conds...))
|
|
}
|
|
|
|
func (p patientDo) Or(conds ...gen.Condition) *patientDo {
|
|
return p.withDO(p.DO.Or(conds...))
|
|
}
|
|
|
|
func (p patientDo) Select(conds ...field.Expr) *patientDo {
|
|
return p.withDO(p.DO.Select(conds...))
|
|
}
|
|
|
|
func (p patientDo) Where(conds ...gen.Condition) *patientDo {
|
|
return p.withDO(p.DO.Where(conds...))
|
|
}
|
|
|
|
func (p patientDo) Order(conds ...field.Expr) *patientDo {
|
|
return p.withDO(p.DO.Order(conds...))
|
|
}
|
|
|
|
func (p patientDo) Distinct(cols ...field.Expr) *patientDo {
|
|
return p.withDO(p.DO.Distinct(cols...))
|
|
}
|
|
|
|
func (p patientDo) Omit(cols ...field.Expr) *patientDo {
|
|
return p.withDO(p.DO.Omit(cols...))
|
|
}
|
|
|
|
func (p patientDo) Join(table schema.Tabler, on ...field.Expr) *patientDo {
|
|
return p.withDO(p.DO.Join(table, on...))
|
|
}
|
|
|
|
func (p patientDo) LeftJoin(table schema.Tabler, on ...field.Expr) *patientDo {
|
|
return p.withDO(p.DO.LeftJoin(table, on...))
|
|
}
|
|
|
|
func (p patientDo) RightJoin(table schema.Tabler, on ...field.Expr) *patientDo {
|
|
return p.withDO(p.DO.RightJoin(table, on...))
|
|
}
|
|
|
|
func (p patientDo) Group(cols ...field.Expr) *patientDo {
|
|
return p.withDO(p.DO.Group(cols...))
|
|
}
|
|
|
|
func (p patientDo) Having(conds ...gen.Condition) *patientDo {
|
|
return p.withDO(p.DO.Having(conds...))
|
|
}
|
|
|
|
func (p patientDo) Limit(limit int) *patientDo {
|
|
return p.withDO(p.DO.Limit(limit))
|
|
}
|
|
|
|
func (p patientDo) Offset(offset int) *patientDo {
|
|
return p.withDO(p.DO.Offset(offset))
|
|
}
|
|
|
|
func (p patientDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *patientDo {
|
|
return p.withDO(p.DO.Scopes(funcs...))
|
|
}
|
|
|
|
func (p patientDo) Unscoped() *patientDo {
|
|
return p.withDO(p.DO.Unscoped())
|
|
}
|
|
|
|
func (p patientDo) Create(values ...*model.Patient) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return p.DO.Create(values)
|
|
}
|
|
|
|
func (p patientDo) CreateInBatches(values []*model.Patient, batchSize int) error {
|
|
return p.DO.CreateInBatches(values, batchSize)
|
|
}
|
|
|
|
// Save : !!! underlying implementation is different with GORM
|
|
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
|
func (p patientDo) Save(values ...*model.Patient) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return p.DO.Save(values)
|
|
}
|
|
|
|
func (p patientDo) First() (*model.Patient, error) {
|
|
if result, err := p.DO.First(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.Patient), nil
|
|
}
|
|
}
|
|
|
|
func (p patientDo) Take() (*model.Patient, error) {
|
|
if result, err := p.DO.Take(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.Patient), nil
|
|
}
|
|
}
|
|
|
|
func (p patientDo) Last() (*model.Patient, error) {
|
|
if result, err := p.DO.Last(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.Patient), nil
|
|
}
|
|
}
|
|
|
|
func (p patientDo) Find() ([]*model.Patient, error) {
|
|
result, err := p.DO.Find()
|
|
return result.([]*model.Patient), err
|
|
}
|
|
|
|
func (p patientDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Patient, err error) {
|
|
buf := make([]*model.Patient, 0, batchSize)
|
|
err = p.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
|
defer func() { results = append(results, buf...) }()
|
|
return fc(tx, batch)
|
|
})
|
|
return results, err
|
|
}
|
|
|
|
func (p patientDo) FindInBatches(result *[]*model.Patient, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
return p.DO.FindInBatches(result, batchSize, fc)
|
|
}
|
|
|
|
func (p patientDo) Attrs(attrs ...field.AssignExpr) *patientDo {
|
|
return p.withDO(p.DO.Attrs(attrs...))
|
|
}
|
|
|
|
func (p patientDo) Assign(attrs ...field.AssignExpr) *patientDo {
|
|
return p.withDO(p.DO.Assign(attrs...))
|
|
}
|
|
|
|
func (p patientDo) Joins(fields ...field.RelationField) *patientDo {
|
|
for _, _f := range fields {
|
|
p = *p.withDO(p.DO.Joins(_f))
|
|
}
|
|
return &p
|
|
}
|
|
|
|
func (p patientDo) Preload(fields ...field.RelationField) *patientDo {
|
|
for _, _f := range fields {
|
|
p = *p.withDO(p.DO.Preload(_f))
|
|
}
|
|
return &p
|
|
}
|
|
|
|
func (p patientDo) FirstOrInit() (*model.Patient, error) {
|
|
if result, err := p.DO.FirstOrInit(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.Patient), nil
|
|
}
|
|
}
|
|
|
|
func (p patientDo) FirstOrCreate() (*model.Patient, error) {
|
|
if result, err := p.DO.FirstOrCreate(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.Patient), nil
|
|
}
|
|
}
|
|
|
|
func (p patientDo) FindByPage(offset int, limit int) (result []*model.Patient, count int64, err error) {
|
|
result, err = p.Offset(offset).Limit(limit).Find()
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
if size := len(result); 0 < limit && 0 < size && size < limit {
|
|
count = int64(size + offset)
|
|
return
|
|
}
|
|
|
|
count, err = p.Offset(-1).Limit(-1).Count()
|
|
return
|
|
}
|
|
|
|
func (p patientDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
|
count, err = p.Count()
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
err = p.Offset(offset).Limit(limit).Scan(result)
|
|
return
|
|
}
|
|
|
|
func (p patientDo) Scan(result interface{}) (err error) {
|
|
return p.DO.Scan(result)
|
|
}
|
|
|
|
func (p patientDo) Delete(models ...*model.Patient) (result gen.ResultInfo, err error) {
|
|
return p.DO.Delete(models)
|
|
}
|
|
|
|
func (p *patientDo) withDO(do gen.Dao) *patientDo {
|
|
p.DO = *do.(*gen.DO)
|
|
return p
|
|
}
|