98 lines
3.3 KiB
Go
98 lines
3.3 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.
|
||
}
|
||
|
||
// RewardsColumns defines and stores column names for the table rewards.
|
||
type RewardsColumns struct {
|
||
Id string // 奖励唯一标识符
|
||
RewardTypeId string // 奖励类型ID
|
||
RewardScope string // 奖励范围:1=系统奖励,2=门店奖励
|
||
Name string // 奖励名称
|
||
Code string // 奖励编号
|
||
Description string // 奖励描述
|
||
Status string // 状态:1=启用,2=禁用
|
||
Stock string // 奖励库存(0表示无限制)
|
||
StartAt string // 奖励有效开始时间
|
||
ExpireAt string // 奖励有效结束时间
|
||
CreatedAt string // 创建时间
|
||
UpdatedAt string // 更新时间
|
||
DeletedAt string // 软删除时间戳
|
||
}
|
||
|
||
// rewardsColumns holds the columns for the table rewards.
|
||
var rewardsColumns = RewardsColumns{
|
||
Id: "id",
|
||
RewardTypeId: "reward_type_id",
|
||
RewardScope: "reward_scope",
|
||
Name: "name",
|
||
Code: "code",
|
||
Description: "description",
|
||
Status: "status",
|
||
Stock: "stock",
|
||
StartAt: "start_at",
|
||
ExpireAt: "expire_at",
|
||
CreatedAt: "created_at",
|
||
UpdatedAt: "updated_at",
|
||
DeletedAt: "deleted_at",
|
||
}
|
||
|
||
// NewRewardsDao creates and returns a new DAO object for table data access.
|
||
func NewRewardsDao() *RewardsDao {
|
||
return &RewardsDao{
|
||
group: "default",
|
||
table: "rewards",
|
||
columns: rewardsColumns,
|
||
}
|
||
}
|
||
|
||
// 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 {
|
||
return dao.DB().Model(dao.table).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)
|
||
}
|