Some checks failed
Build docker and publish / linux (1.24.5) (push) Failing after 25s
feat(admin): 新增工会管理功能 feat(activity): 添加活动管理相关服务 feat(user): 实现用户道具卡和积分管理 feat(guild): 新增工会成员管理功能 fix: 修复数据库连接配置 fix: 修正jwtoken导入路径 fix: 解决端口冲突问题 style: 统一代码格式和注释风格 style: 更新项目常量命名 docs: 添加项目框架和开发规范文档 docs: 更新接口文档注释 chore: 移除无用代码和文件 chore: 更新Makefile和配置文件 chore: 清理日志文件 test: 添加道具卡测试脚本
361 lines
9.9 KiB
Go
361 lines
9.9 KiB
Go
// 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 newActivities(db *gorm.DB, opts ...gen.DOOption) activities {
|
||
_activities := activities{}
|
||
|
||
_activities.activitiesDo.UseDB(db, opts...)
|
||
_activities.activitiesDo.UseModel(&model.Activities{})
|
||
|
||
tableName := _activities.activitiesDo.TableName()
|
||
_activities.ALL = field.NewAsterisk(tableName)
|
||
_activities.ID = field.NewInt64(tableName, "id")
|
||
_activities.CreatedAt = field.NewTime(tableName, "created_at")
|
||
_activities.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||
_activities.Name = field.NewString(tableName, "name")
|
||
_activities.Banner = field.NewString(tableName, "banner")
|
||
_activities.ActivityCategoryID = field.NewInt64(tableName, "activity_category_id")
|
||
_activities.Status = field.NewInt32(tableName, "status")
|
||
_activities.PriceDraw = field.NewInt64(tableName, "price_draw")
|
||
_activities.IsBoss = field.NewInt32(tableName, "is_boss")
|
||
_activities.StartTime = field.NewTime(tableName, "start_time")
|
||
_activities.EndTime = field.NewTime(tableName, "end_time")
|
||
|
||
_activities.fillFieldMap()
|
||
|
||
return _activities
|
||
}
|
||
|
||
// activities 活动
|
||
type activities struct {
|
||
activitiesDo
|
||
|
||
ALL field.Asterisk
|
||
ID field.Int64 // 主键ID
|
||
CreatedAt field.Time // 创建时间
|
||
UpdatedAt field.Time // 更新时间
|
||
Name field.String // 活动名称
|
||
Banner field.String // 活动横幅/海报URL
|
||
ActivityCategoryID field.Int64 // 活动所属分类ID(activity_categories.id,可空)
|
||
Status field.Int32 // 状态:1进行中 2下线
|
||
PriceDraw field.Int64 // 活动门票价格
|
||
IsBoss field.Int32 // Boss: 1 是 0 不是
|
||
StartTime field.Time // 开始时间
|
||
EndTime field.Time // 结束时间
|
||
|
||
fieldMap map[string]field.Expr
|
||
}
|
||
|
||
func (a activities) Table(newTableName string) *activities {
|
||
a.activitiesDo.UseTable(newTableName)
|
||
return a.updateTableName(newTableName)
|
||
}
|
||
|
||
func (a activities) As(alias string) *activities {
|
||
a.activitiesDo.DO = *(a.activitiesDo.As(alias).(*gen.DO))
|
||
return a.updateTableName(alias)
|
||
}
|
||
|
||
func (a *activities) updateTableName(table string) *activities {
|
||
a.ALL = field.NewAsterisk(table)
|
||
a.ID = field.NewInt64(table, "id")
|
||
a.CreatedAt = field.NewTime(table, "created_at")
|
||
a.UpdatedAt = field.NewTime(table, "updated_at")
|
||
a.Name = field.NewString(table, "name")
|
||
a.Banner = field.NewString(table, "banner")
|
||
a.ActivityCategoryID = field.NewInt64(table, "activity_category_id")
|
||
a.Status = field.NewInt32(table, "status")
|
||
a.PriceDraw = field.NewInt64(table, "price_draw")
|
||
a.IsBoss = field.NewInt32(table, "is_boss")
|
||
a.StartTime = field.NewTime(table, "start_time")
|
||
a.EndTime = field.NewTime(table, "end_time")
|
||
|
||
a.fillFieldMap()
|
||
|
||
return a
|
||
}
|
||
|
||
func (a *activities) 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 *activities) fillFieldMap() {
|
||
a.fieldMap = make(map[string]field.Expr, 11)
|
||
a.fieldMap["id"] = a.ID
|
||
a.fieldMap["created_at"] = a.CreatedAt
|
||
a.fieldMap["updated_at"] = a.UpdatedAt
|
||
a.fieldMap["name"] = a.Name
|
||
a.fieldMap["banner"] = a.Banner
|
||
a.fieldMap["activity_category_id"] = a.ActivityCategoryID
|
||
a.fieldMap["status"] = a.Status
|
||
a.fieldMap["price_draw"] = a.PriceDraw
|
||
a.fieldMap["is_boss"] = a.IsBoss
|
||
a.fieldMap["start_time"] = a.StartTime
|
||
a.fieldMap["end_time"] = a.EndTime
|
||
}
|
||
|
||
func (a activities) clone(db *gorm.DB) activities {
|
||
a.activitiesDo.ReplaceConnPool(db.Statement.ConnPool)
|
||
return a
|
||
}
|
||
|
||
func (a activities) replaceDB(db *gorm.DB) activities {
|
||
a.activitiesDo.ReplaceDB(db)
|
||
return a
|
||
}
|
||
|
||
type activitiesDo struct{ gen.DO }
|
||
|
||
func (a activitiesDo) Debug() *activitiesDo {
|
||
return a.withDO(a.DO.Debug())
|
||
}
|
||
|
||
func (a activitiesDo) WithContext(ctx context.Context) *activitiesDo {
|
||
return a.withDO(a.DO.WithContext(ctx))
|
||
}
|
||
|
||
func (a activitiesDo) ReadDB() *activitiesDo {
|
||
return a.Clauses(dbresolver.Read)
|
||
}
|
||
|
||
func (a activitiesDo) WriteDB() *activitiesDo {
|
||
return a.Clauses(dbresolver.Write)
|
||
}
|
||
|
||
func (a activitiesDo) Session(config *gorm.Session) *activitiesDo {
|
||
return a.withDO(a.DO.Session(config))
|
||
}
|
||
|
||
func (a activitiesDo) Clauses(conds ...clause.Expression) *activitiesDo {
|
||
return a.withDO(a.DO.Clauses(conds...))
|
||
}
|
||
|
||
func (a activitiesDo) Returning(value interface{}, columns ...string) *activitiesDo {
|
||
return a.withDO(a.DO.Returning(value, columns...))
|
||
}
|
||
|
||
func (a activitiesDo) Not(conds ...gen.Condition) *activitiesDo {
|
||
return a.withDO(a.DO.Not(conds...))
|
||
}
|
||
|
||
func (a activitiesDo) Or(conds ...gen.Condition) *activitiesDo {
|
||
return a.withDO(a.DO.Or(conds...))
|
||
}
|
||
|
||
func (a activitiesDo) Select(conds ...field.Expr) *activitiesDo {
|
||
return a.withDO(a.DO.Select(conds...))
|
||
}
|
||
|
||
func (a activitiesDo) Where(conds ...gen.Condition) *activitiesDo {
|
||
return a.withDO(a.DO.Where(conds...))
|
||
}
|
||
|
||
func (a activitiesDo) Order(conds ...field.Expr) *activitiesDo {
|
||
return a.withDO(a.DO.Order(conds...))
|
||
}
|
||
|
||
func (a activitiesDo) Distinct(cols ...field.Expr) *activitiesDo {
|
||
return a.withDO(a.DO.Distinct(cols...))
|
||
}
|
||
|
||
func (a activitiesDo) Omit(cols ...field.Expr) *activitiesDo {
|
||
return a.withDO(a.DO.Omit(cols...))
|
||
}
|
||
|
||
func (a activitiesDo) Join(table schema.Tabler, on ...field.Expr) *activitiesDo {
|
||
return a.withDO(a.DO.Join(table, on...))
|
||
}
|
||
|
||
func (a activitiesDo) LeftJoin(table schema.Tabler, on ...field.Expr) *activitiesDo {
|
||
return a.withDO(a.DO.LeftJoin(table, on...))
|
||
}
|
||
|
||
func (a activitiesDo) RightJoin(table schema.Tabler, on ...field.Expr) *activitiesDo {
|
||
return a.withDO(a.DO.RightJoin(table, on...))
|
||
}
|
||
|
||
func (a activitiesDo) Group(cols ...field.Expr) *activitiesDo {
|
||
return a.withDO(a.DO.Group(cols...))
|
||
}
|
||
|
||
func (a activitiesDo) Having(conds ...gen.Condition) *activitiesDo {
|
||
return a.withDO(a.DO.Having(conds...))
|
||
}
|
||
|
||
func (a activitiesDo) Limit(limit int) *activitiesDo {
|
||
return a.withDO(a.DO.Limit(limit))
|
||
}
|
||
|
||
func (a activitiesDo) Offset(offset int) *activitiesDo {
|
||
return a.withDO(a.DO.Offset(offset))
|
||
}
|
||
|
||
func (a activitiesDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *activitiesDo {
|
||
return a.withDO(a.DO.Scopes(funcs...))
|
||
}
|
||
|
||
func (a activitiesDo) Unscoped() *activitiesDo {
|
||
return a.withDO(a.DO.Unscoped())
|
||
}
|
||
|
||
func (a activitiesDo) Create(values ...*model.Activities) error {
|
||
if len(values) == 0 {
|
||
return nil
|
||
}
|
||
return a.DO.Create(values)
|
||
}
|
||
|
||
func (a activitiesDo) CreateInBatches(values []*model.Activities, 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 activitiesDo) Save(values ...*model.Activities) error {
|
||
if len(values) == 0 {
|
||
return nil
|
||
}
|
||
return a.DO.Save(values)
|
||
}
|
||
|
||
func (a activitiesDo) First() (*model.Activities, error) {
|
||
if result, err := a.DO.First(); err != nil {
|
||
return nil, err
|
||
} else {
|
||
return result.(*model.Activities), nil
|
||
}
|
||
}
|
||
|
||
func (a activitiesDo) Take() (*model.Activities, error) {
|
||
if result, err := a.DO.Take(); err != nil {
|
||
return nil, err
|
||
} else {
|
||
return result.(*model.Activities), nil
|
||
}
|
||
}
|
||
|
||
func (a activitiesDo) Last() (*model.Activities, error) {
|
||
if result, err := a.DO.Last(); err != nil {
|
||
return nil, err
|
||
} else {
|
||
return result.(*model.Activities), nil
|
||
}
|
||
}
|
||
|
||
func (a activitiesDo) Find() ([]*model.Activities, error) {
|
||
result, err := a.DO.Find()
|
||
return result.([]*model.Activities), err
|
||
}
|
||
|
||
func (a activitiesDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Activities, err error) {
|
||
buf := make([]*model.Activities, 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 activitiesDo) FindInBatches(result *[]*model.Activities, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||
return a.DO.FindInBatches(result, batchSize, fc)
|
||
}
|
||
|
||
func (a activitiesDo) Attrs(attrs ...field.AssignExpr) *activitiesDo {
|
||
return a.withDO(a.DO.Attrs(attrs...))
|
||
}
|
||
|
||
func (a activitiesDo) Assign(attrs ...field.AssignExpr) *activitiesDo {
|
||
return a.withDO(a.DO.Assign(attrs...))
|
||
}
|
||
|
||
func (a activitiesDo) Joins(fields ...field.RelationField) *activitiesDo {
|
||
for _, _f := range fields {
|
||
a = *a.withDO(a.DO.Joins(_f))
|
||
}
|
||
return &a
|
||
}
|
||
|
||
func (a activitiesDo) Preload(fields ...field.RelationField) *activitiesDo {
|
||
for _, _f := range fields {
|
||
a = *a.withDO(a.DO.Preload(_f))
|
||
}
|
||
return &a
|
||
}
|
||
|
||
func (a activitiesDo) FirstOrInit() (*model.Activities, error) {
|
||
if result, err := a.DO.FirstOrInit(); err != nil {
|
||
return nil, err
|
||
} else {
|
||
return result.(*model.Activities), nil
|
||
}
|
||
}
|
||
|
||
func (a activitiesDo) FirstOrCreate() (*model.Activities, error) {
|
||
if result, err := a.DO.FirstOrCreate(); err != nil {
|
||
return nil, err
|
||
} else {
|
||
return result.(*model.Activities), nil
|
||
}
|
||
}
|
||
|
||
func (a activitiesDo) FindByPage(offset int, limit int) (result []*model.Activities, 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 activitiesDo) 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 activitiesDo) Scan(result interface{}) (err error) {
|
||
return a.DO.Scan(result)
|
||
}
|
||
|
||
func (a activitiesDo) Delete(models ...*model.Activities) (result gen.ResultInfo, err error) {
|
||
return a.DO.Delete(models)
|
||
}
|
||
|
||
func (a *activitiesDo) withDO(do gen.Dao) *activitiesDo {
|
||
a.DO = *do.(*gen.DO)
|
||
return a
|
||
}
|