From e992189705d9e08b0af396fe627ad3cf113e1c68 Mon Sep 17 00:00:00 2001 From: denghui <1016848185@qq.com> Date: Wed, 25 Jun 2025 10:34:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=93=8D=E4=BD=9C=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E5=A5=96=E5=8A=B1=E7=9A=84=E6=8E=A5=E5=8F=A3=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/reward/v1/reward.go | 2 +- .../reward/reward_v1_operate_task_reward.go | 15 ++- internal/dao/internal/admins.go | 22 ++--- internal/dao/internal/feedbacks.go | 22 ++--- internal/dao/internal/games.go | 22 ++--- internal/dao/internal/merchant_admins.go | 22 ++--- internal/dao/internal/merchants.go | 22 ++--- internal/dao/internal/reward_types.go | 22 ++--- internal/dao/internal/rewards.go | 22 ++--- internal/dao/internal/roles.go | 22 ++--- internal/dao/internal/store_admins.go | 22 ++--- .../dao/internal/store_desktop_settings.go | 22 ++--- internal/dao/internal/store_ips.go | 22 ++--- .../dao/internal/store_netfee_area_level.go | 22 ++--- internal/dao/internal/store_roles.go | 22 ++--- internal/dao/internal/store_task_rewards.go | 91 ------------------- internal/dao/internal/stores.go | 22 ++--- internal/dao/internal/tasks.go | 22 ++--- internal/dao/internal/user_tasks.go | 22 ++--- internal/dao/internal/users.go | 22 ++--- internal/dao/store_task_rewards.go | 27 ------ internal/logic/reward/reward.go | 10 +- internal/logic/task/task.go | 45 +++++++-- internal/model/do/store_task_rewards.go | 22 ----- internal/model/entity/store_task_rewards.go | 20 ---- internal/model/entity/task_rewards.go | 4 +- internal/model/reward.go | 47 +++++----- internal/model/storeTaskReward.go | 40 -------- internal/model/task.go | 4 +- utility/myCasbin/casbin.go | 3 +- 30 files changed, 216 insertions(+), 488 deletions(-) delete mode 100644 internal/dao/internal/store_task_rewards.go delete mode 100644 internal/dao/store_task_rewards.go delete mode 100644 internal/model/do/store_task_rewards.go delete mode 100644 internal/model/entity/store_task_rewards.go delete mode 100644 internal/model/storeTaskReward.go diff --git a/api/reward/v1/reward.go b/api/reward/v1/reward.go index 4d84430..7e6a58a 100644 --- a/api/reward/v1/reward.go +++ b/api/reward/v1/reward.go @@ -269,7 +269,7 @@ type GetGoodsDetailsRes struct { } type OperateTaskRewardReq struct { - g.Meta `path:"/reward/addTaskReward" method:"post" tags:"Reward" summary:"添加任务奖励"` + g.Meta `path:"/reward/taskReward" method:"post" tags:"Reward" summary:"添加任务奖励"` Type int `json:"type" v:"required#操作类型只能为1或2,1是添加、2是删除" dc:"操作类型"` TaskId int64 `json:"taskId" v:"required#任务id不能为空" dc:"任务Id"` RewardId int64 `json:"rewardId" v:"required#奖励id不能为空" dc:"奖励Id"` diff --git a/internal/controller/reward/reward_v1_operate_task_reward.go b/internal/controller/reward/reward_v1_operate_task_reward.go index c12790a..e2117f4 100644 --- a/internal/controller/reward/reward_v1_operate_task_reward.go +++ b/internal/controller/reward/reward_v1_operate_task_reward.go @@ -2,12 +2,21 @@ package reward import ( "context" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/frame/g" + "server/internal/model" + "server/internal/service" "server/api/reward/v1" ) func (c *ControllerV1) OperateTaskReward(ctx context.Context, req *v1.OperateTaskRewardReq) (res *v1.OperateTaskRewardRes, err error) { - return nil, gerror.NewCode(gcode.CodeNotImplemented) + fromCtx := g.RequestFromCtx(ctx) + operatorId := fromCtx.GetCtxVar("id").Int64() + operatorRole := fromCtx.GetCtxVar("role").String() + out, err := service.Reward().OperateTaskReward(ctx, &model.OperateTaskRewardIn{OperatorId: operatorId, OperatorRole: operatorRole, RewardId: req.RewardId, TaskId: req.TaskId, Type: req.Type}) + if err != nil { + return nil, err + + } + return &v1.OperateTaskRewardRes{Success: out.Success}, nil } diff --git a/internal/dao/internal/admins.go b/internal/dao/internal/admins.go index dc72d15..7c3f2be 100644 --- a/internal/dao/internal/admins.go +++ b/internal/dao/internal/admins.go @@ -13,10 +13,9 @@ import ( // AdminsDao is the data access object for the table admins. type AdminsDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns AdminsColumns // columns contains all the column names of Table for convenient usage. - handlers []gdb.ModelHandler // handlers for customized model modification. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns AdminsColumns // columns contains all the column names of Table for convenient usage. } // AdminsColumns defines and stores column names for the table admins. @@ -50,12 +49,11 @@ var adminsColumns = AdminsColumns{ } // NewAdminsDao creates and returns a new DAO object for table data access. -func NewAdminsDao(handlers ...gdb.ModelHandler) *AdminsDao { +func NewAdminsDao() *AdminsDao { return &AdminsDao{ - group: "default", - table: "admins", - columns: adminsColumns, - handlers: handlers, + group: "default", + table: "admins", + columns: adminsColumns, } } @@ -81,11 +79,7 @@ func (dao *AdminsDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *AdminsDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/feedbacks.go b/internal/dao/internal/feedbacks.go index 7a8d085..d67a1e5 100644 --- a/internal/dao/internal/feedbacks.go +++ b/internal/dao/internal/feedbacks.go @@ -13,10 +13,9 @@ import ( // FeedbacksDao is the data access object for the table feedbacks. type FeedbacksDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns FeedbacksColumns // columns contains all the column names of Table for convenient usage. - handlers []gdb.ModelHandler // handlers for customized model modification. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns FeedbacksColumns // columns contains all the column names of Table for convenient usage. } // FeedbacksColumns defines and stores column names for the table feedbacks. @@ -52,12 +51,11 @@ var feedbacksColumns = FeedbacksColumns{ } // NewFeedbacksDao creates and returns a new DAO object for table data access. -func NewFeedbacksDao(handlers ...gdb.ModelHandler) *FeedbacksDao { +func NewFeedbacksDao() *FeedbacksDao { return &FeedbacksDao{ - group: "default", - table: "feedbacks", - columns: feedbacksColumns, - handlers: handlers, + group: "default", + table: "feedbacks", + columns: feedbacksColumns, } } @@ -83,11 +81,7 @@ func (dao *FeedbacksDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *FeedbacksDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/games.go b/internal/dao/internal/games.go index dac75c7..b53dd54 100644 --- a/internal/dao/internal/games.go +++ b/internal/dao/internal/games.go @@ -13,10 +13,9 @@ import ( // GamesDao is the data access object for the table games. type GamesDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns GamesColumns // columns contains all the column names of Table for convenient usage. - handlers []gdb.ModelHandler // handlers for customized model modification. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns GamesColumns // columns contains all the column names of Table for convenient usage. } // GamesColumns defines and stores column names for the table games. @@ -46,12 +45,11 @@ var gamesColumns = GamesColumns{ } // NewGamesDao creates and returns a new DAO object for table data access. -func NewGamesDao(handlers ...gdb.ModelHandler) *GamesDao { +func NewGamesDao() *GamesDao { return &GamesDao{ - group: "default", - table: "games", - columns: gamesColumns, - handlers: handlers, + group: "default", + table: "games", + columns: gamesColumns, } } @@ -77,11 +75,7 @@ func (dao *GamesDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *GamesDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/merchant_admins.go b/internal/dao/internal/merchant_admins.go index 64533e1..51ac691 100644 --- a/internal/dao/internal/merchant_admins.go +++ b/internal/dao/internal/merchant_admins.go @@ -13,10 +13,9 @@ import ( // MerchantAdminsDao is the data access object for the table merchant_admins. type MerchantAdminsDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns MerchantAdminsColumns // columns contains all the column names of Table for convenient usage. - handlers []gdb.ModelHandler // handlers for customized model modification. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns MerchantAdminsColumns // columns contains all the column names of Table for convenient usage. } // MerchantAdminsColumns defines and stores column names for the table merchant_admins. @@ -58,12 +57,11 @@ var merchantAdminsColumns = MerchantAdminsColumns{ } // NewMerchantAdminsDao creates and returns a new DAO object for table data access. -func NewMerchantAdminsDao(handlers ...gdb.ModelHandler) *MerchantAdminsDao { +func NewMerchantAdminsDao() *MerchantAdminsDao { return &MerchantAdminsDao{ - group: "default", - table: "merchant_admins", - columns: merchantAdminsColumns, - handlers: handlers, + group: "default", + table: "merchant_admins", + columns: merchantAdminsColumns, } } @@ -89,11 +87,7 @@ func (dao *MerchantAdminsDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *MerchantAdminsDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/merchants.go b/internal/dao/internal/merchants.go index 717f855..6dd5d05 100644 --- a/internal/dao/internal/merchants.go +++ b/internal/dao/internal/merchants.go @@ -13,10 +13,9 @@ import ( // MerchantsDao is the data access object for the table merchants. type MerchantsDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns MerchantsColumns // columns contains all the column names of Table for convenient usage. - handlers []gdb.ModelHandler // handlers for customized model modification. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns MerchantsColumns // columns contains all the column names of Table for convenient usage. } // MerchantsColumns defines and stores column names for the table merchants. @@ -72,12 +71,11 @@ var merchantsColumns = MerchantsColumns{ } // NewMerchantsDao creates and returns a new DAO object for table data access. -func NewMerchantsDao(handlers ...gdb.ModelHandler) *MerchantsDao { +func NewMerchantsDao() *MerchantsDao { return &MerchantsDao{ - group: "default", - table: "merchants", - columns: merchantsColumns, - handlers: handlers, + group: "default", + table: "merchants", + columns: merchantsColumns, } } @@ -103,11 +101,7 @@ func (dao *MerchantsDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *MerchantsDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/reward_types.go b/internal/dao/internal/reward_types.go index b8d246d..591cab5 100644 --- a/internal/dao/internal/reward_types.go +++ b/internal/dao/internal/reward_types.go @@ -13,10 +13,9 @@ import ( // RewardTypesDao is the data access object for the table reward_types. type RewardTypesDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns RewardTypesColumns // columns contains all the column names of Table for convenient usage. - handlers []gdb.ModelHandler // handlers for customized model modification. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns RewardTypesColumns // columns contains all the column names of Table for convenient usage. } // RewardTypesColumns defines and stores column names for the table reward_types. @@ -44,12 +43,11 @@ var rewardTypesColumns = RewardTypesColumns{ } // NewRewardTypesDao creates and returns a new DAO object for table data access. -func NewRewardTypesDao(handlers ...gdb.ModelHandler) *RewardTypesDao { +func NewRewardTypesDao() *RewardTypesDao { return &RewardTypesDao{ - group: "default", - table: "reward_types", - columns: rewardTypesColumns, - handlers: handlers, + group: "default", + table: "reward_types", + columns: rewardTypesColumns, } } @@ -75,11 +73,7 @@ func (dao *RewardTypesDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *RewardTypesDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/rewards.go b/internal/dao/internal/rewards.go index 1f3bc3b..86d8d4c 100644 --- a/internal/dao/internal/rewards.go +++ b/internal/dao/internal/rewards.go @@ -13,10 +13,9 @@ import ( // RewardsDao is the data access object for the table rewards. type RewardsDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns RewardsColumns // columns contains all the column names of Table for convenient usage. - handlers []gdb.ModelHandler // handlers for customized model modification. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns RewardsColumns // columns contains all the column names of Table for convenient usage. } // RewardsColumns defines and stores column names for the table rewards. @@ -72,12 +71,11 @@ var rewardsColumns = RewardsColumns{ } // NewRewardsDao creates and returns a new DAO object for table data access. -func NewRewardsDao(handlers ...gdb.ModelHandler) *RewardsDao { +func NewRewardsDao() *RewardsDao { return &RewardsDao{ - group: "default", - table: "rewards", - columns: rewardsColumns, - handlers: handlers, + group: "default", + table: "rewards", + columns: rewardsColumns, } } @@ -103,11 +101,7 @@ func (dao *RewardsDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *RewardsDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/roles.go b/internal/dao/internal/roles.go index b540549..9eab304 100644 --- a/internal/dao/internal/roles.go +++ b/internal/dao/internal/roles.go @@ -13,10 +13,9 @@ import ( // RolesDao is the data access object for the table roles. type RolesDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns RolesColumns // columns contains all the column names of Table for convenient usage. - handlers []gdb.ModelHandler // handlers for customized model modification. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns RolesColumns // columns contains all the column names of Table for convenient usage. } // RolesColumns defines and stores column names for the table roles. @@ -48,12 +47,11 @@ var rolesColumns = RolesColumns{ } // NewRolesDao creates and returns a new DAO object for table data access. -func NewRolesDao(handlers ...gdb.ModelHandler) *RolesDao { +func NewRolesDao() *RolesDao { return &RolesDao{ - group: "default", - table: "roles", - columns: rolesColumns, - handlers: handlers, + group: "default", + table: "roles", + columns: rolesColumns, } } @@ -79,11 +77,7 @@ func (dao *RolesDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *RolesDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/store_admins.go b/internal/dao/internal/store_admins.go index 538322c..7bcffcc 100644 --- a/internal/dao/internal/store_admins.go +++ b/internal/dao/internal/store_admins.go @@ -13,10 +13,9 @@ import ( // StoreAdminsDao is the data access object for the table store_admins. type StoreAdminsDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns StoreAdminsColumns // columns contains all the column names of Table for convenient usage. - handlers []gdb.ModelHandler // handlers for customized model modification. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns StoreAdminsColumns // columns contains all the column names of Table for convenient usage. } // StoreAdminsColumns defines and stores column names for the table store_admins. @@ -58,12 +57,11 @@ var storeAdminsColumns = StoreAdminsColumns{ } // NewStoreAdminsDao creates and returns a new DAO object for table data access. -func NewStoreAdminsDao(handlers ...gdb.ModelHandler) *StoreAdminsDao { +func NewStoreAdminsDao() *StoreAdminsDao { return &StoreAdminsDao{ - group: "default", - table: "store_admins", - columns: storeAdminsColumns, - handlers: handlers, + group: "default", + table: "store_admins", + columns: storeAdminsColumns, } } @@ -89,11 +87,7 @@ func (dao *StoreAdminsDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *StoreAdminsDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/store_desktop_settings.go b/internal/dao/internal/store_desktop_settings.go index 88c9cb5..dec1ba9 100644 --- a/internal/dao/internal/store_desktop_settings.go +++ b/internal/dao/internal/store_desktop_settings.go @@ -13,10 +13,9 @@ import ( // StoreDesktopSettingsDao is the data access object for the table store_desktop_settings. type StoreDesktopSettingsDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns StoreDesktopSettingsColumns // columns contains all the column names of Table for convenient usage. - handlers []gdb.ModelHandler // handlers for customized model modification. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns StoreDesktopSettingsColumns // columns contains all the column names of Table for convenient usage. } // StoreDesktopSettingsColumns defines and stores column names for the table store_desktop_settings. @@ -34,12 +33,11 @@ var storeDesktopSettingsColumns = StoreDesktopSettingsColumns{ } // NewStoreDesktopSettingsDao creates and returns a new DAO object for table data access. -func NewStoreDesktopSettingsDao(handlers ...gdb.ModelHandler) *StoreDesktopSettingsDao { +func NewStoreDesktopSettingsDao() *StoreDesktopSettingsDao { return &StoreDesktopSettingsDao{ - group: "default", - table: "store_desktop_settings", - columns: storeDesktopSettingsColumns, - handlers: handlers, + group: "default", + table: "store_desktop_settings", + columns: storeDesktopSettingsColumns, } } @@ -65,11 +63,7 @@ func (dao *StoreDesktopSettingsDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *StoreDesktopSettingsDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/store_ips.go b/internal/dao/internal/store_ips.go index dfdfd58..20197cb 100644 --- a/internal/dao/internal/store_ips.go +++ b/internal/dao/internal/store_ips.go @@ -13,10 +13,9 @@ import ( // StoreIpsDao is the data access object for the table store_ips. type StoreIpsDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns StoreIpsColumns // columns contains all the column names of Table for convenient usage. - handlers []gdb.ModelHandler // handlers for customized model modification. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns StoreIpsColumns // columns contains all the column names of Table for convenient usage. } // StoreIpsColumns defines and stores column names for the table store_ips. @@ -42,12 +41,11 @@ var storeIpsColumns = StoreIpsColumns{ } // NewStoreIpsDao creates and returns a new DAO object for table data access. -func NewStoreIpsDao(handlers ...gdb.ModelHandler) *StoreIpsDao { +func NewStoreIpsDao() *StoreIpsDao { return &StoreIpsDao{ - group: "default", - table: "store_ips", - columns: storeIpsColumns, - handlers: handlers, + group: "default", + table: "store_ips", + columns: storeIpsColumns, } } @@ -73,11 +71,7 @@ func (dao *StoreIpsDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *StoreIpsDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/store_netfee_area_level.go b/internal/dao/internal/store_netfee_area_level.go index ffa209a..e2a43a6 100644 --- a/internal/dao/internal/store_netfee_area_level.go +++ b/internal/dao/internal/store_netfee_area_level.go @@ -13,10 +13,9 @@ import ( // StoreNetfeeAreaLevelDao is the data access object for the table store_netfee_area_level. type StoreNetfeeAreaLevelDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns StoreNetfeeAreaLevelColumns // columns contains all the column names of Table for convenient usage. - handlers []gdb.ModelHandler // handlers for customized model modification. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns StoreNetfeeAreaLevelColumns // columns contains all the column names of Table for convenient usage. } // StoreNetfeeAreaLevelColumns defines and stores column names for the table store_netfee_area_level. @@ -50,12 +49,11 @@ var storeNetfeeAreaLevelColumns = StoreNetfeeAreaLevelColumns{ } // NewStoreNetfeeAreaLevelDao creates and returns a new DAO object for table data access. -func NewStoreNetfeeAreaLevelDao(handlers ...gdb.ModelHandler) *StoreNetfeeAreaLevelDao { +func NewStoreNetfeeAreaLevelDao() *StoreNetfeeAreaLevelDao { return &StoreNetfeeAreaLevelDao{ - group: "default", - table: "store_netfee_area_level", - columns: storeNetfeeAreaLevelColumns, - handlers: handlers, + group: "default", + table: "store_netfee_area_level", + columns: storeNetfeeAreaLevelColumns, } } @@ -81,11 +79,7 @@ func (dao *StoreNetfeeAreaLevelDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *StoreNetfeeAreaLevelDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/store_roles.go b/internal/dao/internal/store_roles.go index 137e1fa..8528459 100644 --- a/internal/dao/internal/store_roles.go +++ b/internal/dao/internal/store_roles.go @@ -13,10 +13,9 @@ import ( // StoreRolesDao is the data access object for the table store_roles. type StoreRolesDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns StoreRolesColumns // columns contains all the column names of Table for convenient usage. - handlers []gdb.ModelHandler // handlers for customized model modification. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns StoreRolesColumns // columns contains all the column names of Table for convenient usage. } // StoreRolesColumns defines and stores column names for the table store_roles. @@ -40,12 +39,11 @@ var storeRolesColumns = StoreRolesColumns{ } // NewStoreRolesDao creates and returns a new DAO object for table data access. -func NewStoreRolesDao(handlers ...gdb.ModelHandler) *StoreRolesDao { +func NewStoreRolesDao() *StoreRolesDao { return &StoreRolesDao{ - group: "default", - table: "store_roles", - columns: storeRolesColumns, - handlers: handlers, + group: "default", + table: "store_roles", + columns: storeRolesColumns, } } @@ -71,11 +69,7 @@ func (dao *StoreRolesDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *StoreRolesDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/store_task_rewards.go b/internal/dao/internal/store_task_rewards.go deleted file mode 100644 index 7c7ab6a..0000000 --- a/internal/dao/internal/store_task_rewards.go +++ /dev/null @@ -1,91 +0,0 @@ -// ========================================================================== -// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. -// ========================================================================== - -package internal - -import ( - "context" - - "github.com/gogf/gf/v2/database/gdb" - "github.com/gogf/gf/v2/frame/g" -) - -// StoreTaskRewardsDao is the data access object for the table store_task_rewards. -type StoreTaskRewardsDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns StoreTaskRewardsColumns // columns contains all the column names of Table for convenient usage. - handlers []gdb.ModelHandler // handlers for customized model modification. -} - -// StoreTaskRewardsColumns defines and stores column names for the table store_task_rewards. -type StoreTaskRewardsColumns struct { - Id string // 任务奖励关联ID - TaskId string // 腾讯任务ID - RewardId string // 奖励ID - StoreId string // 门店ID - CreatedAt string // 创建时间 - UpdatedAt string // 更新时间 - DeletedAt string // 软删除时间戳 -} - -// storeTaskRewardsColumns holds the columns for the table store_task_rewards. -var storeTaskRewardsColumns = StoreTaskRewardsColumns{ - Id: "id", - TaskId: "task_id", - RewardId: "reward_id", - StoreId: "store_id", - CreatedAt: "created_at", - UpdatedAt: "updated_at", - DeletedAt: "deleted_at", -} - -// NewStoreTaskRewardsDao creates and returns a new DAO object for table data access. -func NewStoreTaskRewardsDao(handlers ...gdb.ModelHandler) *StoreTaskRewardsDao { - return &StoreTaskRewardsDao{ - group: "default", - table: "store_task_rewards", - columns: storeTaskRewardsColumns, - handlers: handlers, - } -} - -// DB retrieves and returns the underlying raw database management object of the current DAO. -func (dao *StoreTaskRewardsDao) DB() gdb.DB { - return g.DB(dao.group) -} - -// Table returns the table name of the current DAO. -func (dao *StoreTaskRewardsDao) Table() string { - return dao.table -} - -// Columns returns all column names of the current DAO. -func (dao *StoreTaskRewardsDao) Columns() StoreTaskRewardsColumns { - return dao.columns -} - -// Group returns the database configuration group name of the current DAO. -func (dao *StoreTaskRewardsDao) Group() string { - return dao.group -} - -// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. -func (dao *StoreTaskRewardsDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) -} - -// Transaction wraps the transaction logic using function f. -// It rolls back the transaction and returns the error if function f returns a non-nil error. -// It commits the transaction and returns nil if function f returns nil. -// -// Note: Do not commit or roll back the transaction in function f, -// as it is automatically handled by this function. -func (dao *StoreTaskRewardsDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { - return dao.Ctx(ctx).Transaction(ctx, f) -} diff --git a/internal/dao/internal/stores.go b/internal/dao/internal/stores.go index 69ed619..8bbdc42 100644 --- a/internal/dao/internal/stores.go +++ b/internal/dao/internal/stores.go @@ -13,10 +13,9 @@ import ( // StoresDao is the data access object for the table stores. type StoresDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns StoresColumns // columns contains all the column names of Table for convenient usage. - handlers []gdb.ModelHandler // handlers for customized model modification. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns StoresColumns // columns contains all the column names of Table for convenient usage. } // StoresColumns defines and stores column names for the table stores. @@ -52,12 +51,11 @@ var storesColumns = StoresColumns{ } // NewStoresDao creates and returns a new DAO object for table data access. -func NewStoresDao(handlers ...gdb.ModelHandler) *StoresDao { +func NewStoresDao() *StoresDao { return &StoresDao{ - group: "default", - table: "stores", - columns: storesColumns, - handlers: handlers, + group: "default", + table: "stores", + columns: storesColumns, } } @@ -83,11 +81,7 @@ func (dao *StoresDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *StoresDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/tasks.go b/internal/dao/internal/tasks.go index dfd5153..526632b 100644 --- a/internal/dao/internal/tasks.go +++ b/internal/dao/internal/tasks.go @@ -13,10 +13,9 @@ import ( // TasksDao is the data access object for the table tasks. type TasksDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns TasksColumns // columns contains all the column names of Table for convenient usage. - handlers []gdb.ModelHandler // handlers for customized model modification. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns TasksColumns // columns contains all the column names of Table for convenient usage. } // TasksColumns defines and stores column names for the table tasks. @@ -58,12 +57,11 @@ var tasksColumns = TasksColumns{ } // NewTasksDao creates and returns a new DAO object for table data access. -func NewTasksDao(handlers ...gdb.ModelHandler) *TasksDao { +func NewTasksDao() *TasksDao { return &TasksDao{ - group: "default", - table: "tasks", - columns: tasksColumns, - handlers: handlers, + group: "default", + table: "tasks", + columns: tasksColumns, } } @@ -89,11 +87,7 @@ func (dao *TasksDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *TasksDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/user_tasks.go b/internal/dao/internal/user_tasks.go index 257329e..69ac1d3 100644 --- a/internal/dao/internal/user_tasks.go +++ b/internal/dao/internal/user_tasks.go @@ -13,10 +13,9 @@ import ( // UserTasksDao is the data access object for the table user_tasks. type UserTasksDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns UserTasksColumns // columns contains all the column names of Table for convenient usage. - handlers []gdb.ModelHandler // handlers for customized model modification. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns UserTasksColumns // columns contains all the column names of Table for convenient usage. } // UserTasksColumns defines and stores column names for the table user_tasks. @@ -52,12 +51,11 @@ var userTasksColumns = UserTasksColumns{ } // NewUserTasksDao creates and returns a new DAO object for table data access. -func NewUserTasksDao(handlers ...gdb.ModelHandler) *UserTasksDao { +func NewUserTasksDao() *UserTasksDao { return &UserTasksDao{ - group: "default", - table: "user_tasks", - columns: userTasksColumns, - handlers: handlers, + group: "default", + table: "user_tasks", + columns: userTasksColumns, } } @@ -83,11 +81,7 @@ func (dao *UserTasksDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *UserTasksDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/internal/users.go b/internal/dao/internal/users.go index 340eaf7..c5aa79d 100644 --- a/internal/dao/internal/users.go +++ b/internal/dao/internal/users.go @@ -13,10 +13,9 @@ import ( // UsersDao is the data access object for the table users. type UsersDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns UsersColumns // columns contains all the column names of Table for convenient usage. - handlers []gdb.ModelHandler // handlers for customized model modification. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns UsersColumns // columns contains all the column names of Table for convenient usage. } // UsersColumns defines and stores column names for the table users. @@ -60,12 +59,11 @@ var usersColumns = UsersColumns{ } // NewUsersDao creates and returns a new DAO object for table data access. -func NewUsersDao(handlers ...gdb.ModelHandler) *UsersDao { +func NewUsersDao() *UsersDao { return &UsersDao{ - group: "default", - table: "users", - columns: usersColumns, - handlers: handlers, + group: "default", + table: "users", + columns: usersColumns, } } @@ -91,11 +89,7 @@ func (dao *UsersDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *UsersDao) Ctx(ctx context.Context) *gdb.Model { - model := dao.DB().Model(dao.table) - for _, handler := range dao.handlers { - model = handler(model) - } - return model.Safe().Ctx(ctx) + return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/internal/dao/store_task_rewards.go b/internal/dao/store_task_rewards.go deleted file mode 100644 index d3c923e..0000000 --- a/internal/dao/store_task_rewards.go +++ /dev/null @@ -1,27 +0,0 @@ -// ================================================================================= -// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed. -// ================================================================================= - -package dao - -import ( - "server/internal/dao/internal" -) - -// internalStoreTaskRewardsDao is an internal type for wrapping the internal DAO implementation. -type internalStoreTaskRewardsDao = *internal.StoreTaskRewardsDao - -// storeTaskRewardsDao is the data access object for the table store_task_rewards. -// You can define custom methods on it to extend its functionality as needed. -type storeTaskRewardsDao struct { - internalStoreTaskRewardsDao -} - -var ( - // StoreTaskRewards is a globally accessible object for table store_task_rewards operations. - StoreTaskRewards = storeTaskRewardsDao{ - internal.NewStoreTaskRewardsDao(), - } -) - -// Add your custom methods and functionality below. diff --git a/internal/logic/reward/reward.go b/internal/logic/reward/reward.go index 665943a..acf2196 100644 --- a/internal/logic/reward/reward.go +++ b/internal/logic/reward/reward.go @@ -476,15 +476,7 @@ func (s *sReward) GetGoodsDetails(ctx context.Context, in *model.GetGoodsDetails func (s *sReward) OperateTaskReward(ctx context.Context, in *model.OperateTaskRewardIn) (out *model.OperateTaskRewardOut, err error) { // 如果是系统管理员给任务添加奖励,需要校验奖励的来源 - exist, err := dao.Tasks.Ctx(ctx).Where(do.Tasks{Id: in.TaskId}).Exist() - if err != nil { - return nil, ecode.Fail.Sub("任务不存在") - } - if !exist { - return nil, ecode.Params.Sub("任务不存在") - } - - exist, err = dao.Rewards.Ctx(ctx).Where(do.Rewards{Id: in.RewardId}).Exist() + exist, err := dao.Rewards.Ctx(ctx).Where(do.Rewards{Id: in.RewardId}).Exist() if err != nil { return nil, ecode.Fail.Sub("奖励不存在") } diff --git a/internal/logic/task/task.go b/internal/logic/task/task.go index d8c4fa5..6ec29e8 100644 --- a/internal/logic/task/task.go +++ b/internal/logic/task/task.go @@ -160,15 +160,31 @@ func (s *sTask) GetNonLoginTaskList(ctx context.Context, in *model.GetTaskListIn QqNetbarTaskName: task.Title, QqNetbarTaskMemo: task.TaskDesc, QqNetbarTaskRules: task.RuleDesc, - QqNetbarReward: task.TargetName, + QqNetbarTargetName: task.TargetName, QqNetbarTargetTime: task.TargetTimes, StartTime: task.CycleStart, EndTime: task.CycleEnd, } - // 组装门店奖励数据 - err := dao.StoreTaskRewards.Ctx(ctx).InnerJoin(dao.Rewards.Table(), fmt.Sprintf("%s.%s = %s.%s", dao.StoreTaskRewards.Table(), dao.StoreTaskRewards.Columns().RewardId, dao.Rewards.Table(), dao.Rewards.Columns().Id)). - Where(dao.StoreTaskRewards.Columns().TaskId, task.TaskID).Fields(fmt.Sprintf("%s.*", dao.Rewards.Table())).Scan(&data.NetbarRewards) + // 组装奖励数据 + err := dao.TaskRewards.Ctx(ctx). + LeftJoin(dao.Rewards.Table(), + fmt.Sprintf("`%s`.`%s` = `%s`.`%s`", + dao.Rewards.Table(), dao.Rewards.Columns().Id, + dao.TaskRewards.Table(), dao.TaskRewards.Columns().RewardId)). + LeftJoin(dao.RewardTypes.Table(), + fmt.Sprintf("`%s`.`%s` = `%s`.`%s`", + dao.RewardTypes.Table(), dao.RewardTypes.Columns().Id, + dao.Rewards.Table(), dao.Rewards.Columns().RewardTypeId)). + Fields( + fmt.Sprintf("%s.*, `%s`.`%s` AS %s, `%s`.`%s` AS %s", + dao.Rewards.Table(), + dao.RewardTypes.Table(), dao.RewardTypes.Columns().Name, + "reward_type_name", + dao.RewardTypes.Table(), dao.RewardTypes.Columns().Source, + "reward_type_source", + ), + ).Where(dao.TaskRewards.Columns().TaskId, task.TaskID).Scan(&data.Rewards) if err != nil { return nil, err } @@ -202,7 +218,7 @@ func (s *sTask) GetLoginTaskList(ctx context.Context, in *model.GetTaskListIn) ( QqNetbarTaskName: task.Title, QqNetbarTaskMemo: task.TaskDesc, QqNetbarTaskRules: task.RuleDesc, - QqNetbarReward: task.TargetName, + QqNetbarTargetName: task.TargetName, QqNetbarTargetTime: task.TargetTimes, StartTime: task.CycleStart, EndTime: task.CycleEnd, @@ -210,9 +226,22 @@ func (s *sTask) GetLoginTaskList(ctx context.Context, in *model.GetTaskListIn) ( } data.UserTaskResult.Usertimes = task.UserTimes // 组装门店奖励数据 - err := dao.Tasks.Ctx(ctx).InnerJoin(dao.StoreTaskRewards.Table(), fmt.Sprintf("%s.%s = %s.%s", dao.Tasks.Table(), dao.Tasks.Columns().Id, dao.StoreTaskRewards.Table(), dao.StoreTaskRewards.Columns().TaskId)). - InnerJoin(dao.Rewards.Table(), fmt.Sprintf("%s.%s = %s.%s", dao.StoreTaskRewards.Table(), dao.StoreTaskRewards.Columns().RewardId, dao.Rewards.Table(), dao.Rewards.Columns().Id)). - Where(dao.Tasks.Columns().QqNetbarTaskId, task.TaskID).Fields(fmt.Sprintf("%s.*", dao.Rewards.Table())).Scan(&data.NetbarRewards) + err := dao.TaskRewards.Ctx(ctx). + LeftJoin(dao.Rewards.Table(), + fmt.Sprintf("`%s`.`%s` = `%s`.`%s`", + dao.Rewards.Table(), dao.Rewards.Columns().Id, + dao.TaskRewards.Table(), dao.TaskRewards.Columns().RewardId)). + LeftJoin(dao.RewardTypes.Table(), + fmt.Sprintf("`%s`.`%s` = `%s`.`%s`", + dao.RewardTypes.Table(), dao.RewardTypes.Columns().Id, + dao.Rewards.Table(), dao.Rewards.Columns().RewardTypeId)). + Fields( + fmt.Sprintf("%s.*, `%s`.`%s` AS %s", + dao.Rewards.Table(), + dao.RewardTypes.Table(), dao.RewardTypes.Columns().Name, + "reward_type_name", + ), + ).Where(dao.TaskRewards.Columns().TaskId, task.TaskID).Scan(&data.Rewards) if err != nil { return nil, err } diff --git a/internal/model/do/store_task_rewards.go b/internal/model/do/store_task_rewards.go deleted file mode 100644 index 32a3e93..0000000 --- a/internal/model/do/store_task_rewards.go +++ /dev/null @@ -1,22 +0,0 @@ -// ================================================================================= -// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. -// ================================================================================= - -package do - -import ( - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gtime" -) - -// StoreTaskRewards is the golang structure of table store_task_rewards for DAO operations like Where/Data. -type StoreTaskRewards struct { - g.Meta `orm:"table:store_task_rewards, do:true"` - Id interface{} // 任务奖励关联ID - TaskId interface{} // 腾讯任务ID - RewardId interface{} // 奖励ID - StoreId interface{} // 门店ID - CreatedAt *gtime.Time // 创建时间 - UpdatedAt *gtime.Time // 更新时间 - DeletedAt *gtime.Time // 软删除时间戳 -} diff --git a/internal/model/entity/store_task_rewards.go b/internal/model/entity/store_task_rewards.go deleted file mode 100644 index b88075f..0000000 --- a/internal/model/entity/store_task_rewards.go +++ /dev/null @@ -1,20 +0,0 @@ -// ================================================================================= -// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. -// ================================================================================= - -package entity - -import ( - "github.com/gogf/gf/v2/os/gtime" -) - -// StoreTaskRewards is the golang structure for table store_task_rewards. -type StoreTaskRewards struct { - Id int64 `json:"id" orm:"id" description:"任务奖励关联ID"` // 任务奖励关联ID - TaskId string `json:"taskId" orm:"task_id" description:"腾讯任务ID"` // 腾讯任务ID - RewardId int64 `json:"rewardId" orm:"reward_id" description:"奖励ID"` // 奖励ID - StoreId int64 `json:"storeId" orm:"store_id" description:"门店ID"` // 门店ID - CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间 - UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间 - DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间戳"` // 软删除时间戳 -} diff --git a/internal/model/entity/task_rewards.go b/internal/model/entity/task_rewards.go index 334fe86..549c883 100644 --- a/internal/model/entity/task_rewards.go +++ b/internal/model/entity/task_rewards.go @@ -6,6 +6,6 @@ package entity // TaskRewards is the golang structure for table task_rewards. type TaskRewards struct { - TaskId int64 `json:"taskId" orm:"task_id" description:"任务ID"` // 任务ID - RewardId int64 `json:"rewardId" orm:"reward_id" description:"奖励ID"` // 奖励ID + TaskId string `json:"taskId" orm:"task_id" description:"任务ID"` // 任务ID + RewardId int64 `json:"rewardId" orm:"reward_id" description:"奖励ID"` // 奖励ID } diff --git a/internal/model/reward.go b/internal/model/reward.go index a02ff87..79cf5df 100644 --- a/internal/model/reward.go +++ b/internal/model/reward.go @@ -6,29 +6,30 @@ import ( // Reward 奖励表 type Reward struct { - Id int64 `json:"id" orm:"id" description:"奖励ID"` // 奖励ID - StoreId int64 `json:"storeId" orm:"store_id" description:"门店ID,系统奖励为NULL"` // 门店ID,系统奖励为NULL - Name string `json:"name" orm:"name" description:"奖励名称"` // 奖励名称 - RewardTypeId int64 `json:"rewardTypeId" orm:"reward_type_id" description:"奖励类型ID,关联 reward_types 表"` // 奖励类型ID,关联 reward_types 表 - RewardTypeName string `json:"rewardTypeName" orm:"reward_type_name" description:"奖励类型名称"` // 奖励类型名称 - GameId int64 `json:"gameId" orm:"game_id" description:"游戏ID"` // 游戏ID - ImageUrl string `json:"imageUrl" orm:"image_url" description:"奖励图片链接"` // 奖励图片链接 - QqGoodsId string `json:"qqGoodsId" orm:"qq_goods_id" description:"QQ网吧物品ID"` // QQ网吧物品ID - QqGoodsIdStr string `json:"qqGoodsIdStr" orm:"qq_goods_id_str" description:"QQ网吧物品ID字符串"` // QQ网吧物品ID字符串 - Status int `json:"status" orm:"status" description:"状态:1=启用,2=禁用"` // 状态:1=启用,2=禁用 - ExpireType int `json:"expireType" orm:"expire_type" description:"过期方式:1=时间段过期,2=领取后过期"` // 过期方式:1=时间段过期,2=领取后过期 - ValidFrom *gtime.Time `json:"validFrom" orm:"valid_from" description:"有效期开始时间(expire_type=1时)"` // 有效期开始时间(expire_type=1时) - ValidTo *gtime.Time `json:"validTo" orm:"valid_to" description:"有效期结束时间(expire_type=1时)"` // 有效期结束时间(expire_type=1时) - ExpireDays int `json:"expireDays" orm:"expire_days" description:"领取后多少天过期(expire_type=2时)"` // 领取后多少天过期(expire_type=2时) - DailyTotalLimit uint64 `json:"dailyTotalLimit" orm:"daily_total_limit" description:"每日发放总限(NULL表示不限制)"` // 每日发放总限(NULL表示不限制) - TotalLimit uint64 `json:"totalLimit" orm:"total_limit" description:"奖励总限(NULL表示不限制)"` // 奖励总限(NULL表示不限制) - UserDailyLimit uint64 `json:"userDailyLimit" orm:"user_daily_limit" description:"用户每日领取限制(NULL表示不限制)"` // 用户每日领取限制(NULL表示不限制) - UserTotalLimit uint64 `json:"userTotalLimit" orm:"user_total_limit" description:"用户领取总次数限制(NULL表示不限制)"` // 用户领取总次数限制(NULL表示不限制) - ReceivedNum uint64 `json:"receivedNum" orm:"received_num" description:"已领取数量"` // 已领取数量 - GrantQuantity uint64 `json:"grantQuantity" orm:"grant_quantity" description:"每次发放个数"` // 每次发放个数 - CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间 - UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间 - DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"删除时间(软删除)"` // 删除时间(软删除) + Id int64 `json:"id" orm:"id" description:"奖励ID"` // 奖励ID + StoreId int64 `json:"storeId" orm:"store_id" description:"门店ID,系统奖励为NULL"` // 门店ID,系统奖励为NULL + Name string `json:"name" orm:"name" description:"奖励名称"` // 奖励名称 + RewardTypeId int64 `json:"rewardTypeId" orm:"reward_type_id" description:"奖励类型ID,关联 reward_types 表"` // 奖励类型ID,关联 reward_types 表 + RewardTypeName string `json:"rewardTypeName" orm:"reward_type_name" description:"奖励类型名称"` // 奖励类型名称 + RewardTypeSource int `json:"rewardTypeSource" orm:"reward_type_source" description:"奖励类型来源"` // 奖励类型来源 + GameId int64 `json:"gameId" orm:"game_id" description:"游戏ID"` // 游戏ID + ImageUrl string `json:"imageUrl" orm:"image_url" description:"奖励图片链接"` // 奖励图片链接 + QqGoodsId string `json:"qqGoodsId" orm:"qq_goods_id" description:"QQ网吧物品ID"` // QQ网吧物品ID + QqGoodsIdStr string `json:"qqGoodsIdStr" orm:"qq_goods_id_str" description:"QQ网吧物品ID字符串"` // QQ网吧物品ID字符串 + Status int `json:"status" orm:"status" description:"状态:1=启用,2=禁用"` // 状态:1=启用,2=禁用 + ExpireType int `json:"expireType" orm:"expire_type" description:"过期方式:1=时间段过期,2=领取后过期"` // 过期方式:1=时间段过期,2=领取后过期 + ValidFrom *gtime.Time `json:"validFrom" orm:"valid_from" description:"有效期开始时间(expire_type=1时)"` // 有效期开始时间(expire_type=1时) + ValidTo *gtime.Time `json:"validTo" orm:"valid_to" description:"有效期结束时间(expire_type=1时)"` // 有效期结束时间(expire_type=1时) + ExpireDays int `json:"expireDays" orm:"expire_days" description:"领取后多少天过期(expire_type=2时)"` // 领取后多少天过期(expire_type=2时) + DailyTotalLimit uint64 `json:"dailyTotalLimit" orm:"daily_total_limit" description:"每日发放总限(NULL表示不限制)"` // 每日发放总限(NULL表示不限制) + TotalLimit uint64 `json:"totalLimit" orm:"total_limit" description:"奖励总限(NULL表示不限制)"` // 奖励总限(NULL表示不限制) + UserDailyLimit uint64 `json:"userDailyLimit" orm:"user_daily_limit" description:"用户每日领取限制(NULL表示不限制)"` // 用户每日领取限制(NULL表示不限制) + UserTotalLimit uint64 `json:"userTotalLimit" orm:"user_total_limit" description:"用户领取总次数限制(NULL表示不限制)"` // 用户领取总次数限制(NULL表示不限制) + ReceivedNum uint64 `json:"receivedNum" orm:"received_num" description:"已领取数量"` // 已领取数量 + GrantQuantity uint64 `json:"grantQuantity" orm:"grant_quantity" description:"每次发放个数"` // 每次发放个数 + CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间 + UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间 + DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"删除时间(软删除)"` // 删除时间(软删除) } // RewardCreateIn 创建奖励入参 diff --git a/internal/model/storeTaskReward.go b/internal/model/storeTaskReward.go deleted file mode 100644 index 802ba33..0000000 --- a/internal/model/storeTaskReward.go +++ /dev/null @@ -1,40 +0,0 @@ -package model - -import ( - "github.com/gogf/gf/v2/frame/g" -) - -// StoreTaskReward 门店任务奖励关联表 -type StoreTaskReward struct { - g.Meta `orm:"table:store_task_rewards"` - Id int64 `json:"id" dc:"任务奖励关联ID" orm:"id,primary"` - TaskId int64 `json:"taskId" dc:"门店任务ID" orm:"task_id"` - RewardId int64 `json:"rewardId" dc:"奖励ID" orm:"reward_id"` - StoreId int64 `json:"storeId" dc:"门店ID" orm:"store_id"` -} - -// StoreTaskRewardCreateIn 创建任务奖励关联入参 -type StoreTaskRewardCreateIn struct { - OperatorId int64 - OperatorRole string - TaskId string // 门店任务ID - RewardId int64 // 奖励ID - StoreId int64 // 门店ID -} - -// StoreTaskRewardCreateOut 创建任务奖励关联出参 -type StoreTaskRewardCreateOut struct { - Id int64 // 创建成功后返回的ID -} - -// StoreTaskRewardDeleteIn 删除任务奖励关联入参 -type StoreTaskRewardDeleteIn struct { - Id int64 // 任务奖励关联ID - OperatorId int64 - OperatorRole string -} - -// StoreTaskRewardDeleteOut 删除任务奖励关联出参 -type StoreTaskRewardDeleteOut struct { - Success bool // 是否删除成功 -} diff --git a/internal/model/task.go b/internal/model/task.go index edc56d8..86a3148 100644 --- a/internal/model/task.go +++ b/internal/model/task.go @@ -17,11 +17,11 @@ type Task struct { QqNetbarTaskRules string `json:"qqNetbarTaskRules" orm:"qq_netbar_task_rules" description:"任务规则"` // 任务规则 QqNetbarTaskMemo string `json:"qqNetbarTaskMemo" orm:"qq_netbar_task_memo" description:"任务描述"` // 任务描述 QqNetbarTaskName string `json:"qqNetbarTaskName" orm:"qq_netbar_task_name" description:"QQ网吧任务名称"` // QQ网吧任务名称 - QqNetbarReward string `json:"qqNetbarReward" orm:"qq_netbar_reward" description:"qq 网吧奖励名称"` // qq 网吧奖励名称 + QqNetbarTargetName string `json:"qqNetbarTargetName" orm:"qq_netbar_target_name" description:"任务指标名称"` // 任务指标名称 QqNetbarTargetTime int `json:"qqNetbarTargetTime" orm:"qq_netbar_target_time" description:"qq 网吧任务指标"` // qq 网吧任务指标 StartTime int64 `json:"startTime" orm:"start_time" description:"任务开始时间"` // 任务开始时间 EndTime int64 `json:"endTime" orm:"end_time" description:"任务结束时间"` // 任务结束时间 - NetbarRewards []Reward `json:"netbarRewards" orm:"-"` + Rewards []Reward `json:"rewards" orm:"-"` UserTaskResult UserTaskResult `json:"userTaskResult,omitempty"` } diff --git a/utility/myCasbin/casbin.go b/utility/myCasbin/casbin.go index 9c870ef..b5e4538 100644 --- a/utility/myCasbin/casbin.go +++ b/utility/myCasbin/casbin.go @@ -104,8 +104,7 @@ func init() { enforcer.AddPolicy("store", "/x/reward", "PUT", "更新奖励") enforcer.AddPolicy("store", "/x/reward/*", "DELETE", "删除奖励") - enforcer.AddPolicy("store", "/x/storeTaskReward", "POST", "添加门店任务奖励") - enforcer.AddPolicy("store", "/x/storeTaskReward/*", "DELETE", "删除门店任务奖励") + enforcer.AddPolicy("store", "/x/reward/taskReward", "POST", "添加/删除门店任务奖励") // 门店角色 enforcer.AddPolicy("store", "/x/store/role", "GET", "获取门店角色列表")