任务列表新增 qq网吧奖励名称,状态
This commit is contained in:
@ -16,6 +16,7 @@ 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.
|
||||||
|
|||||||
@ -16,6 +16,7 @@ type RewardsDao 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 RewardsColumns // columns contains all the column names of Table for convenient usage.
|
columns RewardsColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
}
|
}
|
||||||
|
|
||||||
// RewardsColumns defines and stores column names for the table rewards.
|
// RewardsColumns defines and stores column names for the table rewards.
|
||||||
@ -49,11 +50,12 @@ var rewardsColumns = RewardsColumns{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewRewardsDao creates and returns a new DAO object for table data access.
|
// NewRewardsDao creates and returns a new DAO object for table data access.
|
||||||
func NewRewardsDao() *RewardsDao {
|
func NewRewardsDao(handlers ...gdb.ModelHandler) *RewardsDao {
|
||||||
return &RewardsDao{
|
return &RewardsDao{
|
||||||
group: "default",
|
group: "default",
|
||||||
table: "rewards",
|
table: "rewards",
|
||||||
columns: rewardsColumns,
|
columns: rewardsColumns,
|
||||||
|
handlers: handlers,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +81,11 @@ func (dao *RewardsDao) 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 *RewardsDao) Ctx(ctx context.Context) *gdb.Model {
|
func (dao *RewardsDao) 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.
|
||||||
|
|||||||
@ -16,6 +16,7 @@ type StoreTaskRewardsDao 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 StoreTaskRewardsColumns // columns contains all the column names of Table for convenient usage.
|
columns StoreTaskRewardsColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
}
|
}
|
||||||
|
|
||||||
// StoreTaskRewardsColumns defines and stores column names for the table store_task_rewards.
|
// StoreTaskRewardsColumns defines and stores column names for the table store_task_rewards.
|
||||||
@ -45,11 +46,12 @@ var storeTaskRewardsColumns = StoreTaskRewardsColumns{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewStoreTaskRewardsDao creates and returns a new DAO object for table data access.
|
// NewStoreTaskRewardsDao creates and returns a new DAO object for table data access.
|
||||||
func NewStoreTaskRewardsDao() *StoreTaskRewardsDao {
|
func NewStoreTaskRewardsDao(handlers ...gdb.ModelHandler) *StoreTaskRewardsDao {
|
||||||
return &StoreTaskRewardsDao{
|
return &StoreTaskRewardsDao{
|
||||||
group: "default",
|
group: "default",
|
||||||
table: "store_task_rewards",
|
table: "store_task_rewards",
|
||||||
columns: storeTaskRewardsColumns,
|
columns: storeTaskRewardsColumns,
|
||||||
|
handlers: handlers,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +77,11 @@ func (dao *StoreTaskRewardsDao) 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 *StoreTaskRewardsDao) Ctx(ctx context.Context) *gdb.Model {
|
func (dao *StoreTaskRewardsDao) 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.
|
||||||
|
|||||||
@ -31,6 +31,8 @@ type TasksColumns struct {
|
|||||||
QqNetbarTaskRules string // 任务规则
|
QqNetbarTaskRules string // 任务规则
|
||||||
GameId string // 游戏唯一id
|
GameId string // 游戏唯一id
|
||||||
StoreId string // 门店 id
|
StoreId string // 门店 id
|
||||||
|
QqNetbarReward string //
|
||||||
|
Status string // 1:启用 2:禁用
|
||||||
}
|
}
|
||||||
|
|
||||||
// tasksColumns holds the columns for the table tasks.
|
// tasksColumns holds the columns for the table tasks.
|
||||||
@ -45,6 +47,8 @@ var tasksColumns = TasksColumns{
|
|||||||
QqNetbarTaskRules: "qq_netbar_task_rules",
|
QqNetbarTaskRules: "qq_netbar_task_rules",
|
||||||
GameId: "game_id",
|
GameId: "game_id",
|
||||||
StoreId: "store_id",
|
StoreId: "store_id",
|
||||||
|
QqNetbarReward: "qq_netbar_reward",
|
||||||
|
Status: "status",
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTasksDao creates and returns a new DAO object for table data access.
|
// NewTasksDao creates and returns a new DAO object for table data access.
|
||||||
|
|||||||
@ -16,6 +16,7 @@ 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.
|
||||||
|
|||||||
@ -140,7 +140,6 @@ func (s *sTask) UserTaskRankingList(ctx context.Context, in *model.UserTaskRanki
|
|||||||
// GetNonLoginTaskList 获取下发到指定网吧的任务列表(未登录)
|
// GetNonLoginTaskList 获取下发到指定网吧的任务列表(未登录)
|
||||||
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) {
|
||||||
|
|
||||||
// TODO 调用外部接口
|
|
||||||
// 调用外部接口
|
// 调用外部接口
|
||||||
data, err := tencent.GetNonLoginTaskList(ctx, in)
|
data, err := tencent.GetNonLoginTaskList(ctx, in)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -157,7 +156,7 @@ func (s *sTask) GetNonLoginTaskList(ctx context.Context, in *model.GetNonLoginTa
|
|||||||
return nil, ecode.Fail.Sub("当前网吧不存在")
|
return nil, ecode.Fail.Sub("当前网吧不存在")
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO 任务列表数据处理
|
// 任务列表数据处理
|
||||||
if jsonData, ok := data.(map[string]interface{}); ok {
|
if jsonData, ok := data.(map[string]interface{}); ok {
|
||||||
// 现在可以访问 jsonData 中的字段
|
// 现在可以访问 jsonData 中的字段
|
||||||
list := jsonData["task_list"]
|
list := jsonData["task_list"]
|
||||||
@ -179,6 +178,14 @@ func (s *sTask) GetNonLoginTaskList(ctx context.Context, in *model.GetNonLoginTa
|
|||||||
return nil, ecode.Fail.Sub("查询该任务失败")
|
return nil, ecode.Fail.Sub("查询该任务失败")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
str := ""
|
||||||
|
for i, vv := range v.PrizeList {
|
||||||
|
str += vv.PrizeName
|
||||||
|
if i+1 != len(v.PrizeList) {
|
||||||
|
str += ","
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 数据库是否存在,无则添加
|
// 数据库是否存在,无则添加
|
||||||
if !exist {
|
if !exist {
|
||||||
_, err := dao.Tasks.Ctx(ctx).Insert(do.Tasks{
|
_, err := dao.Tasks.Ctx(ctx).Insert(do.Tasks{
|
||||||
@ -188,6 +195,7 @@ func (s *sTask) GetNonLoginTaskList(ctx context.Context, in *model.GetNonLoginTa
|
|||||||
QqNetbarTaskRules: v.QQNetBarTaskRules,
|
QqNetbarTaskRules: v.QQNetBarTaskRules,
|
||||||
GameId: in.Gid,
|
GameId: in.Gid,
|
||||||
StoreId: store.Id,
|
StoreId: store.Id,
|
||||||
|
QqNetbarReward: str,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, ecode.Fail.Sub("添加任务失败")
|
return nil, ecode.Fail.Sub("添加任务失败")
|
||||||
@ -203,14 +211,13 @@ func (s *sTask) GetNonLoginTaskList(ctx context.Context, in *model.GetNonLoginTa
|
|||||||
|
|
||||||
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) {
|
||||||
|
|
||||||
// TODO 调用外部接口
|
|
||||||
// 调用外部接口
|
// 调用外部接口
|
||||||
data, err := tencent.GetLoginTaskList(ctx, in)
|
data, err := tencent.GetLoginTaskList(ctx, in)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO 任务列表数据处理
|
// 任务列表数据处理
|
||||||
return &model.GetLoginTaskListOut{
|
return &model.GetLoginTaskListOut{
|
||||||
Data: data,
|
Data: data,
|
||||||
}, err
|
}, err
|
||||||
|
|||||||
@ -22,4 +22,6 @@ type Tasks struct {
|
|||||||
QqNetbarTaskRules interface{} // 任务规则
|
QqNetbarTaskRules interface{} // 任务规则
|
||||||
GameId interface{} // 游戏唯一id
|
GameId interface{} // 游戏唯一id
|
||||||
StoreId interface{} // 门店 id
|
StoreId interface{} // 门店 id
|
||||||
|
QqNetbarReward interface{} //
|
||||||
|
Status interface{} // 1:启用 2:禁用
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,4 +20,6 @@ type Tasks struct {
|
|||||||
QqNetbarTaskRules string `json:"qqNetbarTaskRules" orm:"qq_netbar_task_rules" description:"任务规则"` // 任务规则
|
QqNetbarTaskRules string `json:"qqNetbarTaskRules" orm:"qq_netbar_task_rules" description:"任务规则"` // 任务规则
|
||||||
GameId int64 `json:"gameId" orm:"game_id" description:"游戏唯一id"` // 游戏唯一id
|
GameId int64 `json:"gameId" orm:"game_id" description:"游戏唯一id"` // 游戏唯一id
|
||||||
StoreId int64 `json:"storeId" orm:"store_id" description:"门店 id"` // 门店 id
|
StoreId int64 `json:"storeId" orm:"store_id" description:"门店 id"` // 门店 id
|
||||||
|
QqNetbarReward string `json:"qqNetbarReward" orm:"qq_netbar_reward" description:""` //
|
||||||
|
Status int `json:"status" orm:"status" description:"1:启用 2:禁用"` // 1:启用 2:禁用
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,6 +16,8 @@ type Tasks struct {
|
|||||||
QqNetbarTaskRules string `json:"qqNetbarTaskRules" orm:"qq_netbar_task_rules" description:"任务规则"` // 任务规则
|
QqNetbarTaskRules string `json:"qqNetbarTaskRules" orm:"qq_netbar_task_rules" description:"任务规则"` // 任务规则
|
||||||
GameId int64 `json:"gameId" orm:"game_id" description:"游戏唯一id"` // 游戏唯一id
|
GameId int64 `json:"gameId" orm:"game_id" description:"游戏唯一id"` // 游戏唯一id
|
||||||
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:"状态"` // 状态
|
||||||
|
QQNetBarReward string `json:"qqNetbarReward" orm:"qq_netbar_reward" description:"qq网吧奖励名称"` // 任务奖励
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetNonLoginTaskListIn struct {
|
type GetNonLoginTaskListIn struct {
|
||||||
@ -64,6 +66,11 @@ type MyData struct {
|
|||||||
QQNetBarTaskName string `json:"title"`
|
QQNetBarTaskName string `json:"title"`
|
||||||
QQNetBarTaskRules string `json:"rule_desc"`
|
QQNetBarTaskRules string `json:"rule_desc"`
|
||||||
//StoreId int `json:"store_id"`
|
//StoreId int `json:"store_id"`
|
||||||
|
PrizeList []PrizeList `json:"prize_list"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type PrizeList struct {
|
||||||
|
PrizeName string `json:"prize_name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TaskListIn struct {
|
type TaskListIn struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user