377 lines
12 KiB
Go
377 lines
12 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 newPatientMedicineTask(db *gorm.DB, opts ...gen.DOOption) patientMedicineTask {
|
|
_patientMedicineTask := patientMedicineTask{}
|
|
|
|
_patientMedicineTask.patientMedicineTaskDo.UseDB(db, opts...)
|
|
_patientMedicineTask.patientMedicineTaskDo.UseModel(&model.PatientMedicineTask{})
|
|
|
|
tableName := _patientMedicineTask.patientMedicineTaskDo.TableName()
|
|
_patientMedicineTask.ALL = field.NewAsterisk(tableName)
|
|
_patientMedicineTask.ID = field.NewInt32(tableName, "id")
|
|
_patientMedicineTask.Code = field.NewString(tableName, "code")
|
|
_patientMedicineTask.Title = field.NewString(tableName, "title")
|
|
_patientMedicineTask.Spec = field.NewString(tableName, "spec")
|
|
_patientMedicineTask.Status = field.NewInt32(tableName, "status")
|
|
_patientMedicineTask.IsRunning = field.NewInt32(tableName, "is_running")
|
|
_patientMedicineTask.RunTime = field.NewTime(tableName, "run_time")
|
|
_patientMedicineTask.RunStartTime = field.NewTime(tableName, "run_start_time")
|
|
_patientMedicineTask.RunEndTime = field.NewTime(tableName, "run_end_time")
|
|
_patientMedicineTask.PatientID = field.NewInt32(tableName, "patient_id")
|
|
_patientMedicineTask.MedicineRecordID = field.NewInt32(tableName, "medicine_record_id")
|
|
_patientMedicineTask.CreatedUser = field.NewString(tableName, "created_user")
|
|
_patientMedicineTask.CreatedAt = field.NewTime(tableName, "created_at")
|
|
_patientMedicineTask.UpdatedUser = field.NewString(tableName, "updated_user")
|
|
_patientMedicineTask.UpdatedAt = field.NewTime(tableName, "updated_at")
|
|
|
|
_patientMedicineTask.fillFieldMap()
|
|
|
|
return _patientMedicineTask
|
|
}
|
|
|
|
// patientMedicineTask 患者用药提醒(任务)表
|
|
type patientMedicineTask struct {
|
|
patientMedicineTaskDo
|
|
|
|
ALL field.Asterisk
|
|
ID field.Int32 // 主键ID
|
|
Code field.String // 任务编码
|
|
Title field.String // 标题
|
|
Spec field.String // 时间表达式
|
|
Status field.Int32 // 状态(1:禁用 2:启用)
|
|
IsRunning field.Int32 // 执行中(0:未执行 1:执行中 2:执行完毕)
|
|
RunTime field.Time // 预期执行时间
|
|
RunStartTime field.Time // 执行开始时间
|
|
RunEndTime field.Time // 执行结束时间
|
|
PatientID field.Int32 // 患者ID
|
|
MedicineRecordID field.Int32 // 用药记录ID
|
|
CreatedUser field.String // 创建人
|
|
CreatedAt field.Time // 创建时间
|
|
UpdatedUser field.String // 更新人
|
|
UpdatedAt field.Time // 更新时间
|
|
|
|
fieldMap map[string]field.Expr
|
|
}
|
|
|
|
func (p patientMedicineTask) Table(newTableName string) *patientMedicineTask {
|
|
p.patientMedicineTaskDo.UseTable(newTableName)
|
|
return p.updateTableName(newTableName)
|
|
}
|
|
|
|
func (p patientMedicineTask) As(alias string) *patientMedicineTask {
|
|
p.patientMedicineTaskDo.DO = *(p.patientMedicineTaskDo.As(alias).(*gen.DO))
|
|
return p.updateTableName(alias)
|
|
}
|
|
|
|
func (p *patientMedicineTask) updateTableName(table string) *patientMedicineTask {
|
|
p.ALL = field.NewAsterisk(table)
|
|
p.ID = field.NewInt32(table, "id")
|
|
p.Code = field.NewString(table, "code")
|
|
p.Title = field.NewString(table, "title")
|
|
p.Spec = field.NewString(table, "spec")
|
|
p.Status = field.NewInt32(table, "status")
|
|
p.IsRunning = field.NewInt32(table, "is_running")
|
|
p.RunTime = field.NewTime(table, "run_time")
|
|
p.RunStartTime = field.NewTime(table, "run_start_time")
|
|
p.RunEndTime = field.NewTime(table, "run_end_time")
|
|
p.PatientID = field.NewInt32(table, "patient_id")
|
|
p.MedicineRecordID = field.NewInt32(table, "medicine_record_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 *patientMedicineTask) 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 *patientMedicineTask) fillFieldMap() {
|
|
p.fieldMap = make(map[string]field.Expr, 15)
|
|
p.fieldMap["id"] = p.ID
|
|
p.fieldMap["code"] = p.Code
|
|
p.fieldMap["title"] = p.Title
|
|
p.fieldMap["spec"] = p.Spec
|
|
p.fieldMap["status"] = p.Status
|
|
p.fieldMap["is_running"] = p.IsRunning
|
|
p.fieldMap["run_time"] = p.RunTime
|
|
p.fieldMap["run_start_time"] = p.RunStartTime
|
|
p.fieldMap["run_end_time"] = p.RunEndTime
|
|
p.fieldMap["patient_id"] = p.PatientID
|
|
p.fieldMap["medicine_record_id"] = p.MedicineRecordID
|
|
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 patientMedicineTask) clone(db *gorm.DB) patientMedicineTask {
|
|
p.patientMedicineTaskDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
return p
|
|
}
|
|
|
|
func (p patientMedicineTask) replaceDB(db *gorm.DB) patientMedicineTask {
|
|
p.patientMedicineTaskDo.ReplaceDB(db)
|
|
return p
|
|
}
|
|
|
|
type patientMedicineTaskDo struct{ gen.DO }
|
|
|
|
func (p patientMedicineTaskDo) Debug() *patientMedicineTaskDo {
|
|
return p.withDO(p.DO.Debug())
|
|
}
|
|
|
|
func (p patientMedicineTaskDo) WithContext(ctx context.Context) *patientMedicineTaskDo {
|
|
return p.withDO(p.DO.WithContext(ctx))
|
|
}
|
|
|
|
func (p patientMedicineTaskDo) ReadDB() *patientMedicineTaskDo {
|
|
return p.Clauses(dbresolver.Read)
|
|
}
|
|
|
|
func (p patientMedicineTaskDo) WriteDB() *patientMedicineTaskDo {
|
|
return p.Clauses(dbresolver.Write)
|
|
}
|
|
|
|
func (p patientMedicineTaskDo) Session(config *gorm.Session) *patientMedicineTaskDo {
|
|
return p.withDO(p.DO.Session(config))
|
|
}
|
|
|
|
func (p patientMedicineTaskDo) Clauses(conds ...clause.Expression) *patientMedicineTaskDo {
|
|
return p.withDO(p.DO.Clauses(conds...))
|
|
}
|
|
|
|
func (p patientMedicineTaskDo) Returning(value interface{}, columns ...string) *patientMedicineTaskDo {
|
|
return p.withDO(p.DO.Returning(value, columns...))
|
|
}
|
|
|
|
func (p patientMedicineTaskDo) Not(conds ...gen.Condition) *patientMedicineTaskDo {
|
|
return p.withDO(p.DO.Not(conds...))
|
|
}
|
|
|
|
func (p patientMedicineTaskDo) Or(conds ...gen.Condition) *patientMedicineTaskDo {
|
|
return p.withDO(p.DO.Or(conds...))
|
|
}
|
|
|
|
func (p patientMedicineTaskDo) Select(conds ...field.Expr) *patientMedicineTaskDo {
|
|
return p.withDO(p.DO.Select(conds...))
|
|
}
|
|
|
|
func (p patientMedicineTaskDo) Where(conds ...gen.Condition) *patientMedicineTaskDo {
|
|
return p.withDO(p.DO.Where(conds...))
|
|
}
|
|
|
|
func (p patientMedicineTaskDo) Order(conds ...field.Expr) *patientMedicineTaskDo {
|
|
return p.withDO(p.DO.Order(conds...))
|
|
}
|
|
|
|
func (p patientMedicineTaskDo) Distinct(cols ...field.Expr) *patientMedicineTaskDo {
|
|
return p.withDO(p.DO.Distinct(cols...))
|
|
}
|
|
|
|
func (p patientMedicineTaskDo) Omit(cols ...field.Expr) *patientMedicineTaskDo {
|
|
return p.withDO(p.DO.Omit(cols...))
|
|
}
|
|
|
|
func (p patientMedicineTaskDo) Join(table schema.Tabler, on ...field.Expr) *patientMedicineTaskDo {
|
|
return p.withDO(p.DO.Join(table, on...))
|
|
}
|
|
|
|
func (p patientMedicineTaskDo) LeftJoin(table schema.Tabler, on ...field.Expr) *patientMedicineTaskDo {
|
|
return p.withDO(p.DO.LeftJoin(table, on...))
|
|
}
|
|
|
|
func (p patientMedicineTaskDo) RightJoin(table schema.Tabler, on ...field.Expr) *patientMedicineTaskDo {
|
|
return p.withDO(p.DO.RightJoin(table, on...))
|
|
}
|
|
|
|
func (p patientMedicineTaskDo) Group(cols ...field.Expr) *patientMedicineTaskDo {
|
|
return p.withDO(p.DO.Group(cols...))
|
|
}
|
|
|
|
func (p patientMedicineTaskDo) Having(conds ...gen.Condition) *patientMedicineTaskDo {
|
|
return p.withDO(p.DO.Having(conds...))
|
|
}
|
|
|
|
func (p patientMedicineTaskDo) Limit(limit int) *patientMedicineTaskDo {
|
|
return p.withDO(p.DO.Limit(limit))
|
|
}
|
|
|
|
func (p patientMedicineTaskDo) Offset(offset int) *patientMedicineTaskDo {
|
|
return p.withDO(p.DO.Offset(offset))
|
|
}
|
|
|
|
func (p patientMedicineTaskDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *patientMedicineTaskDo {
|
|
return p.withDO(p.DO.Scopes(funcs...))
|
|
}
|
|
|
|
func (p patientMedicineTaskDo) Unscoped() *patientMedicineTaskDo {
|
|
return p.withDO(p.DO.Unscoped())
|
|
}
|
|
|
|
func (p patientMedicineTaskDo) Create(values ...*model.PatientMedicineTask) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return p.DO.Create(values)
|
|
}
|
|
|
|
func (p patientMedicineTaskDo) CreateInBatches(values []*model.PatientMedicineTask, 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 patientMedicineTaskDo) Save(values ...*model.PatientMedicineTask) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return p.DO.Save(values)
|
|
}
|
|
|
|
func (p patientMedicineTaskDo) First() (*model.PatientMedicineTask, error) {
|
|
if result, err := p.DO.First(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.PatientMedicineTask), nil
|
|
}
|
|
}
|
|
|
|
func (p patientMedicineTaskDo) Take() (*model.PatientMedicineTask, error) {
|
|
if result, err := p.DO.Take(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.PatientMedicineTask), nil
|
|
}
|
|
}
|
|
|
|
func (p patientMedicineTaskDo) Last() (*model.PatientMedicineTask, error) {
|
|
if result, err := p.DO.Last(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.PatientMedicineTask), nil
|
|
}
|
|
}
|
|
|
|
func (p patientMedicineTaskDo) Find() ([]*model.PatientMedicineTask, error) {
|
|
result, err := p.DO.Find()
|
|
return result.([]*model.PatientMedicineTask), err
|
|
}
|
|
|
|
func (p patientMedicineTaskDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.PatientMedicineTask, err error) {
|
|
buf := make([]*model.PatientMedicineTask, 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 patientMedicineTaskDo) FindInBatches(result *[]*model.PatientMedicineTask, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
return p.DO.FindInBatches(result, batchSize, fc)
|
|
}
|
|
|
|
func (p patientMedicineTaskDo) Attrs(attrs ...field.AssignExpr) *patientMedicineTaskDo {
|
|
return p.withDO(p.DO.Attrs(attrs...))
|
|
}
|
|
|
|
func (p patientMedicineTaskDo) Assign(attrs ...field.AssignExpr) *patientMedicineTaskDo {
|
|
return p.withDO(p.DO.Assign(attrs...))
|
|
}
|
|
|
|
func (p patientMedicineTaskDo) Joins(fields ...field.RelationField) *patientMedicineTaskDo {
|
|
for _, _f := range fields {
|
|
p = *p.withDO(p.DO.Joins(_f))
|
|
}
|
|
return &p
|
|
}
|
|
|
|
func (p patientMedicineTaskDo) Preload(fields ...field.RelationField) *patientMedicineTaskDo {
|
|
for _, _f := range fields {
|
|
p = *p.withDO(p.DO.Preload(_f))
|
|
}
|
|
return &p
|
|
}
|
|
|
|
func (p patientMedicineTaskDo) FirstOrInit() (*model.PatientMedicineTask, error) {
|
|
if result, err := p.DO.FirstOrInit(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.PatientMedicineTask), nil
|
|
}
|
|
}
|
|
|
|
func (p patientMedicineTaskDo) FirstOrCreate() (*model.PatientMedicineTask, error) {
|
|
if result, err := p.DO.FirstOrCreate(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.PatientMedicineTask), nil
|
|
}
|
|
}
|
|
|
|
func (p patientMedicineTaskDo) FindByPage(offset int, limit int) (result []*model.PatientMedicineTask, 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 patientMedicineTaskDo) 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 patientMedicineTaskDo) Scan(result interface{}) (err error) {
|
|
return p.DO.Scan(result)
|
|
}
|
|
|
|
func (p patientMedicineTaskDo) Delete(models ...*model.PatientMedicineTask) (result gen.ResultInfo, err error) {
|
|
return p.DO.Delete(models)
|
|
}
|
|
|
|
func (p *patientMedicineTaskDo) withDO(do gen.Dao) *patientMedicineTaskDo {
|
|
p.DO = *do.(*gen.DO)
|
|
return p
|
|
}
|