gamelife 自定义客户端集成游戏任务接口

This commit is contained in:
2025-06-18 20:36:04 +08:00
parent 1fd58c8966
commit 1395922d1a
34 changed files with 559 additions and 219 deletions

View File

@ -9,8 +9,7 @@ type ListReq struct {
Size int `json:"size" dc:"每页数量"` Size int `json:"size" dc:"每页数量"`
Status int `json:"status" dc:"状态"` Status int `json:"status" dc:"状态"`
StoreId int64 `json:"storeId" dc:"门店ID"` StoreId int64 `json:"storeId" dc:"门店ID"`
OperatorRole int `json:"operatorRole" dc:"操作者角色"` RewardTypeId int64 `json:"rewardTypeId" dc:"奖励类型ID"`
OperatorId int64 `json:"operatorId" dc:"操作者ID"`
} }
type ListRes struct { type ListRes struct {
@ -27,8 +26,6 @@ type CreateReq struct {
StoreId int64 `json:"storeId" dc:"门店ID"` StoreId int64 `json:"storeId" dc:"门店ID"`
RewardTypeId int64 `json:"rewardTypeId" v:"required#奖励类型ID不能为空" dc:"奖励类型ID"` RewardTypeId int64 `json:"rewardTypeId" v:"required#奖励类型ID不能为空" dc:"奖励类型ID"`
Source int `json:"source" v:"in:1,2#来源只能为1或2" dc:"来源"` 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 { type CreateRes struct {
@ -43,8 +40,6 @@ type UpdateReq struct {
Value int64 `json:"value" v:"required#数值不能为空" dc:"奖励值"` Value int64 `json:"value" v:"required#数值不能为空" dc:"奖励值"`
Status int `json:"status" dc:"状态" d:"1"` Status int `json:"status" dc:"状态" d:"1"`
StoreId int64 `json:"storeId" dc:"门店ID"` StoreId int64 `json:"storeId" dc:"门店ID"`
OperatorRole int `json:"operatorRole" dc:"操作者角色"`
OperatorId int64 `json:"operatorId" dc:"操作者ID"`
} }
type UpdateRes struct { type UpdateRes struct {
@ -54,8 +49,6 @@ type UpdateRes struct {
type DeleteReq struct { type DeleteReq struct {
g.Meta `path:"/reward/{id}" method:"delete" tags:"Reward" summary:"(系统、商户、门店后台)删除奖励"` g.Meta `path:"/reward/{id}" method:"delete" tags:"Reward" summary:"(系统、商户、门店后台)删除奖励"`
Id int64 `in:"path" json:"id" v:"required#ID不能为空" dc:"ID"` Id int64 `in:"path" json:"id" v:"required#ID不能为空" dc:"ID"`
OperatorRole int `json:"operatorRole" dc:"操作者角色"`
OperatorId int64 `json:"operatorId" dc:"操作者ID"`
} }
type DeleteRes struct { type DeleteRes struct {

View File

@ -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)
}

View File

@ -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:"是否成功"`
}

View File

@ -17,6 +17,7 @@ import (
"server/internal/controller/store" "server/internal/controller/store"
"server/internal/controller/storeAdmin" "server/internal/controller/storeAdmin"
"server/internal/controller/storeRole" "server/internal/controller/storeRole"
"server/internal/controller/storeTaskReward"
"server/internal/controller/task" "server/internal/controller/task"
"server/internal/controller/upload" "server/internal/controller/upload"
"server/internal/controller/user" "server/internal/controller/user"
@ -56,6 +57,7 @@ var (
game.NewV1(), game.NewV1(),
rewardType.NewV1(), rewardType.NewV1(),
reward.NewV1(), reward.NewV1(),
storeTaskReward.NewV1(),
) )
}) })
}) })

View File

@ -0,0 +1,5 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package storeTaskReward

View File

@ -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{}
}

View File

@ -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
}

View File

@ -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
}

View File

@ -16,7 +16,6 @@ type AdminsDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current 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. columns AdminsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
} }
// AdminsColumns defines and stores column names for the table admins. // 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. // NewAdminsDao creates and returns a new DAO object for table data access.
func NewAdminsDao(handlers ...gdb.ModelHandler) *AdminsDao { func NewAdminsDao() *AdminsDao {
return &AdminsDao{ return &AdminsDao{
group: "default", group: "default",
table: "admins", table: "admins",
columns: adminsColumns, columns: adminsColumns,
handlers: handlers,
} }
} }
@ -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. // 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 { func (dao *AdminsDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table) return dao.DB().Model(dao.table).Safe().Ctx(ctx)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -16,7 +16,6 @@ type FeedbacksDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current 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. columns FeedbacksColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
} }
// FeedbacksColumns defines and stores column names for the table feedbacks. // 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. // NewFeedbacksDao creates and returns a new DAO object for table data access.
func NewFeedbacksDao(handlers ...gdb.ModelHandler) *FeedbacksDao { func NewFeedbacksDao() *FeedbacksDao {
return &FeedbacksDao{ return &FeedbacksDao{
group: "default", group: "default",
table: "feedbacks", table: "feedbacks",
columns: feedbacksColumns, columns: feedbacksColumns,
handlers: handlers,
} }
} }
@ -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. // 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 { func (dao *FeedbacksDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table) return dao.DB().Model(dao.table).Safe().Ctx(ctx)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -16,7 +16,6 @@ type GamesDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current 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. columns GamesColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
} }
// GamesColumns defines and stores column names for the table games. // 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. // NewGamesDao creates and returns a new DAO object for table data access.
func NewGamesDao(handlers ...gdb.ModelHandler) *GamesDao { func NewGamesDao() *GamesDao {
return &GamesDao{ return &GamesDao{
group: "default", group: "default",
table: "games", table: "games",
columns: gamesColumns, columns: gamesColumns,
handlers: handlers,
} }
} }
@ -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. // 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 { func (dao *GamesDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table) return dao.DB().Model(dao.table).Safe().Ctx(ctx)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -16,7 +16,6 @@ type MerchantAdminsDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current 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. columns MerchantAdminsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
} }
// MerchantAdminsColumns defines and stores column names for the table merchant_admins. // 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. // NewMerchantAdminsDao creates and returns a new DAO object for table data access.
func NewMerchantAdminsDao(handlers ...gdb.ModelHandler) *MerchantAdminsDao { func NewMerchantAdminsDao() *MerchantAdminsDao {
return &MerchantAdminsDao{ return &MerchantAdminsDao{
group: "default", group: "default",
table: "merchant_admins", table: "merchant_admins",
columns: merchantAdminsColumns, columns: merchantAdminsColumns,
handlers: handlers,
} }
} }
@ -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. // 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 { func (dao *MerchantAdminsDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table) return dao.DB().Model(dao.table).Safe().Ctx(ctx)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -16,7 +16,6 @@ type MerchantsDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current 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. columns MerchantsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
} }
// MerchantsColumns defines and stores column names for the table merchants. // 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. // NewMerchantsDao creates and returns a new DAO object for table data access.
func NewMerchantsDao(handlers ...gdb.ModelHandler) *MerchantsDao { func NewMerchantsDao() *MerchantsDao {
return &MerchantsDao{ return &MerchantsDao{
group: "default", group: "default",
table: "merchants", table: "merchants",
columns: merchantsColumns, columns: merchantsColumns,
handlers: handlers,
} }
} }
@ -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. // 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 { func (dao *MerchantsDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table) return dao.DB().Model(dao.table).Safe().Ctx(ctx)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -16,7 +16,6 @@ type RewardTypesDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current 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. columns RewardTypesColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
} }
// RewardTypesColumns defines and stores column names for the table reward_types. // 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. // NewRewardTypesDao creates and returns a new DAO object for table data access.
func NewRewardTypesDao(handlers ...gdb.ModelHandler) *RewardTypesDao { func NewRewardTypesDao() *RewardTypesDao {
return &RewardTypesDao{ return &RewardTypesDao{
group: "default", group: "default",
table: "reward_types", table: "reward_types",
columns: rewardTypesColumns, columns: rewardTypesColumns,
handlers: handlers,
} }
} }
@ -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. // 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 { func (dao *RewardTypesDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table) return dao.DB().Model(dao.table).Safe().Ctx(ctx)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -16,7 +16,6 @@ type RolesDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current 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. columns RolesColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
} }
// RolesColumns defines and stores column names for the table roles. // 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. // NewRolesDao creates and returns a new DAO object for table data access.
func NewRolesDao(handlers ...gdb.ModelHandler) *RolesDao { func NewRolesDao() *RolesDao {
return &RolesDao{ return &RolesDao{
group: "default", group: "default",
table: "roles", table: "roles",
columns: rolesColumns, columns: rolesColumns,
handlers: handlers,
} }
} }
@ -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. // 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 { func (dao *RolesDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table) return dao.DB().Model(dao.table).Safe().Ctx(ctx)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -16,7 +16,6 @@ type StoreAdminsDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current 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. columns StoreAdminsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
} }
// StoreAdminsColumns defines and stores column names for the table store_admins. // 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. // NewStoreAdminsDao creates and returns a new DAO object for table data access.
func NewStoreAdminsDao(handlers ...gdb.ModelHandler) *StoreAdminsDao { func NewStoreAdminsDao() *StoreAdminsDao {
return &StoreAdminsDao{ return &StoreAdminsDao{
group: "default", group: "default",
table: "store_admins", table: "store_admins",
columns: storeAdminsColumns, columns: storeAdminsColumns,
handlers: handlers,
} }
} }
@ -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. // 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 { func (dao *StoreAdminsDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table) return dao.DB().Model(dao.table).Safe().Ctx(ctx)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -16,7 +16,6 @@ type StoreDesktopSettingsDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current 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. columns StoreDesktopSettingsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
} }
// StoreDesktopSettingsColumns defines and stores column names for the table store_desktop_settings. // 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. // NewStoreDesktopSettingsDao creates and returns a new DAO object for table data access.
func NewStoreDesktopSettingsDao(handlers ...gdb.ModelHandler) *StoreDesktopSettingsDao { func NewStoreDesktopSettingsDao() *StoreDesktopSettingsDao {
return &StoreDesktopSettingsDao{ return &StoreDesktopSettingsDao{
group: "default", group: "default",
table: "store_desktop_settings", table: "store_desktop_settings",
columns: storeDesktopSettingsColumns, columns: storeDesktopSettingsColumns,
handlers: handlers,
} }
} }
@ -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. // 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 { func (dao *StoreDesktopSettingsDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table) return dao.DB().Model(dao.table).Safe().Ctx(ctx)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -16,7 +16,6 @@ type StoreRolesDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current 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. columns StoreRolesColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
} }
// StoreRolesColumns defines and stores column names for the table store_roles. // 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. // NewStoreRolesDao creates and returns a new DAO object for table data access.
func NewStoreRolesDao(handlers ...gdb.ModelHandler) *StoreRolesDao { func NewStoreRolesDao() *StoreRolesDao {
return &StoreRolesDao{ return &StoreRolesDao{
group: "default", group: "default",
table: "store_roles", table: "store_roles",
columns: storeRolesColumns, columns: storeRolesColumns,
handlers: handlers,
} }
} }
@ -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. // 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 { func (dao *StoreRolesDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table) return dao.DB().Model(dao.table).Safe().Ctx(ctx)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -16,7 +16,6 @@ type StoresDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current 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. columns StoresColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
} }
// StoresColumns defines and stores column names for the table stores. // 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. // NewStoresDao creates and returns a new DAO object for table data access.
func NewStoresDao(handlers ...gdb.ModelHandler) *StoresDao { func NewStoresDao() *StoresDao {
return &StoresDao{ return &StoresDao{
group: "default", group: "default",
table: "stores", table: "stores",
columns: storesColumns, columns: storesColumns,
handlers: handlers,
} }
} }
@ -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. // 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 { func (dao *StoresDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table) return dao.DB().Model(dao.table).Safe().Ctx(ctx)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -16,7 +16,6 @@ type TasksDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current 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. columns TasksColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
} }
// TasksColumns defines and stores column names for the table tasks. // 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. // NewTasksDao creates and returns a new DAO object for table data access.
func NewTasksDao(handlers ...gdb.ModelHandler) *TasksDao { func NewTasksDao() *TasksDao {
return &TasksDao{ return &TasksDao{
group: "default", group: "default",
table: "tasks", table: "tasks",
columns: tasksColumns, columns: tasksColumns,
handlers: handlers,
} }
} }
@ -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. // 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 { func (dao *TasksDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table) return dao.DB().Model(dao.table).Safe().Ctx(ctx)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -16,7 +16,6 @@ type UserTasksDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current 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. columns UserTasksColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
} }
// UserTasksColumns defines and stores column names for the table user_tasks. // 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. // NewUserTasksDao creates and returns a new DAO object for table data access.
func NewUserTasksDao(handlers ...gdb.ModelHandler) *UserTasksDao { func NewUserTasksDao() *UserTasksDao {
return &UserTasksDao{ return &UserTasksDao{
group: "default", group: "default",
table: "user_tasks", table: "user_tasks",
columns: userTasksColumns, columns: userTasksColumns,
handlers: handlers,
} }
} }
@ -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. // 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 { func (dao *UserTasksDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table) return dao.DB().Model(dao.table).Safe().Ctx(ctx)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -16,7 +16,6 @@ type UsersDao struct {
table string // table is the underlying table name of the DAO. table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current 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. columns UsersColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
} }
// UsersColumns defines and stores column names for the table users. // 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. // NewUsersDao creates and returns a new DAO object for table data access.
func NewUsersDao(handlers ...gdb.ModelHandler) *UsersDao { func NewUsersDao() *UsersDao {
return &UsersDao{ return &UsersDao{
group: "default", group: "default",
table: "users", table: "users",
columns: usersColumns, columns: usersColumns,
handlers: handlers,
} }
} }
@ -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. // 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 { func (dao *UsersDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table) return dao.DB().Model(dao.table).Safe().Ctx(ctx)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -16,6 +16,7 @@ import (
_ "server/internal/logic/store" _ "server/internal/logic/store"
_ "server/internal/logic/storeAdmin" _ "server/internal/logic/storeAdmin"
_ "server/internal/logic/storeRole" _ "server/internal/logic/storeRole"
_ "server/internal/logic/storeTaskReward"
_ "server/internal/logic/task" _ "server/internal/logic/task"
_ "server/internal/logic/upload" _ "server/internal/logic/upload"
_ "server/internal/logic/user" _ "server/internal/logic/user"

View File

@ -293,6 +293,9 @@ func (s *sReward) List(ctx context.Context, in *model.RewardListIn) (out *model.
if in.Name != "" { if in.Name != "" {
orm = orm.WhereLike(dao.Rewards.Columns().Name, "%"+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() total, err := orm.Count()
if err != nil { if err != nil {

View File

@ -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
}

View File

@ -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) { 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 var total int
m := dao.Tasks.Ctx(ctx) 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}) 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 { if err != nil {
return nil, ecode.Fail.Sub("任务列表获取失败") 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{ return &model.TaskListOut{
List: data, List: data,
Total: total, Total: total,

View File

@ -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
}

View File

@ -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 // 是否删除成功
}

View File

@ -5,7 +5,7 @@ import (
"github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/os/gtime"
) )
type Tasks struct { type Task struct {
Id int64 `json:"id" orm:"id" description:"任务唯一标识符"` // 任务唯一标识符 Id int64 `json:"id" orm:"id" description:"任务唯一标识符"` // 任务唯一标识符
QqNetbarTaskId string `json:"qqNetbarTaskId" orm:"qq_netbar_task_id" description:"QQ网吧任务ID"` // QQ网吧任务ID QqNetbarTaskId string `json:"qqNetbarTaskId" orm:"qq_netbar_task_id" description:"QQ网吧任务ID"` // QQ网吧任务ID
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间 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 StoreId int64 `json:"storeId" orm:"store_id" description:"门店 id"` // 门店 id
Status int `json:"status" orm:"status" description:"状态"` // 状态 Status int `json:"status" orm:"status" description:"状态"` // 状态
QQNetBarReward string `json:"qqNetbarReward" orm:"qq_netbar_reward" description:"qq网吧奖励名称"` // 任务奖励 QQNetBarReward string `json:"qqNetbarReward" orm:"qq_netbar_reward" description:"qq网吧奖励名称"` // 任务奖励
NetbarRewards []Reward `json:"netbarRewards" orm:"-"`
} }
type GetNonLoginTaskListIn struct { type GetNonLoginTaskListIn struct {

View File

@ -4,6 +4,7 @@ import (
_ "github.com/gogf/gf/contrib/drivers/mysql/v2" _ "github.com/gogf/gf/contrib/drivers/mysql/v2"
_ "github.com/gogf/gf/contrib/nosql/redis/v2" _ "github.com/gogf/gf/contrib/nosql/redis/v2"
_ "server/utility/gamelife" _ "server/utility/gamelife"
_ "server/utility/gametask"
_ "server/utility/myCasbin" _ "server/utility/myCasbin"
_ "server/utility/oss/aliyun" _ "server/utility/oss/aliyun"
_ "server/utility/rsa" _ "server/utility/rsa"

View File

@ -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
}

View File

@ -44,6 +44,7 @@ oss:
gamelife: gamelife:
platId: "quanyou" platId: "quanyou"
brandId: "b1749611654"
secret: "LqPQ2gbF" secret: "LqPQ2gbF"
mode: "test" mode: "test"
rsaKey: "./manifest/config/全游-测试环境密钥.txt" rsaKey: "./manifest/config/全游-测试环境密钥.txt"

View File

@ -21,11 +21,14 @@ import (
type gamelifeClient struct { type gamelifeClient struct {
PlatId string `json:"platId" ` PlatId string `json:"platId" `
BrandId string `json:"brand_id"`
Secret string `json:"secret"`
Mode string `json:"mode" ` Mode string `json:"mode" `
keyivUrlMap map[string]string `json:"-"` // 存储获取用户 aes key 和 iv 的 url keyivUrlMap map[string]string `json:"-"` // 存储获取用户 aes key 和 iv 的 url
boundUrlMap map[string]string `json:"-"` // 存储用户绑定状态的 url boundUrlMap map[string]string `json:"-"` // 存储用户绑定状态的 url
unBoundUrlMap map[string]string `json:"-"` // 存储用户解绑状态的 url unBoundUrlMap map[string]string `json:"-"` // 存储用户解绑状态的 url
getBoundUrl map[string]string `json:"-"` // 存储用户绑定状态的 url getBoundUrl map[string]string `json:"-"` // 存储用户绑定状态的 url
taskUrlMap map[string]string `json:"-"`
} }
var ( var (
@ -35,6 +38,8 @@ var (
func newgamelifeClient(ctx context.Context) *gamelifeClient { func newgamelifeClient(ctx context.Context) *gamelifeClient {
instance = &gamelifeClient{ instance = &gamelifeClient{
PlatId: g.Config().MustGet(ctx, "gamelife.platId").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(), Mode: g.Config().MustGet(ctx, "gamelife.mode").String(),
keyivUrlMap: map[string]string{ keyivUrlMap: map[string]string{
"test": "https://api-test.nes.smoba.qq.com/pvpesport.sgamenes.commcgi.commcgi/GetExplatSecret", "test": "https://api-test.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", "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", "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 成功") glog.Infof(ctx, "初始化 gamelifeClient 成功")
return instance return instance
@ -299,3 +308,28 @@ func (s *gamelifeClient) GetBound(ctx context.Context, popenid string) (*model.U
return &result, nil 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
}

View File

@ -95,6 +95,9 @@ func init() {
enforcer.AddPolicy("store", "/x/reward", "PUT", "更新奖励") enforcer.AddPolicy("store", "/x/reward", "PUT", "更新奖励")
enforcer.AddPolicy("store", "/x/reward/*", "DELETE", "删除奖励") 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", "GET", "获取门店角色列表")
enforcer.AddPolicy("store", "/x/store/role", "POST", "添加门店角色") enforcer.AddPolicy("store", "/x/store/role", "POST", "添加门店角色")