智慧食堂
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

109 рядки
3.5 KiB

  1. package db
  2. import (
  3. "applet/app/db/model"
  4. "applet/app/utils/logx"
  5. "reflect"
  6. "xorm.io/xorm"
  7. )
  8. type NursingHomeUserRefundDayDb struct {
  9. Db *xorm.Engine `json:"db"`
  10. RecordsId int `json:"records_id"`
  11. }
  12. func (nursingHomeUserRefundDayDb *NursingHomeUserRefundDayDb) Set(recordsId int) { // set方法
  13. nursingHomeUserRefundDayDb.Db = Db
  14. nursingHomeUserRefundDayDb.RecordsId = recordsId
  15. }
  16. func (nursingHomeUserRefundDayDb *NursingHomeUserRefundDayDb) GetNursingHomeUserRefundDay(id int) (m *model.NursingHomeUserRefundDay, err error) {
  17. m = new(model.NursingHomeUserRefundDay)
  18. has, err := nursingHomeUserRefundDayDb.Db.Where("id =?", id).Get(m)
  19. if err != nil {
  20. return nil, logx.Error(err)
  21. }
  22. if has == false {
  23. return nil, nil
  24. }
  25. return m, nil
  26. }
  27. func (nursingHomeUserRefundDayDb *NursingHomeUserRefundDayDb) FindNursingHomeUserRefundDay() (*[]model.NursingHomeUserRefundDay, error) {
  28. var m []model.NursingHomeUserRefundDay
  29. if err := nursingHomeUserRefundDayDb.Db.Where("records_id =?", nursingHomeUserRefundDayDb.RecordsId).Desc("id").Find(&m); err != nil {
  30. return nil, logx.Error(err)
  31. }
  32. return &m, nil
  33. }
  34. func (nursingHomeUserRefundDayDb *NursingHomeUserRefundDayDb) FindNursingHomeUserRefundDayByUid(uid int) (*[]model.NursingHomeUserRefundDay, error) {
  35. var m []model.NursingHomeUserRefundDay
  36. if err := nursingHomeUserRefundDayDb.Db.Where("uid =?", uid).Desc("id").Find(&m); err != nil {
  37. return nil, logx.Error(err)
  38. }
  39. return &m, nil
  40. }
  41. func (nursingHomeUserRefundDayDb *NursingHomeUserRefundDayDb) NursingHomeUserRefundDayInsert(m *model.NursingHomeUserRefundDay) (int, error) {
  42. _, err := nursingHomeUserRefundDayDb.Db.InsertOne(m)
  43. if err != nil {
  44. return 0, err
  45. }
  46. return m.Id, nil
  47. }
  48. func (nursingHomeUserRefundDayDb *NursingHomeUserRefundDayDb) BatchAddNursingHomeUserRefundDays(mm []*model.NursingHomeUserRefundDay) (int64, error) {
  49. affected, err := nursingHomeUserRefundDayDb.Db.Insert(mm)
  50. if err != nil {
  51. return 0, err
  52. }
  53. return affected, nil
  54. }
  55. func (nursingHomeUserRefundDayDb *NursingHomeUserRefundDayDb) NursingHomeUserRefundDayDelete(id interface{}) (int64, error) {
  56. if reflect.TypeOf(id).Kind() == reflect.Slice {
  57. return Db.In("id", id).Delete(model.NursingHomeUserRefundDay{})
  58. } else {
  59. return Db.Where("id = ?", id).Delete(model.NursingHomeUserRefundDay{})
  60. }
  61. }
  62. func (nursingHomeUserRefundDayDb *NursingHomeUserRefundDayDb) NursingHomeUserRefundDayUpdate(id interface{}, m *model.NursingHomeUserRefundDay, forceColums ...string) (int64, error) {
  63. var (
  64. affected int64
  65. err error
  66. )
  67. if forceColums != nil {
  68. affected, err = nursingHomeUserRefundDayDb.Db.Where("id=?", id).Cols(forceColums...).Update(m)
  69. } else {
  70. affected, err = nursingHomeUserRefundDayDb.Db.Where("id=?", id).Update(m)
  71. }
  72. if err != nil {
  73. return 0, err
  74. }
  75. return affected, nil
  76. }
  77. type NursingHomeUserRefundDayWithNursingHomeUserWithDay struct {
  78. model.NursingHomeUserRefundDay `xorm:"extends"`
  79. model.NursingHomeUserWithDay `xorm:"extends"`
  80. }
  81. func (NursingHomeUserRefundDayWithNursingHomeUserWithDay) TableName() string {
  82. return "nursing_home_user_refund_day"
  83. }
  84. type NursingHomeUserRefundDayWithData struct {
  85. model.NursingHomeUserRefundDay `xorm:"extends"`
  86. model.NursingHomeUserWithDay `xorm:"extends"`
  87. model.NursingHomePackageOrd `xorm:"extends"`
  88. model.UserIdentity `xorm:"extends"`
  89. model.Enterprise `xorm:"extends"`
  90. model.User `xorm:"extends"`
  91. }
  92. func (NursingHomeUserRefundDayWithData) TableName() string {
  93. return "nursing_home_user_refund_day"
  94. }