修改任务列表查询

This commit is contained in:
chy
2025-06-18 21:34:53 +08:00
parent 87d19b5fe2
commit 3c18686bf9
26 changed files with 316 additions and 344 deletions

View File

@ -23,8 +23,8 @@ type NonLoginTaskListReq struct {
Gid int `json:"gid" v:"required#游戏唯一id不能为空" dc:"游戏唯一id"` Gid int `json:"gid" v:"required#游戏唯一id不能为空" dc:"游戏唯一id"`
Num int `json:"num" v:"required#不能为空" dc:""` Num int `json:"num" v:"required#不能为空" dc:""`
Pageidx string `json:"pageidx" dc:"分页索引"` Pageidx string `json:"pageidx" dc:"分页索引"`
Source string `json:"source" v:"required#不能为空" dc:""` //Source string `json:"source" v:"required#不能为空" dc:""`
BrandId string `json:"brandId" dc:"品牌id(可选)"` //BrandId string `json:"brandId" dc:"品牌id(可选)"`
} }
type NonLoginTaskListRes struct { type NonLoginTaskListRes struct {

View File

@ -8,3 +8,8 @@ const (
GamelifeExtplatBoundTypeWX = "wx" GamelifeExtplatBoundTypeWX = "wx"
GamelifeMiniProgramBand = "1" GamelifeMiniProgramBand = "1"
) )
const (
GetNonLoginTaskList = "GetNonloginTaskList"
GetTaskList = "GetTaskList"
)

View File

@ -1,6 +0,0 @@
package consts
const (
TestAddr = "https://api-test.cafe.qq.com/netbar.cafe.open_api.open_api/"
ProAddr = "https://api.cafe.qq.com/netbar.cafe.open_api.open_api/"
)

View File

@ -17,8 +17,8 @@ func (c *ControllerV1) NonLoginTaskList(ctx context.Context, req *v1.NonLoginTas
Num: req.Num, Num: req.Num,
Pageidx: req.Pageidx, Pageidx: req.Pageidx,
Gid: req.Gid, Gid: req.Gid,
Source: req.Source, //Source: req.Source,
BrandId: req.BrandId, //BrandId: req.BrandId,
}) })
if err != nil { if err != nil {

View File

@ -13,9 +13,10 @@ import (
// AdminsDao is the data access object for the table admins. // AdminsDao is the data access object for the table admins.
type AdminsDao struct { 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.
@ -49,11 +50,12 @@ 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() *AdminsDao { func NewAdminsDao(handlers ...gdb.ModelHandler) *AdminsDao {
return &AdminsDao{ return &AdminsDao{
group: "default", group: "default",
table: "admins", table: "admins",
columns: adminsColumns, columns: adminsColumns,
handlers: handlers,
} }
} }
@ -79,7 +81,11 @@ 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 {
return dao.DB().Model(dao.table).Safe().Ctx(ctx) model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// FeedbacksDao is the data access object for the table feedbacks. // FeedbacksDao is the data access object for the table feedbacks.
type FeedbacksDao struct { 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.
@ -51,11 +52,12 @@ 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() *FeedbacksDao { func NewFeedbacksDao(handlers ...gdb.ModelHandler) *FeedbacksDao {
return &FeedbacksDao{ return &FeedbacksDao{
group: "default", group: "default",
table: "feedbacks", table: "feedbacks",
columns: feedbacksColumns, columns: feedbacksColumns,
handlers: handlers,
} }
} }
@ -81,7 +83,11 @@ 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 {
return dao.DB().Model(dao.table).Safe().Ctx(ctx) model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// GamesDao is the data access object for the table games. // GamesDao is the data access object for the table games.
type GamesDao struct { 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.
@ -45,11 +46,12 @@ 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() *GamesDao { func NewGamesDao(handlers ...gdb.ModelHandler) *GamesDao {
return &GamesDao{ return &GamesDao{
group: "default", group: "default",
table: "games", table: "games",
columns: gamesColumns, columns: gamesColumns,
handlers: handlers,
} }
} }
@ -75,7 +77,11 @@ 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 {
return dao.DB().Model(dao.table).Safe().Ctx(ctx) model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// MerchantAdminsDao is the data access object for the table merchant_admins. // MerchantAdminsDao is the data access object for the table merchant_admins.
type MerchantAdminsDao struct { 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.
@ -57,11 +58,12 @@ 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() *MerchantAdminsDao { func NewMerchantAdminsDao(handlers ...gdb.ModelHandler) *MerchantAdminsDao {
return &MerchantAdminsDao{ return &MerchantAdminsDao{
group: "default", group: "default",
table: "merchant_admins", table: "merchant_admins",
columns: merchantAdminsColumns, columns: merchantAdminsColumns,
handlers: handlers,
} }
} }
@ -87,7 +89,11 @@ 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 {
return dao.DB().Model(dao.table).Safe().Ctx(ctx) model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// MerchantsDao is the data access object for the table merchants. // MerchantsDao is the data access object for the table merchants.
type MerchantsDao struct { 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.
@ -71,11 +72,12 @@ 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() *MerchantsDao { func NewMerchantsDao(handlers ...gdb.ModelHandler) *MerchantsDao {
return &MerchantsDao{ return &MerchantsDao{
group: "default", group: "default",
table: "merchants", table: "merchants",
columns: merchantsColumns, columns: merchantsColumns,
handlers: handlers,
} }
} }
@ -101,7 +103,11 @@ 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 {
return dao.DB().Model(dao.table).Safe().Ctx(ctx) model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// RewardTypesDao is the data access object for the table reward_types. // RewardTypesDao is the data access object for the table reward_types.
type RewardTypesDao struct { 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.
@ -45,11 +46,12 @@ 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() *RewardTypesDao { func NewRewardTypesDao(handlers ...gdb.ModelHandler) *RewardTypesDao {
return &RewardTypesDao{ return &RewardTypesDao{
group: "default", group: "default",
table: "reward_types", table: "reward_types",
columns: rewardTypesColumns, columns: rewardTypesColumns,
handlers: handlers,
} }
} }
@ -75,7 +77,11 @@ 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 {
return dao.DB().Model(dao.table).Safe().Ctx(ctx) model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// RolesDao is the data access object for the table roles. // RolesDao is the data access object for the table roles.
type RolesDao struct { 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.
@ -47,11 +48,12 @@ 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() *RolesDao { func NewRolesDao(handlers ...gdb.ModelHandler) *RolesDao {
return &RolesDao{ return &RolesDao{
group: "default", group: "default",
table: "roles", table: "roles",
columns: rolesColumns, columns: rolesColumns,
handlers: handlers,
} }
} }
@ -77,7 +79,11 @@ 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 {
return dao.DB().Model(dao.table).Safe().Ctx(ctx) model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// StoreAdminsDao is the data access object for the table store_admins. // StoreAdminsDao is the data access object for the table store_admins.
type StoreAdminsDao struct { 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.
@ -57,11 +58,12 @@ 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() *StoreAdminsDao { func NewStoreAdminsDao(handlers ...gdb.ModelHandler) *StoreAdminsDao {
return &StoreAdminsDao{ return &StoreAdminsDao{
group: "default", group: "default",
table: "store_admins", table: "store_admins",
columns: storeAdminsColumns, columns: storeAdminsColumns,
handlers: handlers,
} }
} }
@ -87,7 +89,11 @@ 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 {
return dao.DB().Model(dao.table).Safe().Ctx(ctx) model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// StoreDesktopSettingsDao is the data access object for the table store_desktop_settings. // StoreDesktopSettingsDao is the data access object for the table store_desktop_settings.
type StoreDesktopSettingsDao struct { 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.
@ -45,11 +46,12 @@ 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() *StoreDesktopSettingsDao { func NewStoreDesktopSettingsDao(handlers ...gdb.ModelHandler) *StoreDesktopSettingsDao {
return &StoreDesktopSettingsDao{ return &StoreDesktopSettingsDao{
group: "default", group: "default",
table: "store_desktop_settings", table: "store_desktop_settings",
columns: storeDesktopSettingsColumns, columns: storeDesktopSettingsColumns,
handlers: handlers,
} }
} }
@ -75,7 +77,11 @@ 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 {
return dao.DB().Model(dao.table).Safe().Ctx(ctx) model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// StoreRolesDao is the data access object for the table store_roles. // StoreRolesDao is the data access object for the table store_roles.
type StoreRolesDao struct { 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.
@ -39,11 +40,12 @@ 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() *StoreRolesDao { func NewStoreRolesDao(handlers ...gdb.ModelHandler) *StoreRolesDao {
return &StoreRolesDao{ return &StoreRolesDao{
group: "default", group: "default",
table: "store_roles", table: "store_roles",
columns: storeRolesColumns, columns: storeRolesColumns,
handlers: handlers,
} }
} }
@ -69,7 +71,11 @@ 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 {
return dao.DB().Model(dao.table).Safe().Ctx(ctx) model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// StoresDao is the data access object for the table stores. // StoresDao is the data access object for the table stores.
type StoresDao struct { 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.
@ -51,11 +52,12 @@ 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() *StoresDao { func NewStoresDao(handlers ...gdb.ModelHandler) *StoresDao {
return &StoresDao{ return &StoresDao{
group: "default", group: "default",
table: "stores", table: "stores",
columns: storesColumns, columns: storesColumns,
handlers: handlers,
} }
} }
@ -81,7 +83,11 @@ 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 {
return dao.DB().Model(dao.table).Safe().Ctx(ctx) model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -13,49 +13,57 @@ import (
// TasksDao is the data access object for the table tasks. // TasksDao is the data access object for the table tasks.
type TasksDao struct { 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.
type TasksColumns struct { type TasksColumns struct {
Id string // 任务唯一标识符 Id string // 任务唯一标识符
QqNetbarTaskId string // QQ网吧任务ID CreatedAt string // 创建时间
CreatedAt string // 创建时间 UpdatedAt string // 更新时间
UpdatedAt string // 更新时间 DeletedAt string // 软删除时间
DeletedAt string // 软删除时间戳 GameId string // 游戏唯一id
QqNetbarTaskName string // QQ网吧任务名称 StoreId string // 门店 id
QqNetbarTaskMemo string // 任务描述 Status string // 1启用 2禁用
QqNetbarTaskRules string // 任务规则 QqNetbarTaskId string // QQ网吧任务ID
GameId string // 游戏唯一id QqNetbarTaskRules string // 任务规则
StoreId string // 门店 id QqNetbarTaskMemo string // 任务描述
QqNetbarReward string // QqNetbarTaskName string // QQ网吧任务名称
Status string // 1启用 2禁用 QqNetbarReward string // qq 网吧奖励名称
QqNetbarTargetTime string // qq 网吧任务指标
StartTime string // 任务开始时间
EndTime string // 任务结束时间
} }
// tasksColumns holds the columns for the table tasks. // tasksColumns holds the columns for the table tasks.
var tasksColumns = TasksColumns{ var tasksColumns = TasksColumns{
Id: "id", Id: "id",
QqNetbarTaskId: "qq_netbar_task_id", CreatedAt: "created_at",
CreatedAt: "created_at", UpdatedAt: "updated_at",
UpdatedAt: "updated_at", DeletedAt: "deleted_at",
DeletedAt: "deleted_at", GameId: "game_id",
QqNetbarTaskName: "qq_netbar_task_name", StoreId: "store_id",
QqNetbarTaskMemo: "qq_netbar_task_memo", Status: "status",
QqNetbarTaskRules: "qq_netbar_task_rules", QqNetbarTaskId: "qq_netbar_task_id",
GameId: "game_id", QqNetbarTaskRules: "qq_netbar_task_rules",
StoreId: "store_id", QqNetbarTaskMemo: "qq_netbar_task_memo",
QqNetbarReward: "qq_netbar_reward", QqNetbarTaskName: "qq_netbar_task_name",
Status: "status", QqNetbarReward: "qq_netbar_reward",
QqNetbarTargetTime: "qq_netbar_target_time",
StartTime: "start_time",
EndTime: "end_time",
} }
// 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() *TasksDao { func NewTasksDao(handlers ...gdb.ModelHandler) *TasksDao {
return &TasksDao{ return &TasksDao{
group: "default", group: "default",
table: "tasks", table: "tasks",
columns: tasksColumns, columns: tasksColumns,
handlers: handlers,
} }
} }
@ -81,7 +89,11 @@ 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 {
return dao.DB().Model(dao.table).Safe().Ctx(ctx) model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// UserTasksDao is the data access object for the table user_tasks. // UserTasksDao is the data access object for the table user_tasks.
type UserTasksDao struct { 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.
@ -47,11 +48,12 @@ 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() *UserTasksDao { func NewUserTasksDao(handlers ...gdb.ModelHandler) *UserTasksDao {
return &UserTasksDao{ return &UserTasksDao{
group: "default", group: "default",
table: "user_tasks", table: "user_tasks",
columns: userTasksColumns, columns: userTasksColumns,
handlers: handlers,
} }
} }
@ -77,7 +79,11 @@ 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 {
return dao.DB().Model(dao.table).Safe().Ctx(ctx) model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -13,9 +13,10 @@ import (
// UsersDao is the data access object for the table users. // UsersDao is the data access object for the table users.
type UsersDao struct { 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.
@ -59,11 +60,12 @@ 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() *UsersDao { func NewUsersDao(handlers ...gdb.ModelHandler) *UsersDao {
return &UsersDao{ return &UsersDao{
group: "default", group: "default",
table: "users", table: "users",
columns: usersColumns, columns: usersColumns,
handlers: handlers,
} }
} }
@ -89,7 +91,11 @@ 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 {
return dao.DB().Model(dao.table).Safe().Ctx(ctx) model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
} }
// Transaction wraps the transaction logic using function f. // Transaction wraps the transaction logic using function f.

View File

@ -2,15 +2,15 @@ package task
import ( import (
"context" "context"
"encoding/json"
"fmt" "fmt"
"server/internal/consts"
"server/internal/dao" "server/internal/dao"
"server/internal/model" "server/internal/model"
"server/internal/model/do" "server/internal/model/do"
"server/internal/service" "server/internal/service"
"server/utility/ecode" "server/utility/ecode"
"server/utility/gamelife"
"server/utility/snowid" "server/utility/snowid"
"server/utility/tencent"
"sort" "sort"
"strconv" "strconv"
"strings" "strings"
@ -147,85 +147,50 @@ func (s *sTask) UserTaskRankingList(ctx context.Context, in *model.UserTaskRanki
func (s *sTask) GetNonLoginTaskList(ctx context.Context, in *model.GetNonLoginTaskListIn) (out *model.GetNonLoginTaskListOut, err error) { func (s *sTask) GetNonLoginTaskList(ctx context.Context, in *model.GetNonLoginTaskListIn) (out *model.GetNonLoginTaskListOut, err error) {
// 调用外部接口 // 调用外部接口
data, err := tencent.GetNonLoginTaskList(ctx, in) activity, err := gamelife.GetGamelifeClient(ctx).RequestActivity(ctx, &model.QQNetbarActivityIn{ServiceName: consts.GetNonLoginTaskList, TaskParam: model.TaskParam{Gid: in.Gid, NetBarAccount: in.NetBarAccount, Num: in.Num, Pageidx: in.Pageidx}})
if err != nil { if err != nil {
return nil, err return nil, err
} }
result, ok := activity.(*model.GameTaskResponse)
var store *model.Store if !ok {
// 获取网吧账号 id用作存储task return nil, ecode.Fail.Sub("数据类型转换失败")
err = dao.Stores.Ctx(ctx).Where(dao.Stores.Columns().NetbarAccount, in.NetBarAccount).Scan(&store)
if err != nil {
return nil, ecode.Fail.Sub("查找网吧失败")
}
if store == nil {
return nil, ecode.Fail.Sub("当前网吧不存在")
} }
// 剔除不需要的任务数据
var tasks []model.Task
for _, task := range result.TaskList {
data := model.Task{
QqNetbarTaskId: task.TaskID,
QqNetbarTaskName: task.Title,
QqNetbarTaskMemo: task.TaskDesc,
QqNetbarTaskRules: task.RuleDesc,
QqNetbarReward: task.TargetName,
QqNetbarTargetTime: task.TargetTimes,
StartTime: task.CycleStart,
EndTime: task.CycleEnd,
}
// 任务列表数据处理 // 组装门店奖励数据
if jsonData, ok := data.(map[string]interface{}); ok { err := dao.Tasks.Ctx(ctx).InnerJoin(dao.StoreTaskRewards.Table(), fmt.Sprintf("%s.%s = %s.%s", dao.Tasks.Table(), dao.Tasks.Columns().Id, dao.StoreTaskRewards.Table(), dao.StoreTaskRewards.Columns().TaskId)).
// 现在可以访问 jsonData 中的字段 InnerJoin(dao.Rewards.Table(), fmt.Sprintf("%s.%s = %s.%s", dao.StoreTaskRewards.Table(), dao.StoreTaskRewards.Columns().RewardId, dao.Rewards.Table(), dao.Rewards.Columns().Id)).
list := jsonData["task_list"] Where(dao.Tasks.Columns().QqNetbarTaskId, task.TaskID).Fields(fmt.Sprintf("%s.*", dao.Rewards.Table())).Scan(&data.NetbarRewards)
// 将 interface{} 转换为结构体
var result []model.MyData
jsonBytes, err := json.Marshal(list)
if err != nil { if err != nil {
return nil, ecode.Fail.Sub("JSON序列化失败") return nil, err
}
err = json.Unmarshal(jsonBytes, &result)
if err != nil {
return nil, ecode.Fail.Sub("JSON反序列化失败")
}
for _, v := range result {
exist, err := dao.Tasks.Ctx(ctx).Where(dao.Tasks.Columns().QqNetbarTaskId, v.TaskId).Exist()
if err != nil {
return nil, ecode.Fail.Sub("查询该任务失败")
}
str := ""
for i, vv := range v.PrizeList {
str += vv.PrizeName
if i+1 != len(v.PrizeList) {
str += ","
}
}
// 数据库是否存在,无则添加
if !exist {
_, err := dao.Tasks.Ctx(ctx).Insert(do.Tasks{
QqNetbarTaskId: v.TaskId,
QqNetbarTaskMemo: v.QQNetBarTaskMemo,
QqNetbarTaskName: v.QQNetBarTaskName,
QqNetbarTaskRules: v.QQNetBarTaskRules,
GameId: in.Gid,
StoreId: store.Id,
QqNetbarReward: str,
})
if err != nil {
return nil, ecode.Fail.Sub("添加任务失败")
}
}
} }
tasks = append(tasks, data)
} }
return &model.GetNonLoginTaskListOut{ return &model.GetNonLoginTaskListOut{
Data: data, Data: tasks,
}, err }, err
} }
func (s *sTask) GetLoginTaskList(ctx context.Context, in *model.GetLoginTaskListIn) (out *model.GetLoginTaskListOut, err error) { func (s *sTask) GetLoginTaskList(ctx context.Context, in *model.GetLoginTaskListIn) (out *model.GetLoginTaskListOut, err error) {
// 调用外部接口 // 调用外部接口
data, err := tencent.GetLoginTaskList(ctx, in)
if err != nil {
return nil, err
}
// 任务列表数据处理 // 任务列表数据处理
return &model.GetLoginTaskListOut{ return &model.GetLoginTaskListOut{
Data: data, Data: nil,
}, err }, err
} }

View File

@ -11,17 +11,20 @@ import (
// Tasks is the golang structure of table tasks for DAO operations like Where/Data. // Tasks is the golang structure of table tasks for DAO operations like Where/Data.
type Tasks struct { type Tasks struct {
g.Meta `orm:"table:tasks, do:true"` g.Meta `orm:"table:tasks, do:true"`
Id interface{} // 任务唯一标识符 Id interface{} // 任务唯一标识符
QqNetbarTaskId interface{} // QQ网吧任务ID CreatedAt *gtime.Time // 创建时间
CreatedAt *gtime.Time // 创建时间 UpdatedAt *gtime.Time // 更新时间
UpdatedAt *gtime.Time // 更新时间 DeletedAt *gtime.Time // 软删除时间
DeletedAt *gtime.Time // 软删除时间戳 GameId interface{} // 游戏唯一id
QqNetbarTaskName interface{} // QQ网吧任务名称 StoreId interface{} // 门店 id
QqNetbarTaskMemo interface{} // 任务描述 Status interface{} // 1启用 2禁用
QqNetbarTaskRules interface{} // 任务规则 QqNetbarTaskId interface{} // QQ网吧任务ID
GameId interface{} // 游戏唯一id QqNetbarTaskRules interface{} // 任务规则
StoreId interface{} // 门店 id QqNetbarTaskMemo interface{} // 任务描述
QqNetbarReward interface{} // QqNetbarTaskName interface{} // QQ网吧任务名称
Status interface{} // 1启用 2禁用 QqNetbarReward interface{} // qq 网吧奖励名称
QqNetbarTargetTime interface{} // qq 网吧任务指标
StartTime interface{} // 任务开始时间
EndTime interface{} // 任务结束时间
} }

View File

@ -10,16 +10,19 @@ import (
// Tasks is the golang structure for table tasks. // Tasks is the golang structure for table tasks.
type Tasks struct { type Tasks 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 CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间 UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间 DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间"` // 软删除时间
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间戳"` // 软删除时间戳 GameId int64 `json:"gameId" orm:"game_id" description:"游戏唯一id"` // 游戏唯一id
QqNetbarTaskName string `json:"qqNetbarTaskName" orm:"qq_netbar_task_name" description:"QQ网吧任务名称"` // QQ网吧任务名称 StoreId int64 `json:"storeId" orm:"store_id" description:"门店 id"` // 门店 id
QqNetbarTaskMemo string `json:"qqNetbarTaskMemo" orm:"qq_netbar_task_memo" description:"任务描述"` // 任务描述 Status int `json:"status" orm:"status" description:"1启用 2禁用"` // 1启用 2禁用
QqNetbarTaskRules string `json:"qqNetbarTaskRules" orm:"qq_netbar_task_rules" description:"任务规则"` // 任务规则 QqNetbarTaskId string `json:"qqNetbarTaskId" orm:"qq_netbar_task_id" description:"QQ网吧任务ID"` // QQ网吧任务ID
GameId int64 `json:"gameId" orm:"game_id" description:"游戏唯一id"` // 游戏唯一id QqNetbarTaskRules string `json:"qqNetbarTaskRules" orm:"qq_netbar_task_rules" description:"任务规则"` // 任务规则
StoreId int64 `json:"storeId" orm:"store_id" description:"门店 id"` // 门店 id QqNetbarTaskMemo string `json:"qqNetbarTaskMemo" orm:"qq_netbar_task_memo" description:"任务描述"` // 任务描述
QqNetbarReward string `json:"qqNetbarReward" orm:"qq_netbar_reward" description:""` // QqNetbarTaskName string `json:"qqNetbarTaskName" orm:"qq_netbar_task_name" description:"QQ网吧任务名称"` // QQ网吧任务名称
Status int `json:"status" orm:"status" description:"1启用 2禁用"` // 1启用 2禁用 QqNetbarReward string `json:"qqNetbarReward" orm:"qq_netbar_reward" description:"qq 网吧奖励名称"` // qq 网吧奖励名称
QqNetbarTargetTime int `json:"qqNetbarTargetTime" orm:"qq_netbar_target_time" description:"qq 网吧任务指标"` // qq 网吧任务指标
StartTime int64 `json:"startTime" orm:"start_time" description:"任务开始时间"` // 任务开始时间
EndTime int64 `json:"endTime" orm:"end_time" description:"任务结束时间"` // 任务结束时间
} }

View File

@ -50,8 +50,8 @@ type GameTaskResponse struct {
} }
type TaskParam struct { type TaskParam struct {
NetbarAccount string `json:"netbar_account"` NetBarAccount string `json:"netbar_account"`
PageIds string `json:"pageidx"` Pageidx string `json:"pageidx"`
Num int `json:"num"` Num int `json:"num"`
Gid int `json:"gid"` Gid int `json:"gid"`
BrandId string `json:"brand_id"` BrandId string `json:"brand_id"`

View File

@ -1,11 +1,13 @@
package model package model
import ( import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/os/gtime"
) )
// Reward 奖励表 // Reward 奖励表
type Reward struct { type Reward struct {
g.Meta `orm:"table:reward"`
Id int64 `json:"id" dc:"奖励ID" orm:"id,primary"` Id int64 `json:"id" dc:"奖励ID" orm:"id,primary"`
RewardTypeId int64 `json:"rewardTypeId" dc:"奖励类型ID" orm:"reward_type_id"` RewardTypeId int64 `json:"rewardTypeId" dc:"奖励类型ID" orm:"reward_type_id"`
RewardTypeName string `json:"rewardTypeName" dc:"奖励类型名称" orm:"reward_type_name"` RewardTypeName string `json:"rewardTypeName" dc:"奖励类型名称" orm:"reward_type_name"`

View File

@ -6,19 +6,22 @@ import (
) )
type Task 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 CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间 UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间 DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间"` // 软删除时间
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间戳"` // 软删除时间戳 GameId int64 `json:"gameId" orm:"game_id" description:"游戏唯一id"` // 游戏唯一id
QqNetbarTaskName string `json:"qqNetbarTaskName" orm:"qq_netbar_task_name" description:"QQ网吧任务名称"` // QQ网吧任务名称 StoreId int64 `json:"storeId" orm:"store_id" description:"门店 id"` // 门店 id
QqNetbarTaskMemo string `json:"qqNetbarTaskMemo" orm:"qq_netbar_task_memo" description:"任务描述"` // 任务描述 Status int `json:"status" orm:"status" description:"1启用 2禁用"` // 1启用 2禁用
QqNetbarTaskRules string `json:"qqNetbarTaskRules" orm:"qq_netbar_task_rules" description:"任务规则"` // 任务规则 QqNetbarTaskId string `json:"qqNetbarTaskId" orm:"qq_netbar_task_id" description:"QQ网吧任务ID"` // QQ网吧任务ID
GameId int64 `json:"gameId" orm:"game_id" description:"游戏唯一id"` // 游戏唯一id QqNetbarTaskRules string `json:"qqNetbarTaskRules" orm:"qq_netbar_task_rules" description:"任务规则"` // 任务规则
StoreId int64 `json:"storeId" orm:"store_id" description:"门店 id"` // 门店 id QqNetbarTaskMemo string `json:"qqNetbarTaskMemo" orm:"qq_netbar_task_memo" description:"任务描述"` // 任务描述
Status int `json:"status" orm:"status" description:"状态"` // 状态 QqNetbarTaskName string `json:"qqNetbarTaskName" orm:"qq_netbar_task_name" description:"QQ网吧任务名称"` // QQ网吧任务名称
QQNetBarReward string `json:"qqNetbarReward" orm:"qq_netbar_reward" description:"qq网吧奖励名称"` // 任务奖励 QqNetbarReward string `json:"qqNetbarReward" orm:"qq_netbar_reward" description:"qq 网吧奖励名称"` // qq 网吧奖励名称
NetbarRewards []Reward `json:"netbarRewards" orm:"-"` QqNetbarTargetTime int `json:"qqNetbarTargetTime" orm:"qq_netbar_target_time" description:"qq 网吧任务指标"` // qq 网吧任务指标
StartTime int64 `json:"startTime" orm:"start_time" description:"任务开始时间"` // 任务开始时间
EndTime int64 `json:"endTime" orm:"end_time" description:"任务结束时间"` // 任务结束时间
NetbarRewards []Reward `json:"netbarRewards" orm:"-"`
} }
type GetNonLoginTaskListIn struct { type GetNonLoginTaskListIn struct {

View File

@ -309,10 +309,10 @@ 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) (interface{}, error) { func (s *gamelifeClient) RequestActivity(ctx context.Context, in *model.QQNetbarActivityIn) (interface{}, error) {
client := resty.New() client := resty.New()
switch in.ServiceName { switch in.ServiceName {
case "GetNonloginTaskList": case consts.GetNonLoginTaskList:
result := model.GameTaskResponse{} result := model.GameTaskResponse{}
in.TaskParam.Source = s.PlatId in.TaskParam.Source = s.PlatId
in.TaskParam.BrandId = s.BrandId in.TaskParam.BrandId = s.BrandId
@ -320,7 +320,7 @@ func (s *gamelifeClient) RequestNetbarTaskByGameID(ctx context.Context, in *mode
SetContext(ctx). SetContext(ctx).
SetBody(in.TaskParam). SetBody(in.TaskParam).
SetResult(&result). SetResult(&result).
Post(s.taskUrlMap[s.Mode] + "GetNonloginTaskList") Post(s.taskUrlMap[s.Mode] + consts.GetNonLoginTaskList)
if err != nil { if err != nil {
return nil, ecode.Fail.Sub("请求出现异常") return nil, ecode.Fail.Sub("请求出现异常")
} }

View File

@ -1,93 +0,0 @@
package tencent
import (
"bytes"
"context"
"encoding/json"
"fmt"
"github.com/gogf/gf/v2/frame/g"
"golang.org/x/net/context/ctxhttp"
"io"
"net/http"
"server/internal/consts"
"server/internal/model"
"server/utility/ecode"
)
// GetNonLoginTaskList 获取下发到指定网吧的任务列表(未登录)
func GetNonLoginTaskList(ctx context.Context, in *model.GetNonLoginTaskListIn) (data interface{}, err error) {
// 请求参数
jsonStr, err := json.Marshal(in)
if err != nil {
return nil, ecode.Fail.Sub("参数序列化失败")
}
resp, err := ctxhttp.Post(ctx, http.DefaultClient, consts.TestAddr+"GetNonloginTaskList", "application/json", bytes.NewBuffer(jsonStr))
if err != nil {
return nil, ecode.Fail.Sub("请求失败")
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, ecode.Fail.Sub("读取响应失败")
}
err = json.Unmarshal(body, &data)
if err != nil {
return nil, ecode.Fail.Sub("解析响应失败")
}
return data, err
}
// GetLoginTaskList 获取下发到指定网吧的任务列表(已登录)
func GetLoginTaskList(ctx context.Context, in *model.GetLoginTaskListIn) (data interface{}, err error) {
value, err := g.Redis().Get(ctx, fmt.Sprintf(consts.GameLifeUserKey, in.POpenId))
if value.IsEmpty() {
return nil, ecode.Fail.Sub("从redis获取值异常")
}
if err != nil {
return nil, ecode.Fail.Sub("从redis读取数据失败")
}
var cache model.UserGamelifeCache
err = json.Unmarshal(value.Bytes(), &cache)
if err != nil {
return nil, ecode.Fail.Sub("获取用户信息失败")
}
req := &model.GetTenCentLoginTaskListIn{
Gid: in.Gid,
NetBarAccount: in.NetBarAccount,
Num: 10,
Pageidx: "",
BrandId: "",
}
// 请求参数
jsonStr, err := json.Marshal(req)
if err != nil {
return nil, ecode.Fail.Sub("参数序列化失败")
}
resp, err := ctxhttp.Post(ctx, http.DefaultClient, consts.TestAddr+"GetTaskList"+"?"+cache.Params, "application/json", bytes.NewBuffer(jsonStr))
if err != nil {
return nil, ecode.Fail.Sub("请求失败")
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, ecode.Fail.Sub("解析响应体失败")
}
err = json.Unmarshal(body, &data)
if err != nil {
return nil, ecode.Fail.Sub("反序列化异常")
}
return data, err
}