122 lines
4.5 KiB
Go
122 lines
4.5 KiB
Go
// ==========================================================================
|
||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||
// ==========================================================================
|
||
|
||
package internal
|
||
|
||
import (
|
||
"context"
|
||
|
||
"github.com/gogf/gf/v2/database/gdb"
|
||
"github.com/gogf/gf/v2/frame/g"
|
||
)
|
||
|
||
// RewardsDao is the data access object for the table rewards.
|
||
type RewardsDao 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 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.
|
||
type RewardsColumns struct {
|
||
Id string // 奖励ID
|
||
StoreId string // 门店ID,系统奖励为NULL
|
||
Name string // 奖励名称
|
||
RewardTypeId string // 奖励类型ID,关联 reward_types 表
|
||
GameId string // 游戏ID
|
||
ImageUrl string // 奖励图片链接
|
||
QqGoodsId string // QQ网吧物品ID
|
||
QqGoodsIdStr string // QQ网吧物品ID字符串
|
||
Status string // 状态:1=启用,2=禁用
|
||
ExpireType string // 过期方式:1=时间段过期,2=领取后过期
|
||
ValidFrom string // 有效期开始时间(expire_type=1时)
|
||
ValidTo string // 有效期结束时间(expire_type=1时)
|
||
ExpireDays string // 领取后多少天过期(expire_type=2时)
|
||
DailyTotalLimit string // 每日发放总限(NULL表示不限制)
|
||
TotalLimit string // 奖励总限(NULL表示不限制)
|
||
UserDailyLimit string // 用户每日领取限制(NULL表示不限制)
|
||
UserTotalLimit string // 用户领取总次数限制(NULL表示不限制)
|
||
ReceivedNum string // 已领取数量
|
||
GrantQuantity string // 每次发放个数
|
||
CreatedAt string // 创建时间
|
||
UpdatedAt string // 更新时间
|
||
DeletedAt string // 删除时间(软删除)
|
||
}
|
||
|
||
// rewardsColumns holds the columns for the table rewards.
|
||
var rewardsColumns = RewardsColumns{
|
||
Id: "id",
|
||
StoreId: "store_id",
|
||
Name: "name",
|
||
RewardTypeId: "reward_type_id",
|
||
GameId: "game_id",
|
||
ImageUrl: "image_url",
|
||
QqGoodsId: "qq_goods_id",
|
||
QqGoodsIdStr: "qq_goods_id_str",
|
||
Status: "status",
|
||
ExpireType: "expire_type",
|
||
ValidFrom: "valid_from",
|
||
ValidTo: "valid_to",
|
||
ExpireDays: "expire_days",
|
||
DailyTotalLimit: "daily_total_limit",
|
||
TotalLimit: "total_limit",
|
||
UserDailyLimit: "user_daily_limit",
|
||
UserTotalLimit: "user_total_limit",
|
||
ReceivedNum: "received_num",
|
||
GrantQuantity: "grant_quantity",
|
||
CreatedAt: "created_at",
|
||
UpdatedAt: "updated_at",
|
||
DeletedAt: "deleted_at",
|
||
}
|
||
|
||
// NewRewardsDao creates and returns a new DAO object for table data access.
|
||
func NewRewardsDao(handlers ...gdb.ModelHandler) *RewardsDao {
|
||
return &RewardsDao{
|
||
group: "default",
|
||
table: "rewards",
|
||
columns: rewardsColumns,
|
||
handlers: handlers,
|
||
}
|
||
}
|
||
|
||
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||
func (dao *RewardsDao) DB() gdb.DB {
|
||
return g.DB(dao.group)
|
||
}
|
||
|
||
// Table returns the table name of the current DAO.
|
||
func (dao *RewardsDao) Table() string {
|
||
return dao.table
|
||
}
|
||
|
||
// Columns returns all column names of the current DAO.
|
||
func (dao *RewardsDao) Columns() RewardsColumns {
|
||
return dao.columns
|
||
}
|
||
|
||
// Group returns the database configuration group name of the current DAO.
|
||
func (dao *RewardsDao) Group() string {
|
||
return dao.group
|
||
}
|
||
|
||
// 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 {
|
||
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.
|
||
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||
// It commits the transaction and returns nil if function f returns nil.
|
||
//
|
||
// Note: Do not commit or roll back the transaction in function f,
|
||
// as it is automatically handled by this function.
|
||
func (dao *RewardsDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||
}
|