修改PC任务领取

This commit is contained in:
chy
2025-07-08 11:23:36 +08:00
parent 8490579dad
commit 1a5cc50881
31 changed files with 399 additions and 250 deletions

View File

@ -13,9 +13,10 @@ import (
// UserTasksDao is the data access object for the table user_tasks.
type UserTasksDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns UserTasksColumns // columns contains all the column names of Table for convenient usage.
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns UserTasksColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// UserTasksColumns defines and stores column names for the table user_tasks.
@ -33,6 +34,7 @@ type UserTasksColumns struct {
TaskName string // 任务名称
GameId string // 游戏 id
TaskType string // 1: 每日任务 3: 周期任务
UserTimes string // 用户完成次数
}
// userTasksColumns holds the columns for the table user_tasks.
@ -50,14 +52,16 @@ var userTasksColumns = UserTasksColumns{
TaskName: "task_name",
GameId: "game_id",
TaskType: "task_type",
UserTimes: "user_times",
}
// NewUserTasksDao creates and returns a new DAO object for table data access.
func NewUserTasksDao() *UserTasksDao {
func NewUserTasksDao(handlers ...gdb.ModelHandler) *UserTasksDao {
return &UserTasksDao{
group: "default",
table: "user_tasks",
columns: userTasksColumns,
group: "default",
table: "user_tasks",
columns: userTasksColumns,
handlers: handlers,
}
}
@ -83,7 +87,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.
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.