|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- 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"
- }
|