From b6c4bd025f46d269b80637c1e009d971c517e21e Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Tue, 23 Jul 2024 15:38:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9E=9C=E5=9B=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dao/happy_orchard_user_watch_records.go | 12 +++++ .../happy_orchard_user_watch_records.go | 54 +++++++++++++++++++ src/models/happy_orchard_basic_setting.go | 1 + .../happy_orchard_user_watch_records.go | 14 +++++ 4 files changed, 81 insertions(+) create mode 100644 src/dao/happy_orchard_user_watch_records.go create mode 100644 src/implement/happy_orchard_user_watch_records.go create mode 100644 src/models/happy_orchard_user_watch_records.go diff --git a/src/dao/happy_orchard_user_watch_records.go b/src/dao/happy_orchard_user_watch_records.go new file mode 100644 index 0000000..88497e1 --- /dev/null +++ b/src/dao/happy_orchard_user_watch_records.go @@ -0,0 +1,12 @@ +package dao + +import ( + "code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" + "xorm.io/xorm" +) + +type HappyOrchardUserWatchRecordsDao interface { + GetHappyOrchardUserWatchRecordsSess(sess *xorm.Session, uid int) (m *models.HappyOrchardUserWatchRecords, err error) + GetHappyOrchardUserWatchRecords(uid int) (mm *models.HappyOrchardUserWatchRecords, err error) + HappyOrchardUserWatchRecordsUpdate(id interface{}, OneCirclesUserWatchRecords *models.HappyOrchardUserWatchRecords, forceColums ...string) (int64, error) +} diff --git a/src/implement/happy_orchard_user_watch_records.go b/src/implement/happy_orchard_user_watch_records.go new file mode 100644 index 0000000..40dd609 --- /dev/null +++ b/src/implement/happy_orchard_user_watch_records.go @@ -0,0 +1,54 @@ +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 HappyOrchardUserWatchRecordsDb struct { + Db *xorm.Engine +} + +func NewHappyOrchardUserWatchRecordsDb(engine *xorm.Engine) dao.HappyOrchardUserWatchRecordsDao { + return &HappyOrchardUserWatchRecordsDb{Db: engine} +} + +func (h HappyOrchardUserWatchRecordsDb) GetHappyOrchardUserWatchRecords(uid int) (m *models.HappyOrchardUserWatchRecords, err error) { + m = new(models.HappyOrchardUserWatchRecords) + has, err := h.Db.Where("uid=? ", uid).Get(m) + if err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + if has == false { + return nil, nil + } + return m, nil +} +func (h HappyOrchardUserWatchRecordsDb) GetHappyOrchardUserWatchRecordsSess(sess *xorm.Session, uid int) (m *models.HappyOrchardUserWatchRecords, err error) { + m = new(models.HappyOrchardUserWatchRecords) + has, err := sess.Where("uid=? ", uid).Get(m) + if err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + if has == false { + return nil, nil + } + return m, nil +} +func (h HappyOrchardUserWatchRecordsDb) HappyOrchardUserWatchRecordsUpdate(id interface{}, OneCirclesUserWatchRecords *models.HappyOrchardUserWatchRecords, forceColums ...string) (int64, error) { + var ( + affected int64 + err error + ) + if forceColums != nil { + affected, err = h.Db.Where("id=?", id).Cols(forceColums...).Update(OneCirclesUserWatchRecords) + } else { + affected, err = h.Db.Where("id=?", id).Update(OneCirclesUserWatchRecords) + } + if err != nil { + return 0, err + } + return affected, nil +} diff --git a/src/models/happy_orchard_basic_setting.go b/src/models/happy_orchard_basic_setting.go index 9706331..5d4b2f6 100644 --- a/src/models/happy_orchard_basic_setting.go +++ b/src/models/happy_orchard_basic_setting.go @@ -40,4 +40,5 @@ type HappyOrchardBasicSetting struct { IsOpenSixEnergyBall int `json:"is_open_six_energy_ball" xorm:"not null default 1 comment('是否开启7日签到(1:开启 0:关闭)') TINYINT(1)"` SixEnergyBallRewardData string `json:"six_energy_ball_reward_data" xorm:"not null comment('7日签到奖励数据') TEXT"` VideoSixEnergyBallRewardData string `json:"video_six_energy_ball_reward_data" xorm:"not null comment('观看视频后的7日签到奖励数据') TEXT"` + VideoRewardSystem string `json:"video_reward_system" xorm:"not null comment('视屏奖励机制') TEXT"` } diff --git a/src/models/happy_orchard_user_watch_records.go b/src/models/happy_orchard_user_watch_records.go new file mode 100644 index 0000000..e80e4e5 --- /dev/null +++ b/src/models/happy_orchard_user_watch_records.go @@ -0,0 +1,14 @@ +package models + +import ( + "time" +) + +type HappyOrchardUserWatchRecords struct { + Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"` + Uid int `json:"uid" xorm:"not null default 0 comment('用户id') INT(11)"` + NextWatchAdDate time.Time `json:"next_watch_ad_date" xorm:"not null default 'CURRENT_TIMESTAMP' comment('下一轮观看视屏时间') DATETIME"` + ResidueWatchAdNum int `json:"residue_watch_ad_num" xorm:"not null default 0 comment('剩余观看视屏数') INT(11)"` + CreateAt time.Time `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` + UpdateAt time.Time `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` +}