Files
arenax-server/internal/dao/internal/rewards.go

122 lines
4.5 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// ==========================================================================
// 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)
}