package db import ( "applet/app/db/model" "applet/app/utils/logx" "reflect" "xorm.io/xorm" ) type NursingHomeUserRefundDayDb struct { Db *xorm.Engine `json:"db"` RecordsId int `json:"records_id"` } func (nursingHomeUserRefundDayDb *NursingHomeUserRefundDayDb) Set(recordsId int) { // set方法 nursingHomeUserRefundDayDb.Db = Db nursingHomeUserRefundDayDb.RecordsId = recordsId } func (nursingHomeUserRefundDayDb *NursingHomeUserRefundDayDb) GetNursingHomeUserRefundDay(id int) (m *model.NursingHomeUserRefundDay, err error) { m = new(model.NursingHomeUserRefundDay) has, err := nursingHomeUserRefundDayDb.Db.Where("id =?", id).Get(m) if err != nil { return nil, logx.Error(err) } if has == false { return nil, nil } return m, nil } func (nursingHomeUserRefundDayDb *NursingHomeUserRefundDayDb) FindNursingHomeUserRefundDay() (*[]model.NursingHomeUserRefundDay, error) { var m []model.NursingHomeUserRefundDay if err := nursingHomeUserRefundDayDb.Db.Where("records_id =?", nursingHomeUserRefundDayDb.RecordsId).Desc("id").Find(&m); err != nil { return nil, logx.Error(err) } return &m, nil } func (nursingHomeUserRefundDayDb *NursingHomeUserRefundDayDb) FindNursingHomeUserRefundDayByUid(uid int) (*[]model.NursingHomeUserRefundDay, error) { var m []model.NursingHomeUserRefundDay if err := nursingHomeUserRefundDayDb.Db.Where("uid =?", uid).Desc("id").Find(&m); err != nil { return nil, logx.Error(err) } return &m, nil } func (nursingHomeUserRefundDayDb *NursingHomeUserRefundDayDb) NursingHomeUserRefundDayInsert(m *model.NursingHomeUserRefundDay) (int, error) { _, err := nursingHomeUserRefundDayDb.Db.InsertOne(m) if err != nil { return 0, err } return m.Id, nil } func (nursingHomeUserRefundDayDb *NursingHomeUserRefundDayDb) BatchAddNursingHomeUserRefundDays(mm []*model.NursingHomeUserRefundDay) (int64, error) { affected, err := nursingHomeUserRefundDayDb.Db.Insert(mm) if err != nil { return 0, err } return affected, nil } func (nursingHomeUserRefundDayDb *NursingHomeUserRefundDayDb) NursingHomeUserRefundDayDelete(id interface{}) (int64, error) { if reflect.TypeOf(id).Kind() == reflect.Slice { return Db.In("id", id).Delete(model.NursingHomeUserRefundDay{}) } else { return Db.Where("id = ?", id).Delete(model.NursingHomeUserRefundDay{}) } } func (nursingHomeUserRefundDayDb *NursingHomeUserRefundDayDb) NursingHomeUserRefundDayUpdate(id interface{}, m *model.NursingHomeUserRefundDay, forceColums ...string) (int64, error) { var ( affected int64 err error ) if forceColums != nil { affected, err = nursingHomeUserRefundDayDb.Db.Where("id=?", id).Cols(forceColums...).Update(m) } else { affected, err = nursingHomeUserRefundDayDb.Db.Where("id=?", id).Update(m) } if err != nil { return 0, err } return affected, nil } type NursingHomeUserRefundDayWithNursingHomeUserWithDay struct { model.NursingHomeUserRefundDay `xorm:"extends"` model.NursingHomeUserWithDay `xorm:"extends"` } func (NursingHomeUserRefundDayWithNursingHomeUserWithDay) TableName() string { return "nursing_home_user_refund_day" } type NursingHomeUserRefundDayWithData struct { model.NursingHomeUserRefundDay `xorm:"extends"` model.NursingHomeUserWithDay `xorm:"extends"` model.NursingHomePackageOrd `xorm:"extends"` model.UserIdentity `xorm:"extends"` model.Enterprise `xorm:"extends"` model.User `xorm:"extends"` } func (NursingHomeUserRefundDayWithData) TableName() string { return "nursing_home_user_refund_day" }