diff --git a/api/reward/v1/reward.go b/api/reward/v1/reward.go index 3f49952..1b9143d 100644 --- a/api/reward/v1/reward.go +++ b/api/reward/v1/reward.go @@ -9,8 +9,7 @@ type ListReq struct { Size int `json:"size" dc:"每页数量"` Status int `json:"status" dc:"状态"` StoreId int64 `json:"storeId" dc:"门店ID"` - OperatorRole int `json:"operatorRole" dc:"操作者角色"` - OperatorId int64 `json:"operatorId" dc:"操作者ID"` + RewardTypeId int64 `json:"rewardTypeId" dc:"奖励类型ID"` } type ListRes struct { @@ -27,8 +26,6 @@ type CreateReq struct { StoreId int64 `json:"storeId" dc:"门店ID"` RewardTypeId int64 `json:"rewardTypeId" v:"required#奖励类型ID不能为空" dc:"奖励类型ID"` Source int `json:"source" v:"in:1,2#来源只能为1或2" dc:"来源"` - OperatorRole int `json:"operatorRole" dc:"操作者角色"` - OperatorId int64 `json:"operatorId" dc:"操作者ID"` } type CreateRes struct { @@ -36,15 +33,13 @@ type CreateRes struct { } type UpdateReq struct { - g.Meta `path:"/reward" method:"put" tags:"Reward" summary:"(系统、商户、门店后台)更新奖励"` - Id int64 `json:"id" v:"required#ID不能为空" dc:"ID"` - Name string `json:"name" v:"required#名称不能为空" dc:"名称"` - Description string `json:"description" v:"required#描述不能为空" dc:"描述"` - Value int64 `json:"value" v:"required#数值不能为空" dc:"奖励值"` - Status int `json:"status" dc:"状态" d:"1"` - StoreId int64 `json:"storeId" dc:"门店ID"` - OperatorRole int `json:"operatorRole" dc:"操作者角色"` - OperatorId int64 `json:"operatorId" dc:"操作者ID"` + g.Meta `path:"/reward" method:"put" tags:"Reward" summary:"(系统、商户、门店后台)更新奖励"` + Id int64 `json:"id" v:"required#ID不能为空" dc:"ID"` + Name string `json:"name" v:"required#名称不能为空" dc:"名称"` + Description string `json:"description" v:"required#描述不能为空" dc:"描述"` + Value int64 `json:"value" v:"required#数值不能为空" dc:"奖励值"` + Status int `json:"status" dc:"状态" d:"1"` + StoreId int64 `json:"storeId" dc:"门店ID"` } type UpdateRes struct { @@ -52,10 +47,8 @@ type UpdateRes struct { } type DeleteReq struct { - g.Meta `path:"/reward/{id}" method:"delete" tags:"Reward" summary:"(系统、商户、门店后台)删除奖励"` - Id int64 `in:"path" json:"id" v:"required#ID不能为空" dc:"ID"` - OperatorRole int `json:"operatorRole" dc:"操作者角色"` - OperatorId int64 `json:"operatorId" dc:"操作者ID"` + g.Meta `path:"/reward/{id}" method:"delete" tags:"Reward" summary:"(系统、商户、门店后台)删除奖励"` + Id int64 `in:"path" json:"id" v:"required#ID不能为空" dc:"ID"` } type DeleteRes struct { diff --git a/api/storeTaskReward/storeTaskReward.go b/api/storeTaskReward/storeTaskReward.go new file mode 100644 index 0000000..c600baf --- /dev/null +++ b/api/storeTaskReward/storeTaskReward.go @@ -0,0 +1,16 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package storeTaskReward + +import ( + "context" + + "server/api/storeTaskReward/v1" +) + +type IStoreTaskRewardV1 interface { + Create(ctx context.Context, req *v1.CreateReq) (res *v1.CreateRes, err error) + Delete(ctx context.Context, req *v1.DeleteReq) (res *v1.DeleteRes, err error) +} diff --git a/api/storeTaskReward/v1/storeTaskReward.go b/api/storeTaskReward/v1/storeTaskReward.go new file mode 100644 index 0000000..8074d29 --- /dev/null +++ b/api/storeTaskReward/v1/storeTaskReward.go @@ -0,0 +1,22 @@ +package v1 + +import "github.com/gogf/gf/v2/frame/g" + +type CreateReq struct { + g.Meta `path:"/storeTaskReward" method:"post" tags:"StoreTaskReward" summary:"(商户、门店后台)创建门店任务奖励"` + TaskId int64 `json:"taskId" v:"required#门店任务ID不能为空" dc:"门店任务ID"` + RewardId int64 `json:"rewardId" v:"required#奖励ID不能为空" dc:"奖励ID"` + StoreId int64 `json:"storeId" v:"required#门店ID不能为空" dc:"门店ID"` +} + +type CreateRes struct { + Id int64 `json:"id"` +} + +type DeleteReq struct { + g.Meta `path:"/storeTaskReward/{id}" method:"delete" tags:"StoreTaskReward" summary:"(商户、门店后台)删除门店任务奖励"` + Id int64 `in:"path" json:"id" v:"required#门店任务奖励ID不能为空" dc:"门店任务奖励ID"` +} +type DeleteRes struct { + Success bool `json:"success" dc:"是否成功"` +} diff --git a/internal/cmd/cmd.go b/internal/cmd/cmd.go index 5fb107d..99565ac 100644 --- a/internal/cmd/cmd.go +++ b/internal/cmd/cmd.go @@ -17,6 +17,7 @@ import ( "server/internal/controller/store" "server/internal/controller/storeAdmin" "server/internal/controller/storeRole" + "server/internal/controller/storeTaskReward" "server/internal/controller/task" "server/internal/controller/upload" "server/internal/controller/user" @@ -56,6 +57,7 @@ var ( game.NewV1(), rewardType.NewV1(), reward.NewV1(), + storeTaskReward.NewV1(), ) }) }) diff --git a/internal/controller/storeTaskReward/storeTaskReward.go b/internal/controller/storeTaskReward/storeTaskReward.go new file mode 100644 index 0000000..940ca37 --- /dev/null +++ b/internal/controller/storeTaskReward/storeTaskReward.go @@ -0,0 +1,5 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package storeTaskReward diff --git a/internal/controller/storeTaskReward/storeTaskReward_new.go b/internal/controller/storeTaskReward/storeTaskReward_new.go new file mode 100644 index 0000000..b9899b8 --- /dev/null +++ b/internal/controller/storeTaskReward/storeTaskReward_new.go @@ -0,0 +1,15 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package storeTaskReward + +import ( + "server/api/storeTaskReward" +) + +type ControllerV1 struct{} + +func NewV1() storeTaskReward.IStoreTaskRewardV1 { + return &ControllerV1{} +} diff --git a/internal/controller/storeTaskReward/storeTaskReward_v1_create.go b/internal/controller/storeTaskReward/storeTaskReward_v1_create.go new file mode 100644 index 0000000..61ec376 --- /dev/null +++ b/internal/controller/storeTaskReward/storeTaskReward_v1_create.go @@ -0,0 +1,21 @@ +package storeTaskReward + +import ( + "context" + "github.com/gogf/gf/v2/frame/g" + "server/internal/model" + "server/internal/service" + + "server/api/storeTaskReward/v1" +) + +func (c *ControllerV1) Create(ctx context.Context, req *v1.CreateReq) (res *v1.CreateRes, err error) { + fromCtx := g.RequestFromCtx(ctx) + operatorId := fromCtx.GetCtxVar("id").Int64() + operatorRole := fromCtx.GetCtxVar("role").String() + out, err := service.StoreTaskReward().Create(ctx, &model.StoreTaskRewardCreateIn{OperatorId: operatorId, OperatorRole: operatorRole, RewardId: req.RewardId, StoreId: req.StoreId, TaskId: req.TaskId}) + if err != nil { + return nil, err + } + return &v1.CreateRes{Id: out.Id}, nil +} diff --git a/internal/controller/storeTaskReward/storeTaskReward_v1_delete.go b/internal/controller/storeTaskReward/storeTaskReward_v1_delete.go new file mode 100644 index 0000000..18e8ce8 --- /dev/null +++ b/internal/controller/storeTaskReward/storeTaskReward_v1_delete.go @@ -0,0 +1,21 @@ +package storeTaskReward + +import ( + "context" + "github.com/gogf/gf/v2/frame/g" + "server/internal/model" + "server/internal/service" + + "server/api/storeTaskReward/v1" +) + +func (c *ControllerV1) Delete(ctx context.Context, req *v1.DeleteReq) (res *v1.DeleteRes, err error) { + fromCtx := g.RequestFromCtx(ctx) + operatorId := fromCtx.GetCtxVar("id").Int64() + operatorRole := fromCtx.GetCtxVar("role").String() + out, err := service.StoreTaskReward().Delete(ctx, &model.StoreTaskRewardDeleteIn{Id: req.Id, OperatorId: operatorId, OperatorRole: operatorRole}) + if err != nil { + return nil, err + } + return &v1.DeleteRes{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 30b7375..9d2a944 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. @@ -46,12 +45,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, } } @@ -77,11 +75,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/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 600d641..d6469fa 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. @@ -46,12 +45,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, } } @@ -77,11 +75,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_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/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 b7c9b15..2926883 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. @@ -52,12 +51,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, } } @@ -83,11 +81,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 73bf579..095425b 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. @@ -48,12 +47,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, } } @@ -79,11 +77,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/logic/logic.go b/internal/logic/logic.go index eeea66b..dac7aa8 100644 --- a/internal/logic/logic.go +++ b/internal/logic/logic.go @@ -16,6 +16,7 @@ import ( _ "server/internal/logic/store" _ "server/internal/logic/storeAdmin" _ "server/internal/logic/storeRole" + _ "server/internal/logic/storeTaskReward" _ "server/internal/logic/task" _ "server/internal/logic/upload" _ "server/internal/logic/user" diff --git a/internal/logic/reward/reward.go b/internal/logic/reward/reward.go index e3db410..544e24a 100644 --- a/internal/logic/reward/reward.go +++ b/internal/logic/reward/reward.go @@ -293,6 +293,9 @@ func (s *sReward) List(ctx context.Context, in *model.RewardListIn) (out *model. if in.Name != "" { orm = orm.WhereLike(dao.Rewards.Columns().Name, "%"+in.Name+"%") } + if in.RewardTypeId != 0 { + orm = orm.Where(do.Rewards{RewardTypeId: in.RewardTypeId}) + } total, err := orm.Count() if err != nil { diff --git a/internal/logic/storeTaskReward/storeTaskReward.go b/internal/logic/storeTaskReward/storeTaskReward.go new file mode 100644 index 0000000..b1e0dc1 --- /dev/null +++ b/internal/logic/storeTaskReward/storeTaskReward.go @@ -0,0 +1,142 @@ +package storeTaskReward + +import ( + "context" + "fmt" + "server/internal/consts" + "server/internal/dao" + "server/internal/model" + "server/internal/model/do" + "server/internal/service" + "server/utility/ecode" +) + +type sStoreTaskReward struct { +} + +func New() service.IStoreTaskReward { + return &sStoreTaskReward{} +} +func init() { + service.RegisterStoreTaskReward(New()) +} +func (s *sStoreTaskReward) Create(ctx context.Context, in *model.StoreTaskRewardCreateIn) (out *model.StoreTaskRewardCreateOut, err error) { + if in.OperatorRole != consts.MerchantRoleCode && in.OperatorRole != consts.StoreRoleCode { + return nil, ecode.Params.Sub("仅允许商户或门店角色操作") + } + + // 检查操作者是否有该门店的操作权限 + switch in.OperatorRole { + case consts.MerchantRoleCode: + exist, err := dao.MerchantAdmins.Ctx(ctx). + Where(do.MerchantAdmins{Id: in.OperatorId}). + LeftJoin( + dao.Stores.Table(), + fmt.Sprintf( + "%s.%s = %s.%s", + dao.MerchantAdmins.Table(), dao.MerchantAdmins.Columns().MerchantId, + dao.Stores.Table(), dao.Stores.Columns().MerchantId, + ), + ). + Where(fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), in.StoreId). + Exist() + if err != nil { + return nil, ecode.Fail.Sub("校验商户权限失败") + } + if !exist { + return nil, ecode.Params.Sub("商户无操作该门店权限") + } + + case consts.StoreRoleCode: + exist, err := dao.StoreAdmins.Ctx(ctx). + Where(do.StoreAdmins{Id: in.OperatorId}). + LeftJoin( + dao.Stores.Table(), + fmt.Sprintf( + "%s.%s = %s.%s", + dao.StoreAdmins.Table(), dao.StoreAdmins.Columns().StoreId, + dao.Stores.Table(), dao.Stores.Columns().Id, + ), + ). + Where(fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), in.StoreId). + Exist() + if err != nil { + return nil, ecode.Fail.Sub("校验门店权限失败") + } + if !exist { + return nil, ecode.Params.Sub("门店管理员无权限") + } + } + + id, err := dao.StoreTaskRewards.Ctx(ctx).Data(do.StoreTaskRewards{ + StoreId: in.StoreId, + TaskId: in.TaskId, + RewardId: in.RewardId, + }).InsertAndGetId() + if err != nil { + return nil, ecode.Fail.Sub("创建门店任务奖励失败, err:" + err.Error()) + } + return &model.StoreTaskRewardCreateOut{Id: id}, nil +} + +func (s *sStoreTaskReward) Delete(ctx context.Context, in *model.StoreTaskRewardDeleteIn) (out *model.StoreTaskRewardDeleteOut, err error) { + if in.OperatorRole != consts.MerchantRoleCode && in.OperatorRole != consts.StoreRoleCode { + return nil, ecode.Params.Sub("仅允许商户或门店角色操作") + } + + // 检查操作者是否有该门店的操作权限 + value, err := dao.StoreTaskRewards.Ctx(ctx).WherePri(in.Id).Fields(dao.StoreTaskRewards.Columns().StoreId).Value() + if err != nil { + return nil, ecode.Fail.Sub("查询门店任务奖励失败, err:" + err.Error()) + } + if value.IsEmpty() { + return nil, ecode.Params.Sub("门店任务奖励不存在") + } + switch in.OperatorRole { + case consts.MerchantRoleCode: + exist, err := dao.MerchantAdmins.Ctx(ctx). + Where(do.MerchantAdmins{Id: in.OperatorId}). + LeftJoin( + dao.Stores.Table(), + fmt.Sprintf( + "%s.%s = %s.%s", + dao.MerchantAdmins.Table(), dao.MerchantAdmins.Columns().MerchantId, + dao.Stores.Table(), dao.Stores.Columns().MerchantId, + ), + ). + Where(fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), value.Int64()). + Exist() + if err != nil { + return nil, ecode.Fail.Sub("校验商户权限失败") + } + if !exist { + return nil, ecode.Params.Sub("商户无操作该门店权限") + } + + case consts.StoreRoleCode: + exist, err := dao.StoreAdmins.Ctx(ctx). + Where(do.StoreAdmins{Id: in.OperatorId}). + LeftJoin( + dao.Stores.Table(), + fmt.Sprintf( + "%s.%s = %s.%s", + dao.StoreAdmins.Table(), dao.StoreAdmins.Columns().StoreId, + dao.Stores.Table(), dao.Stores.Columns().Id, + ), + ). + Where(fmt.Sprintf("%s.%s = ?", dao.Stores.Table(), dao.Stores.Columns().Id), value.Int64()). + Exist() + if err != nil { + return nil, ecode.Fail.Sub("校验门店权限失败") + } + if !exist { + return nil, ecode.Params.Sub("门店管理员无权限") + } + } + _, err = dao.StoreTaskRewards.Ctx(ctx).WherePri(in.Id).Delete() + if err != nil { + return nil, ecode.Fail.Sub("删除门店任务奖励失败") + } + + return &model.StoreTaskRewardDeleteOut{Success: true}, nil +} diff --git a/internal/logic/task/task.go b/internal/logic/task/task.go index 456277f..c18fe21 100644 --- a/internal/logic/task/task.go +++ b/internal/logic/task/task.go @@ -231,7 +231,7 @@ func (s *sTask) GetLoginTaskList(ctx context.Context, in *model.GetLoginTaskList func (s *sTask) GetTaskList(ctx context.Context, in *model.TaskListIn) (out *model.TaskListOut, err error) { - var data []model.Tasks + var data []model.Task var total int m := dao.Tasks.Ctx(ctx) @@ -239,11 +239,19 @@ func (s *sTask) GetTaskList(ctx context.Context, in *model.TaskListIn) (out *mod m = m.Where(do.Tasks{StoreId: in.StoreId}) } - err = m.Page(in.Page, in.Size).Where(do.Tasks{GameId: in.Gid}).WithAll().ScanAndCount(&data, &total, false) - + err = m.Page(in.Page, in.Size).Where(do.Tasks{GameId: in.Gid}).ScanAndCount(&data, &total, false) if err != nil { return nil, ecode.Fail.Sub("任务列表获取失败") } + + for i, v := range data { + if err = dao.StoreTaskRewards.Ctx(ctx).Where(do.StoreTaskRewards{TaskId: v.Id, StoreId: in.StoreId}).LeftJoin( + dao.Rewards.Table(), + fmt.Sprintf("%s.%s = %s.%s", dao.Rewards.Table(), dao.Rewards.Columns().Id, dao.StoreTaskRewards.Table(), dao.StoreTaskRewards.Columns().RewardId), + ).Fields(fmt.Sprintf("%s.*", dao.Rewards.Table())).Scan(&data[i].NetbarRewards); err != nil { + return nil, ecode.Fail.Sub("任务奖励获取失败") + } + } return &model.TaskListOut{ List: data, Total: total, diff --git a/internal/model/gamelife.go b/internal/model/gamelife.go new file mode 100644 index 0000000..55b9ac4 --- /dev/null +++ b/internal/model/gamelife.go @@ -0,0 +1,62 @@ +package model + +type Goods struct { + GoodsType int `json:"goodstype"` + GoodsName string `json:"goodsname"` + GoodsIcon string `json:"goodsicon"` + Num int `json:"num"` +} + +type Prize struct { + Pic string `json:"pic"` + PrizeName string `json:"prize_name"` + GoodsList []Goods `json:"goods_list"` +} + +type GameTaskConfig struct { + GameType int `json:"game_type"` + LimitQueue []string `json:"limit_queue"` + LimitMode []string `json:"limit_mode"` + Target int `json:"target"` + TimeType int `json:"time_type"` + LimitUserType []string `json:"limit_user_type"` +} + +type GameTaskConfigParse struct { + Target string `json:"target"` +} + +type QQNetbarTask struct { + RuleDesc string `json:"rule_desc"` + TaskDesc string `json:"task_desc"` + LimitPrize int `json:"limit_prize"` + LimitNum int `json:"limit_num"` + PrizeList []Prize `json:"prize_list"` + TaskID string `json:"task_id"` + Title string `json:"title"` + CycleStart int64 `json:"cycle_start"` + CycleEnd int64 `json:"cycle_end"` + TargetName string `json:"target_name"` + TargetTimes int `json:"target_times"` + GameTaskConfig GameTaskConfig `json:"game_task_config"` + GameTaskConfigParse GameTaskConfigParse `json:"game_task_config_parse"` +} + +type QQNetbarTaskNoLoginResponse struct { + PageIdx string `json:"pageidx"` + TaskList []QQNetbarTask `json:"task_list"` +} + +type TaskParam struct { + NetbarAccount string `json:"netbar_account"` + PageIds string `json:"pageidx"` + Num int `json:"num"` + Gid int `json:"gid"` + BrandId string `json:"brand_id"` + Source string `json:"source"` +} + +type QQNetbarActivityIn struct { + ServiceName string // 服务名称 + TaskParam TaskParam +} diff --git a/internal/model/storeTaskReward.go b/internal/model/storeTaskReward.go new file mode 100644 index 0000000..eb69996 --- /dev/null +++ b/internal/model/storeTaskReward.go @@ -0,0 +1,40 @@ +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 int64 // 门店任务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 a447a19..6495dd1 100644 --- a/internal/model/task.go +++ b/internal/model/task.go @@ -5,7 +5,7 @@ import ( "github.com/gogf/gf/v2/os/gtime" ) -type Tasks struct { +type Task struct { Id int64 `json:"id" orm:"id" description:"任务唯一标识符"` // 任务唯一标识符 QqNetbarTaskId string `json:"qqNetbarTaskId" orm:"qq_netbar_task_id" description:"QQ网吧任务ID"` // QQ网吧任务ID CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间 @@ -18,6 +18,7 @@ type Tasks struct { StoreId int64 `json:"storeId" orm:"store_id" description:"门店 id"` // 门店 id Status int `json:"status" orm:"status" description:"状态"` // 状态 QQNetBarReward string `json:"qqNetbarReward" orm:"qq_netbar_reward" description:"qq网吧奖励名称"` // 任务奖励 + NetbarRewards []Reward `json:"netbarRewards" orm:"-"` } type GetNonLoginTaskListIn struct { diff --git a/internal/packed/packed.go b/internal/packed/packed.go index 84d479a..1426f0b 100644 --- a/internal/packed/packed.go +++ b/internal/packed/packed.go @@ -4,6 +4,7 @@ import ( _ "github.com/gogf/gf/contrib/drivers/mysql/v2" _ "github.com/gogf/gf/contrib/nosql/redis/v2" _ "server/utility/gamelife" + _ "server/utility/gametask" _ "server/utility/myCasbin" _ "server/utility/oss/aliyun" _ "server/utility/rsa" diff --git a/internal/service/store_task_reward.go b/internal/service/store_task_reward.go new file mode 100644 index 0000000..4224dee --- /dev/null +++ b/internal/service/store_task_reward.go @@ -0,0 +1,33 @@ +// ================================================================================ +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// You can delete these comments if you wish manually maintain this interface file. +// ================================================================================ + +package service + +import ( + "context" + "server/internal/model" +) + +type ( + IStoreTaskReward interface { + Create(ctx context.Context, in *model.StoreTaskRewardCreateIn) (out *model.StoreTaskRewardCreateOut, err error) + Delete(ctx context.Context, in *model.StoreTaskRewardDeleteIn) (out *model.StoreTaskRewardDeleteOut, err error) + } +) + +var ( + localStoreTaskReward IStoreTaskReward +) + +func StoreTaskReward() IStoreTaskReward { + if localStoreTaskReward == nil { + panic("implement not found for interface IStoreTaskReward, forgot register?") + } + return localStoreTaskReward +} + +func RegisterStoreTaskReward(i IStoreTaskReward) { + localStoreTaskReward = i +} diff --git a/manifest/config/config.yaml b/manifest/config/config.yaml index 6e0e827..1b57930 100644 --- a/manifest/config/config.yaml +++ b/manifest/config/config.yaml @@ -44,6 +44,7 @@ oss: gamelife: platId: "quanyou" + brandId: "b1749611654" secret: "LqPQ2gbF" mode: "test" rsaKey: "./manifest/config/全游-测试环境密钥.txt" diff --git a/utility/gamelife/gamelife.go b/utility/gamelife/gamelife.go index 50579d2..efb84f5 100644 --- a/utility/gamelife/gamelife.go +++ b/utility/gamelife/gamelife.go @@ -21,11 +21,14 @@ import ( type gamelifeClient struct { PlatId string `json:"platId" ` + BrandId string `json:"brand_id"` + Secret string `json:"secret"` Mode string `json:"mode" ` keyivUrlMap map[string]string `json:"-"` // 存储获取用户 aes key 和 iv 的 url boundUrlMap map[string]string `json:"-"` // 存储用户绑定状态的 url unBoundUrlMap map[string]string `json:"-"` // 存储用户解绑状态的 url getBoundUrl map[string]string `json:"-"` // 存储用户绑定状态的 url + taskUrlMap map[string]string `json:"-"` } var ( @@ -34,8 +37,10 @@ var ( func newgamelifeClient(ctx context.Context) *gamelifeClient { instance = &gamelifeClient{ - PlatId: g.Config().MustGet(ctx, "gamelife.platId").String(), - Mode: g.Config().MustGet(ctx, "gamelife.mode").String(), + PlatId: g.Config().MustGet(ctx, "gamelife.platId").String(), + BrandId: g.Config().MustGet(ctx, "gamelife.brandId").String(), + Secret: g.Config().MustGet(ctx, "gamelife.secret").String(), + Mode: g.Config().MustGet(ctx, "gamelife.mode").String(), keyivUrlMap: map[string]string{ "test": "https://api-test.nes.smoba.qq.com/pvpesport.sgamenes.commcgi.commcgi/GetExplatSecret", "prod": "https://api.nes.smoba.qq.com/pvpesport.sgamenes.commcgi.commcgi/GetExplatSecret", @@ -52,6 +57,10 @@ func newgamelifeClient(ctx context.Context) *gamelifeClient { "test": "https://api-test.cafe.qq.com/tipmp.user.authinfo_cgi.authinfo_cgi/GetPlatUserInfo", "prod": "https://api.cafe.qq.com/tipmp.user.authinfo_cgi.authinfo_cgi/GetPlatUserInfo", }, + taskUrlMap: map[string]string{ + "test": "https://api-test.cafe.qq.com/netbar.cafe.open_api.open_api/", + "prod": "https://api.cafe.qq.com/netbar.cafe.open_api.open_api/", + }, } glog.Infof(ctx, "初始化 gamelifeClient 成功") return instance @@ -299,3 +308,28 @@ func (s *gamelifeClient) GetBound(ctx context.Context, popenid string) (*model.U return &result, nil } + +func (s *gamelifeClient) RequestNetbarTaskByGameID(ctx context.Context, in *model.QQNetbarActivityIn) (out interface{}, err error) { + client := resty.New() + switch in.ServiceName { + case "GetNonloginTaskList": + result := model.QQNetbarTaskNoLoginResponse{} + in.TaskParam.Source = s.PlatId + in.TaskParam.BrandId = s.BrandId + resp, err := client.R(). + SetContext(ctx). + SetBody(in.TaskParam). + SetResult(&result). + Post(s.taskUrlMap[s.Mode] + "GetNonloginTaskList") + if err != nil { + err = ecode.Fail.Sub("请求出现异常") + return + } + + if resp.IsError() { + err = ecode.Fail.Sub("请求失败") + return + } + } + return +} diff --git a/utility/myCasbin/casbin.go b/utility/myCasbin/casbin.go index 92bb470..218086f 100644 --- a/utility/myCasbin/casbin.go +++ b/utility/myCasbin/casbin.go @@ -95,6 +95,9 @@ 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/store/role", "GET", "获取门店角色列表") enforcer.AddPolicy("store", "/x/store/role", "POST", "添加门店角色")