bindbox-game/internal/repository/mysql/dao/activity_draw_receipts.gen.go
邹方成 81e2fb5a75
Some checks failed
Build docker and publish / linux (1.24.5) (push) Failing after 41s
feat(activity): 实现抽奖随机承诺与验证功能
新增随机种子生成与验证逻辑,包括:
1. 添加随机承诺生成接口
2. 实现抽奖执行与验证流程
3. 新增批量用户创建与删除功能
4. 添加抽奖收据记录表
5. 完善配置管理与错误码

新增测试用例验证随机算法正确性
2025-11-15 20:39:13 +08:00

389 lines
13 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 by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package dao
import (
"context"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
"bindbox-game/internal/repository/mysql/model"
)
func newActivityDrawReceipts(db *gorm.DB, opts ...gen.DOOption) activityDrawReceipts {
_activityDrawReceipts := activityDrawReceipts{}
_activityDrawReceipts.activityDrawReceiptsDo.UseDB(db, opts...)
_activityDrawReceipts.activityDrawReceiptsDo.UseModel(&model.ActivityDrawReceipts{})
tableName := _activityDrawReceipts.activityDrawReceiptsDo.TableName()
_activityDrawReceipts.ALL = field.NewAsterisk(tableName)
_activityDrawReceipts.ID = field.NewInt64(tableName, "id")
_activityDrawReceipts.CreatedAt = field.NewTime(tableName, "created_at")
_activityDrawReceipts.DrawLogID = field.NewInt64(tableName, "draw_log_id")
_activityDrawReceipts.AlgoVersion = field.NewString(tableName, "algo_version")
_activityDrawReceipts.RoundID = field.NewInt64(tableName, "round_id")
_activityDrawReceipts.DrawID = field.NewInt64(tableName, "draw_id")
_activityDrawReceipts.ClientID = field.NewInt64(tableName, "client_id")
_activityDrawReceipts.Timestamp = field.NewInt64(tableName, "timestamp")
_activityDrawReceipts.ServerSeedHash = field.NewString(tableName, "server_seed_hash")
_activityDrawReceipts.ServerSubSeed = field.NewString(tableName, "server_sub_seed")
_activityDrawReceipts.ClientSeed = field.NewString(tableName, "client_seed")
_activityDrawReceipts.Nonce = field.NewInt64(tableName, "nonce")
_activityDrawReceipts.ItemsRoot = field.NewString(tableName, "items_root")
_activityDrawReceipts.WeightsTotal = field.NewInt64(tableName, "weights_total")
_activityDrawReceipts.SelectedIndex = field.NewInt32(tableName, "selected_index")
_activityDrawReceipts.RandProof = field.NewString(tableName, "rand_proof")
_activityDrawReceipts.Signature = field.NewString(tableName, "signature")
_activityDrawReceipts.ItemsSnapshot = field.NewString(tableName, "items_snapshot")
_activityDrawReceipts.fillFieldMap()
return _activityDrawReceipts
}
// activityDrawReceipts 活动抽奖凭据表
type activityDrawReceipts struct {
activityDrawReceiptsDo
ALL field.Asterisk
ID field.Int64 // 主键ID
CreatedAt field.Time // 创建时间
DrawLogID field.Int64 // 抽奖日志IDactivity_draw_logs.id
AlgoVersion field.String // 算法版本
RoundID field.Int64 // 期ID
DrawID field.Int64 // 抽奖ID
ClientID field.Int64 // 客户端ID
Timestamp field.Int64 // 时间戳(毫秒)
ServerSeedHash field.String // 服务器种子哈希(十六进制)
ServerSubSeed field.String // 服务器子种子(十六进制)
ClientSeed field.String // 客户端种子(十六进制)
Nonce field.Int64 // 随机数
ItemsRoot field.String // 项目根哈希(十六进制)
WeightsTotal field.Int64 // 权重总和
SelectedIndex field.Int32 // 选中索引
RandProof field.String // 随机证明(十六进制)
Signature field.String // 签名(十六进制,可选)
ItemsSnapshot field.String // 项目快照JSON格式
fieldMap map[string]field.Expr
}
func (a activityDrawReceipts) Table(newTableName string) *activityDrawReceipts {
a.activityDrawReceiptsDo.UseTable(newTableName)
return a.updateTableName(newTableName)
}
func (a activityDrawReceipts) As(alias string) *activityDrawReceipts {
a.activityDrawReceiptsDo.DO = *(a.activityDrawReceiptsDo.As(alias).(*gen.DO))
return a.updateTableName(alias)
}
func (a *activityDrawReceipts) updateTableName(table string) *activityDrawReceipts {
a.ALL = field.NewAsterisk(table)
a.ID = field.NewInt64(table, "id")
a.CreatedAt = field.NewTime(table, "created_at")
a.DrawLogID = field.NewInt64(table, "draw_log_id")
a.AlgoVersion = field.NewString(table, "algo_version")
a.RoundID = field.NewInt64(table, "round_id")
a.DrawID = field.NewInt64(table, "draw_id")
a.ClientID = field.NewInt64(table, "client_id")
a.Timestamp = field.NewInt64(table, "timestamp")
a.ServerSeedHash = field.NewString(table, "server_seed_hash")
a.ServerSubSeed = field.NewString(table, "server_sub_seed")
a.ClientSeed = field.NewString(table, "client_seed")
a.Nonce = field.NewInt64(table, "nonce")
a.ItemsRoot = field.NewString(table, "items_root")
a.WeightsTotal = field.NewInt64(table, "weights_total")
a.SelectedIndex = field.NewInt32(table, "selected_index")
a.RandProof = field.NewString(table, "rand_proof")
a.Signature = field.NewString(table, "signature")
a.ItemsSnapshot = field.NewString(table, "items_snapshot")
a.fillFieldMap()
return a
}
func (a *activityDrawReceipts) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := a.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (a *activityDrawReceipts) fillFieldMap() {
a.fieldMap = make(map[string]field.Expr, 18)
a.fieldMap["id"] = a.ID
a.fieldMap["created_at"] = a.CreatedAt
a.fieldMap["draw_log_id"] = a.DrawLogID
a.fieldMap["algo_version"] = a.AlgoVersion
a.fieldMap["round_id"] = a.RoundID
a.fieldMap["draw_id"] = a.DrawID
a.fieldMap["client_id"] = a.ClientID
a.fieldMap["timestamp"] = a.Timestamp
a.fieldMap["server_seed_hash"] = a.ServerSeedHash
a.fieldMap["server_sub_seed"] = a.ServerSubSeed
a.fieldMap["client_seed"] = a.ClientSeed
a.fieldMap["nonce"] = a.Nonce
a.fieldMap["items_root"] = a.ItemsRoot
a.fieldMap["weights_total"] = a.WeightsTotal
a.fieldMap["selected_index"] = a.SelectedIndex
a.fieldMap["rand_proof"] = a.RandProof
a.fieldMap["signature"] = a.Signature
a.fieldMap["items_snapshot"] = a.ItemsSnapshot
}
func (a activityDrawReceipts) clone(db *gorm.DB) activityDrawReceipts {
a.activityDrawReceiptsDo.ReplaceConnPool(db.Statement.ConnPool)
return a
}
func (a activityDrawReceipts) replaceDB(db *gorm.DB) activityDrawReceipts {
a.activityDrawReceiptsDo.ReplaceDB(db)
return a
}
type activityDrawReceiptsDo struct{ gen.DO }
func (a activityDrawReceiptsDo) Debug() *activityDrawReceiptsDo {
return a.withDO(a.DO.Debug())
}
func (a activityDrawReceiptsDo) WithContext(ctx context.Context) *activityDrawReceiptsDo {
return a.withDO(a.DO.WithContext(ctx))
}
func (a activityDrawReceiptsDo) ReadDB() *activityDrawReceiptsDo {
return a.Clauses(dbresolver.Read)
}
func (a activityDrawReceiptsDo) WriteDB() *activityDrawReceiptsDo {
return a.Clauses(dbresolver.Write)
}
func (a activityDrawReceiptsDo) Session(config *gorm.Session) *activityDrawReceiptsDo {
return a.withDO(a.DO.Session(config))
}
func (a activityDrawReceiptsDo) Clauses(conds ...clause.Expression) *activityDrawReceiptsDo {
return a.withDO(a.DO.Clauses(conds...))
}
func (a activityDrawReceiptsDo) Returning(value interface{}, columns ...string) *activityDrawReceiptsDo {
return a.withDO(a.DO.Returning(value, columns...))
}
func (a activityDrawReceiptsDo) Not(conds ...gen.Condition) *activityDrawReceiptsDo {
return a.withDO(a.DO.Not(conds...))
}
func (a activityDrawReceiptsDo) Or(conds ...gen.Condition) *activityDrawReceiptsDo {
return a.withDO(a.DO.Or(conds...))
}
func (a activityDrawReceiptsDo) Select(conds ...field.Expr) *activityDrawReceiptsDo {
return a.withDO(a.DO.Select(conds...))
}
func (a activityDrawReceiptsDo) Where(conds ...gen.Condition) *activityDrawReceiptsDo {
return a.withDO(a.DO.Where(conds...))
}
func (a activityDrawReceiptsDo) Order(conds ...field.Expr) *activityDrawReceiptsDo {
return a.withDO(a.DO.Order(conds...))
}
func (a activityDrawReceiptsDo) Distinct(cols ...field.Expr) *activityDrawReceiptsDo {
return a.withDO(a.DO.Distinct(cols...))
}
func (a activityDrawReceiptsDo) Omit(cols ...field.Expr) *activityDrawReceiptsDo {
return a.withDO(a.DO.Omit(cols...))
}
func (a activityDrawReceiptsDo) Join(table schema.Tabler, on ...field.Expr) *activityDrawReceiptsDo {
return a.withDO(a.DO.Join(table, on...))
}
func (a activityDrawReceiptsDo) LeftJoin(table schema.Tabler, on ...field.Expr) *activityDrawReceiptsDo {
return a.withDO(a.DO.LeftJoin(table, on...))
}
func (a activityDrawReceiptsDo) RightJoin(table schema.Tabler, on ...field.Expr) *activityDrawReceiptsDo {
return a.withDO(a.DO.RightJoin(table, on...))
}
func (a activityDrawReceiptsDo) Group(cols ...field.Expr) *activityDrawReceiptsDo {
return a.withDO(a.DO.Group(cols...))
}
func (a activityDrawReceiptsDo) Having(conds ...gen.Condition) *activityDrawReceiptsDo {
return a.withDO(a.DO.Having(conds...))
}
func (a activityDrawReceiptsDo) Limit(limit int) *activityDrawReceiptsDo {
return a.withDO(a.DO.Limit(limit))
}
func (a activityDrawReceiptsDo) Offset(offset int) *activityDrawReceiptsDo {
return a.withDO(a.DO.Offset(offset))
}
func (a activityDrawReceiptsDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *activityDrawReceiptsDo {
return a.withDO(a.DO.Scopes(funcs...))
}
func (a activityDrawReceiptsDo) Unscoped() *activityDrawReceiptsDo {
return a.withDO(a.DO.Unscoped())
}
func (a activityDrawReceiptsDo) Create(values ...*model.ActivityDrawReceipts) error {
if len(values) == 0 {
return nil
}
return a.DO.Create(values)
}
func (a activityDrawReceiptsDo) CreateInBatches(values []*model.ActivityDrawReceipts, batchSize int) error {
return a.DO.CreateInBatches(values, batchSize)
}
// Save : !!! underlying implementation is different with GORM
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
func (a activityDrawReceiptsDo) Save(values ...*model.ActivityDrawReceipts) error {
if len(values) == 0 {
return nil
}
return a.DO.Save(values)
}
func (a activityDrawReceiptsDo) First() (*model.ActivityDrawReceipts, error) {
if result, err := a.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.ActivityDrawReceipts), nil
}
}
func (a activityDrawReceiptsDo) Take() (*model.ActivityDrawReceipts, error) {
if result, err := a.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.ActivityDrawReceipts), nil
}
}
func (a activityDrawReceiptsDo) Last() (*model.ActivityDrawReceipts, error) {
if result, err := a.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.ActivityDrawReceipts), nil
}
}
func (a activityDrawReceiptsDo) Find() ([]*model.ActivityDrawReceipts, error) {
result, err := a.DO.Find()
return result.([]*model.ActivityDrawReceipts), err
}
func (a activityDrawReceiptsDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ActivityDrawReceipts, err error) {
buf := make([]*model.ActivityDrawReceipts, 0, batchSize)
err = a.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
defer func() { results = append(results, buf...) }()
return fc(tx, batch)
})
return results, err
}
func (a activityDrawReceiptsDo) FindInBatches(result *[]*model.ActivityDrawReceipts, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return a.DO.FindInBatches(result, batchSize, fc)
}
func (a activityDrawReceiptsDo) Attrs(attrs ...field.AssignExpr) *activityDrawReceiptsDo {
return a.withDO(a.DO.Attrs(attrs...))
}
func (a activityDrawReceiptsDo) Assign(attrs ...field.AssignExpr) *activityDrawReceiptsDo {
return a.withDO(a.DO.Assign(attrs...))
}
func (a activityDrawReceiptsDo) Joins(fields ...field.RelationField) *activityDrawReceiptsDo {
for _, _f := range fields {
a = *a.withDO(a.DO.Joins(_f))
}
return &a
}
func (a activityDrawReceiptsDo) Preload(fields ...field.RelationField) *activityDrawReceiptsDo {
for _, _f := range fields {
a = *a.withDO(a.DO.Preload(_f))
}
return &a
}
func (a activityDrawReceiptsDo) FirstOrInit() (*model.ActivityDrawReceipts, error) {
if result, err := a.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.ActivityDrawReceipts), nil
}
}
func (a activityDrawReceiptsDo) FirstOrCreate() (*model.ActivityDrawReceipts, error) {
if result, err := a.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.ActivityDrawReceipts), nil
}
}
func (a activityDrawReceiptsDo) FindByPage(offset int, limit int) (result []*model.ActivityDrawReceipts, count int64, err error) {
result, err = a.Offset(offset).Limit(limit).Find()
if err != nil {
return
}
if size := len(result); 0 < limit && 0 < size && size < limit {
count = int64(size + offset)
return
}
count, err = a.Offset(-1).Limit(-1).Count()
return
}
func (a activityDrawReceiptsDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = a.Count()
if err != nil {
return
}
err = a.Offset(offset).Limit(limit).Scan(result)
return
}
func (a activityDrawReceiptsDo) Scan(result interface{}) (err error) {
return a.DO.Scan(result)
}
func (a activityDrawReceiptsDo) Delete(models ...*model.ActivityDrawReceipts) (result gen.ResultInfo, err error) {
return a.DO.Delete(models)
}
func (a *activityDrawReceiptsDo) withDO(do gen.Dao) *activityDrawReceiptsDo {
a.DO = *do.(*gen.DO)
return a
}