From 9b05ec0caa29feb9a1587abd1dcdae8e14181ce4 Mon Sep 17 00:00:00 2001 From: dengbiao Date: Tue, 21 May 2024 18:07:47 +0800 Subject: [PATCH] update --- ...ppy_orchard_user_assistance_records_dao.go | 9 ++++ src/dao/happy_orchard_user_waters_dao.go | 1 + src/dao/happy_orchard_user_waters_log_dao.go | 11 ++++ ...appy_orchard_user_assistance_records_db.go | 52 +++++++++++++++++++ src/implement/happy_orchard_user_waters_db.go | 32 +++++++++--- .../happy_orchard_user_waters_log_db.go | 31 +++++++++++ .../happy_orchard_user_assistance_records.go | 11 ++++ src/models/happy_orchard_user_waters.go | 2 +- src/models/happy_orchard_user_waters_log.go | 2 +- 9 files changed, 141 insertions(+), 10 deletions(-) create mode 100644 src/dao/happy_orchard_user_assistance_records_dao.go create mode 100644 src/dao/happy_orchard_user_waters_log_dao.go create mode 100644 src/implement/happy_orchard_user_assistance_records_db.go create mode 100644 src/implement/happy_orchard_user_waters_log_db.go create mode 100644 src/models/happy_orchard_user_assistance_records.go diff --git a/src/dao/happy_orchard_user_assistance_records_dao.go b/src/dao/happy_orchard_user_assistance_records_dao.go new file mode 100644 index 0000000..55f6509 --- /dev/null +++ b/src/dao/happy_orchard_user_assistance_records_dao.go @@ -0,0 +1,9 @@ +package dao + +import "code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" + +type HappyOrchardUserAssistanceRecordsDao interface { + GetHappyOrchardUserAssistanceRecords(uid int, kind int32) (m *models.HappyOrchardUserAssistanceRecords, err error) + InsertHappyOrchardUserAssistanceRecords(m *models.HappyOrchardUserAssistanceRecords) (int, error) + UpdateHappyOrchardUserAssistanceRecords(m *models.HappyOrchardUserAssistanceRecords, forceColums ...string) (int64, error) +} diff --git a/src/dao/happy_orchard_user_waters_dao.go b/src/dao/happy_orchard_user_waters_dao.go index eb1e55c..222be4d 100644 --- a/src/dao/happy_orchard_user_waters_dao.go +++ b/src/dao/happy_orchard_user_waters_dao.go @@ -8,4 +8,5 @@ type HappyOrchardUserWatersDao interface { GetHappyOrchardUserWaters(uid int) (m *models.HappyOrchardUserWaters, err error) GetHappyOrchardUserWatersSess(uid int) (m *models.HappyOrchardUserWaters, err error) UpdateHappyOrchardUserWaters(uid int, m *models.HappyOrchardUserWaters, forceColums ...string) (int64, error) + UpdateHappyOrchardUserWatersBySess(uid int, m *models.HappyOrchardUserWaters, forceColums ...string) (int64, error) } diff --git a/src/dao/happy_orchard_user_waters_log_dao.go b/src/dao/happy_orchard_user_waters_log_dao.go new file mode 100644 index 0000000..b1674e7 --- /dev/null +++ b/src/dao/happy_orchard_user_waters_log_dao.go @@ -0,0 +1,11 @@ +package dao + +import ( + "code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" + "xorm.io/xorm" +) + +type HappyOrchardUserWatersLogDao interface { + InsertHappyOrchardUserWatersLog(m *models.HappyOrchardUserWatersLog) (int, error) + InsertHappyOrchardUserWatersLogBySess(session *xorm.Session, m *models.HappyOrchardUserWatersLog) (int, error) +} diff --git a/src/implement/happy_orchard_user_assistance_records_db.go b/src/implement/happy_orchard_user_assistance_records_db.go new file mode 100644 index 0000000..b2d270e --- /dev/null +++ b/src/implement/happy_orchard_user_assistance_records_db.go @@ -0,0 +1,52 @@ +package implement + +import ( + "code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/dao" + "code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" + zhios_order_relate_logx "code.fnuoos.com/go_rely_warehouse/zyos_model.git/utils/logx" + "xorm.io/xorm" +) + +type HappyOrchardUserAssistanceRecordsDb struct { + Db *xorm.Engine +} + +func (h HappyOrchardUserAssistanceRecordsDb) GetHappyOrchardUserAssistanceRecords(uid int, kind int32) (m *models.HappyOrchardUserAssistanceRecords, err error) { + m = new(models.HappyOrchardUserAssistanceRecords) + has, err := h.Db.Where("uid =?", uid).And("kind =?", kind).Get(m) + if err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + if has == false { + return nil, nil + } + return m, nil +} + +func (h HappyOrchardUserAssistanceRecordsDb) InsertHappyOrchardUserAssistanceRecords(m *models.HappyOrchardUserAssistanceRecords) (int, error) { + _, err := h.Db.InsertOne(m) + if err != nil { + return 0, err + } + return m.Id, nil +} + +func (h HappyOrchardUserAssistanceRecordsDb) UpdateHappyOrchardUserAssistanceRecords(m *models.HappyOrchardUserAssistanceRecords, forceColums ...string) (int64, error) { + var ( + affected int64 + err error + ) + if forceColums != nil { + affected, err = h.Db.Where("id=?", m.Id).Cols(forceColums...).Update(m) + } else { + affected, err = h.Db.Where("id=?", m.Id).Update(m) + } + if err != nil { + return 0, err + } + return affected, nil +} + +func NewHappyOrchardUserAssistanceRecordsDb(engine *xorm.Engine) dao.HappyOrchardUserAssistanceRecordsDao { + return &HappyOrchardUserAssistanceRecordsDb{Db: engine} +} diff --git a/src/implement/happy_orchard_user_waters_db.go b/src/implement/happy_orchard_user_waters_db.go index 6c9d4ec..3be9149 100644 --- a/src/implement/happy_orchard_user_waters_db.go +++ b/src/implement/happy_orchard_user_waters_db.go @@ -12,6 +12,22 @@ type HappyOrchardUserWatersDb struct { Sess *xorm.Session } +func (h HappyOrchardUserWatersDb) UpdateHappyOrchardUserWatersBySess(uid int, m *models.HappyOrchardUserWaters, forceColums ...string) (int64, error) { + var ( + affected int64 + err error + ) + if forceColums != nil { + affected, err = h.Sess.Where("uid=?", uid).Cols(forceColums...).Update(m) + } else { + affected, err = h.Sess.Where("uid=?", uid).Update(m) + } + if err != nil { + return 0, err + } + return affected, nil +} + func (h HappyOrchardUserWatersDb) UpdateHappyOrchardUserWaters(uid int, m *models.HappyOrchardUserWaters, forceColums ...string) (int64, error) { var ( affected int64 @@ -28,14 +44,6 @@ func (h HappyOrchardUserWatersDb) UpdateHappyOrchardUserWaters(uid int, m *model return affected, nil } -func NewHappyOrchardUserWatersDb(engine *xorm.Engine) dao.HappyOrchardUserWatersDao { - return &HappyOrchardUserWatersDb{Db: engine} -} - -func NewHappyOrchardUserWatersSess(sess *xorm.Session) dao.HappyOrchardUserWatersDao { - return &HappyOrchardUserWatersDb{Sess: sess} -} - func (h HappyOrchardUserWatersDb) GetHappyOrchardUserWaters(uid int) (m *models.HappyOrchardUserWaters, err error) { m = new(models.HappyOrchardUserWaters) has, err := h.Db.Where("uid =?", uid).Get(m) @@ -58,3 +66,11 @@ func (h HappyOrchardUserWatersDb) GetHappyOrchardUserWatersSess(uid int) (m *mod } return m, nil } + +func NewHappyOrchardUserWatersDb(engine *xorm.Engine) dao.HappyOrchardUserWatersDao { + return &HappyOrchardUserWatersDb{Db: engine} +} + +func NewHappyOrchardUserWatersSess(sess *xorm.Session) dao.HappyOrchardUserWatersDao { + return &HappyOrchardUserWatersDb{Sess: sess} +} diff --git a/src/implement/happy_orchard_user_waters_log_db.go b/src/implement/happy_orchard_user_waters_log_db.go new file mode 100644 index 0000000..2c5874f --- /dev/null +++ b/src/implement/happy_orchard_user_waters_log_db.go @@ -0,0 +1,31 @@ +package implement + +import ( + "code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/dao" + "code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" + "xorm.io/xorm" +) + +type HappyOrchardUserWatersLogDb struct { + Db *xorm.Engine +} + +func (h HappyOrchardUserWatersLogDb) InsertHappyOrchardUserWatersLog(m *models.HappyOrchardUserWatersLog) (int, error) { + _, err := h.Db.InsertOne(m) + if err != nil { + return 0, err + } + return m.Id, nil +} + +func (h HappyOrchardUserWatersLogDb) InsertHappyOrchardUserWatersLogBySess(session *xorm.Session, m *models.HappyOrchardUserWatersLog) (int, error) { + _, err := session.InsertOne(m) + if err != nil { + return 0, err + } + return m.Id, nil +} + +func NewHappyOrchardUserWatersLogDb(engine *xorm.Engine) dao.HappyOrchardUserWatersLogDao { + return &HappyOrchardUserWatersLogDb{Db: engine} +} diff --git a/src/models/happy_orchard_user_assistance_records.go b/src/models/happy_orchard_user_assistance_records.go new file mode 100644 index 0000000..92f5294 --- /dev/null +++ b/src/models/happy_orchard_user_assistance_records.go @@ -0,0 +1,11 @@ +package models + +type HappyOrchardUserAssistanceRecords struct { + Id int `json:"id" xorm:"not null pk autoincr comment('自增id') INT(11)"` + Uid int `json:"uid" xorm:"not null default '' comment('用户id') INT(11)"` + Date string `json:"date" xorm:"not null default '0000-00-00' comment('日期') INT(11)"` + Nums int `json:"nums" xorm:"not null default 0 comment('助力次数') INT(11)"` + Kind int32 `json:"kind" xorm:"not null default 1 comment('类型(1:分享助力 2:玩金蛋游戏助力 3:玩抽奖游戏助力)') INT(11)"` + CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('创建时间') DATETIME"` + UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('更新时间') DATETIME"` +} diff --git a/src/models/happy_orchard_user_waters.go b/src/models/happy_orchard_user_waters.go index 9ace97f..98280f6 100644 --- a/src/models/happy_orchard_user_waters.go +++ b/src/models/happy_orchard_user_waters.go @@ -2,7 +2,7 @@ package models type HappyOrchardUserWaters struct { Id int `json:"id" xorm:"not null pk autoincr comment('自增id') INT(11)"` - Uid string `json:"uid" xorm:"not null default '' comment('名称') VARCHAR(255)"` + Uid int `json:"uid" xorm:"not null default '' comment('名称') VARCHAR(255)"` WaterNums int `json:"water_nums" xorm:"not null default 0 comment('水滴数') INT(11)"` ReplaceSeedNums int `json:"replace_seed_nums" xorm:"not null default 0 comment('更换种子次数') INT(11)"` CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('创建时间') DATETIME"` diff --git a/src/models/happy_orchard_user_waters_log.go b/src/models/happy_orchard_user_waters_log.go index 525aa31..11ce0fa 100644 --- a/src/models/happy_orchard_user_waters_log.go +++ b/src/models/happy_orchard_user_waters_log.go @@ -2,7 +2,7 @@ package models type HappyOrchardUserWatersLog struct { Id int `json:"id" xorm:"not null pk autoincr comment('自增id') INT(11)"` - Uid string `json:"uid" xorm:"not null default '' comment('名称') VARCHAR(255)"` + Uid int `json:"uid" xorm:"not null default '' comment('名称') VARCHAR(255)"` WaterNums int `json:"water_nums" xorm:"not null default 0 comment('水滴数') INT(11)"` Title string `json:"title" xorm:"not null default '' comment('名称') CHAR(50)"` Kind int `json:"kind" xorm:"not null default 1 comment('类型(1:增加 2:减少)') TINYINT(1)"`