From 96c37b747c2f413ac5d107046ce0204eef886656 Mon Sep 17 00:00:00 2001 From: dengbiao Date: Fri, 17 May 2024 22:01:32 +0800 Subject: [PATCH] update --- src/dao/happy_happy_orchard_reward_dao.go | 9 ++++++ src/dao/happy_happy_orchard_seed_dao.go | 9 ++++++ src/implement/happy_orchard_reward_db.go | 28 +++++++++++++++++++ ...ppy_orchard_reward_exchange_records_db.go} | 10 +++---- src/implement/happy_orchard_seed_db.go | 28 +++++++++++++++++++ src/models/happy_orchard_reward.go | 15 ++++++++++ src/models/happy_orchard_reward_with_seed.go | 7 +++++ src/models/happy_orchard_seed.go | 12 ++++++++ src/models/happy_orchard_user_waters.go | 9 ++++++ src/models/happy_orchard_user_waters_log.go | 13 +++++++++ test/repositories_test.go | 2 +- 11 files changed, 136 insertions(+), 6 deletions(-) create mode 100644 src/dao/happy_happy_orchard_reward_dao.go create mode 100644 src/dao/happy_happy_orchard_seed_dao.go create mode 100644 src/implement/happy_orchard_reward_db.go rename src/implement/{happy_orchard_reward_exchange_records_repositories.go => happy_orchard_reward_exchange_records_db.go} (57%) create mode 100644 src/implement/happy_orchard_seed_db.go create mode 100644 src/models/happy_orchard_reward.go create mode 100644 src/models/happy_orchard_reward_with_seed.go create mode 100644 src/models/happy_orchard_seed.go create mode 100644 src/models/happy_orchard_user_waters.go create mode 100644 src/models/happy_orchard_user_waters_log.go diff --git a/src/dao/happy_happy_orchard_reward_dao.go b/src/dao/happy_happy_orchard_reward_dao.go new file mode 100644 index 0000000..ff44bdf --- /dev/null +++ b/src/dao/happy_happy_orchard_reward_dao.go @@ -0,0 +1,9 @@ +package dao + +import ( + "code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" +) + +type HappyOrchardRewardDao interface { + GetHappyOrchardRewardDao(id int) (m *models.HappyOrchardReward, err error) +} diff --git a/src/dao/happy_happy_orchard_seed_dao.go b/src/dao/happy_happy_orchard_seed_dao.go new file mode 100644 index 0000000..87eb027 --- /dev/null +++ b/src/dao/happy_happy_orchard_seed_dao.go @@ -0,0 +1,9 @@ +package dao + +import ( + "code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" +) + +type HappyOrchardSeedDao interface { + GetHappyOrchardSeedDao(id int) (m *models.HappyOrchardSeed, err error) +} diff --git a/src/implement/happy_orchard_reward_db.go b/src/implement/happy_orchard_reward_db.go new file mode 100644 index 0000000..13be073 --- /dev/null +++ b/src/implement/happy_orchard_reward_db.go @@ -0,0 +1,28 @@ +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 happyOrchardRewardDb struct { + Db *xorm.Engine +} + +func NewHappyOrchardRewardDb(engine *xorm.Engine) dao.HappyOrchardRewardDao { + return &happyOrchardRewardDb{Db: engine} +} + +func (h happyOrchardRewardDb) GetHappyOrchardRewardDao(id int) (m *models.HappyOrchardReward, err error) { + m = new(models.HappyOrchardReward) + has, err := h.Db.Where("id =?", id).Get(m) + if err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + if has == false { + return nil, nil + } + return m, nil +} diff --git a/src/implement/happy_orchard_reward_exchange_records_repositories.go b/src/implement/happy_orchard_reward_exchange_records_db.go similarity index 57% rename from src/implement/happy_orchard_reward_exchange_records_repositories.go rename to src/implement/happy_orchard_reward_exchange_records_db.go index 9201203..9d2c307 100644 --- a/src/implement/happy_orchard_reward_exchange_records_repositories.go +++ b/src/implement/happy_orchard_reward_exchange_records_db.go @@ -7,15 +7,15 @@ import ( "xorm.io/xorm" ) -type happyOrchardRewardExchangeRecordsDao struct { +type happyOrchardRewardExchangeRecordsDb struct { Db *xorm.Engine } -func NewHappyOrchardRewardExchangeRecordsDao(engine *xorm.Engine) dao.HappyOrchardRewardExchangeRecordsDao { - return &happyOrchardRewardExchangeRecordsDao{Db: engine} +func NewHappyOrchardRewardExchangeRecordsDb(engine *xorm.Engine) dao.HappyOrchardRewardExchangeRecordsDao { + return &happyOrchardRewardExchangeRecordsDb{Db: engine} } -func (h happyOrchardRewardExchangeRecordsDao) GetHappyOrchardRewardExchangeRecords(id int) (m *models.HappyOrchardRewardExchangeRecords, err error) { +func (h happyOrchardRewardExchangeRecordsDb) GetHappyOrchardRewardExchangeRecords(id int) (m *models.HappyOrchardRewardExchangeRecords, err error) { //TODO implement me m = new(models.HappyOrchardRewardExchangeRecords) has, err := h.Db.Where("id =?", id).Get(m) @@ -28,7 +28,7 @@ func (h happyOrchardRewardExchangeRecordsDao) GetHappyOrchardRewardExchangeRecor return m, nil } -func (h happyOrchardRewardExchangeRecordsDao) FindHappyOrchardRewardExchangeRecordsByUid(uid int) (mm *[]models.HappyOrchardRewardExchangeRecords, err error) { +func (h happyOrchardRewardExchangeRecordsDb) FindHappyOrchardRewardExchangeRecordsByUid(uid int) (mm *[]models.HappyOrchardRewardExchangeRecords, err error) { //TODO implement me var m []models.HappyOrchardRewardExchangeRecords if err := h.Db.Where("uid =?", uid).Desc("id").Find(&m); err != nil { diff --git a/src/implement/happy_orchard_seed_db.go b/src/implement/happy_orchard_seed_db.go new file mode 100644 index 0000000..c4e8c8f --- /dev/null +++ b/src/implement/happy_orchard_seed_db.go @@ -0,0 +1,28 @@ +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 happyOrchardSeedDb struct { + Db *xorm.Engine +} + +func NewHappyOrchardSeedDb(engine *xorm.Engine) dao.HappyOrchardSeedDao { + return &happyOrchardSeedDb{Db: engine} +} + +func (h happyOrchardSeedDb) GetHappyOrchardSeedDao(id int) (m *models.HappyOrchardSeed, err error) { + m = new(models.HappyOrchardSeed) + has, err := h.Db.Where("id =?", id).Get(m) + if err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + if has == false { + return nil, nil + } + return m, nil +} diff --git a/src/models/happy_orchard_reward.go b/src/models/happy_orchard_reward.go new file mode 100644 index 0000000..f585bbf --- /dev/null +++ b/src/models/happy_orchard_reward.go @@ -0,0 +1,15 @@ +package models + +type HappyOrchardReward struct { + Id int `json:"id" xorm:"not null pk autoincr comment('自增id') INT(11)"` + Kind int `json:"kind" xorm:"not null default 1 comment('奖品类型(1:赠送商品 2:虚拟商品)') TINYINT(1)"` + Name string `json:"name" xorm:"not null default '' comment('名称') VARCHAR(255)"` + Nums int `json:"nums" xorm:"not null default 0 comment('奖品总数') INT(11)"` + ImgUrl string `json:"img_url" xorm:"not null default '' comment('图片地址') VARCHAR(255)"` + Value int `json:"value" xorm:"not null default 0 comment('具体值(kind=2时代表虚拟币值)') INT(11)"` + CoinId int `json:"coin_id" xorm:"not null default 0 comment('虚拟币id(kind=2时代表虚拟币id)') INT(11)"` + Memo string `json:"memo" xorm:"not null default '' comment('备注') VARCHAR(255)"` + Sort int `json:"sort" xorm:"not null default 0 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_reward_with_seed.go b/src/models/happy_orchard_reward_with_seed.go new file mode 100644 index 0000000..14c580c --- /dev/null +++ b/src/models/happy_orchard_reward_with_seed.go @@ -0,0 +1,7 @@ +package models + +type HappyOrchardRewardWithSeed struct { + Id int `json:"id" xorm:"not null pk autoincr comment('自增id') INT(11)"` + RewardId int `json:"reward_id" xorm:"not null default 0 comment('奖品id') INT(11)"` + SeedId int `json:"seed_id" xorm:"not null default 0 comment('种子id') INT(11)"` +} diff --git a/src/models/happy_orchard_seed.go b/src/models/happy_orchard_seed.go new file mode 100644 index 0000000..11c79ba --- /dev/null +++ b/src/models/happy_orchard_seed.go @@ -0,0 +1,12 @@ +package models + +type HappyOrchardSeed struct { + Id int `json:"id" xorm:"not null pk autoincr comment('自增id') INT(11)"` + Name string `json:"name" xorm:"not null default '' comment('名称') VARCHAR(255)"` + WaterNums int `json:"water_nums" xorm:"not null default 0 comment('所需水滴数') INT(11)"` + SeedImgUrl string `json:"seed_img_url" xorm:"not null default '' comment('种子图片地址') VARCHAR(255)"` + SeedMatureImgUrl string `json:"seed_mature_img_url" xorm:"not null default '' comment('种子成熟后图片地址') VARCHAR(255)"` + Sort int `json:"sort" xorm:"not null default 0 comment('排序') 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 new file mode 100644 index 0000000..27ba552 --- /dev/null +++ b/src/models/happy_orchard_user_waters.go @@ -0,0 +1,9 @@ +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)"` + WaterNums int `json:"water_nums" xorm:"not null default 0 comment('水滴数') 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_log.go b/src/models/happy_orchard_user_waters_log.go new file mode 100644 index 0000000..525aa31 --- /dev/null +++ b/src/models/happy_orchard_user_waters_log.go @@ -0,0 +1,13 @@ +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)"` + 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)"` + BeforeWaterNums int `json:"before_water_nums" xorm:"not null default 0 comment('之前水滴数') INT(11)"` + AfterWaterNums int `json:"after_water_nums" xorm:"not null default 0 comment('之后水滴数') 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/test/repositories_test.go b/test/repositories_test.go index e95d2b4..22e3e2e 100644 --- a/test/repositories_test.go +++ b/test/repositories_test.go @@ -8,7 +8,7 @@ import ( func TestImplementServer_GetHappyOrchardRewardExchangeRecords(t *testing.T) { Init() - dao := implement.NewHappyOrchardRewardExchangeRecordsDao(Db) + dao := implement.NewHappyOrchardRewardExchangeRecordsDb(Db) record, err := dao.GetHappyOrchardRewardExchangeRecords(1) if err != nil { fmt.Println("error:", err.Error())