查询当前登录用户排名,
This commit is contained in:
@ -21,9 +21,10 @@ type GamesDao struct {
|
||||
|
||||
// GamesColumns defines and stores column names for the table games.
|
||||
type GamesColumns struct {
|
||||
Id string //
|
||||
GameId string // 腾讯游戏 id
|
||||
GameName string // 游戏名称
|
||||
GameaCode string // 游戏代号
|
||||
GameCode string // 游戏代号
|
||||
Avatar string // 图标
|
||||
CreatedAt string // 创建时间
|
||||
UpdatedAt string // 更新时间
|
||||
@ -32,9 +33,10 @@ type GamesColumns struct {
|
||||
|
||||
// gamesColumns holds the columns for the table games.
|
||||
var gamesColumns = GamesColumns{
|
||||
Id: "id",
|
||||
GameId: "game_id",
|
||||
GameName: "game_name",
|
||||
GameaCode: "gamea_code",
|
||||
GameCode: "game_code",
|
||||
Avatar: "avatar",
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
|
||||
@ -13,9 +13,10 @@ import (
|
||||
|
||||
// TasksDao is the data access object for the table tasks.
|
||||
type TasksDao struct {
|
||||
table string // table is the underlying table name of the DAO.
|
||||
group string // group is the database configuration group name of the current DAO.
|
||||
columns TasksColumns // columns contains all the column names of Table for convenient usage.
|
||||
table string // table is the underlying table name of the DAO.
|
||||
group string // group is the database configuration group name of the current DAO.
|
||||
columns TasksColumns // columns contains all the column names of Table for convenient usage.
|
||||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||
}
|
||||
|
||||
// TasksColumns defines and stores column names for the table tasks.
|
||||
@ -37,11 +38,12 @@ var tasksColumns = TasksColumns{
|
||||
}
|
||||
|
||||
// NewTasksDao creates and returns a new DAO object for table data access.
|
||||
func NewTasksDao() *TasksDao {
|
||||
func NewTasksDao(handlers ...gdb.ModelHandler) *TasksDao {
|
||||
return &TasksDao{
|
||||
group: "default",
|
||||
table: "tasks",
|
||||
columns: tasksColumns,
|
||||
group: "default",
|
||||
table: "tasks",
|
||||
columns: tasksColumns,
|
||||
handlers: handlers,
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,7 +69,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.
|
||||
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.
|
||||
|
||||
@ -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.
|
||||
@ -29,6 +30,7 @@ type UserTasksColumns struct {
|
||||
UpdatedAt string // 更新时间
|
||||
CompletedAt string // 任务完成时间
|
||||
DeletedAt string // 软删除时间戳
|
||||
StoreId string // 门店 id
|
||||
}
|
||||
|
||||
// userTasksColumns holds the columns for the table user_tasks.
|
||||
@ -42,14 +44,16 @@ var userTasksColumns = UserTasksColumns{
|
||||
UpdatedAt: "updated_at",
|
||||
CompletedAt: "completed_at",
|
||||
DeletedAt: "deleted_at",
|
||||
StoreId: "store_id",
|
||||
}
|
||||
|
||||
// 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,
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,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.
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user