bindbox-game/internal/repository/mysql/dao/system_titles.gen.go

353 lines
9.8 KiB
Go
Executable File
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 newSystemTitles(db *gorm.DB, opts ...gen.DOOption) systemTitles {
_systemTitles := systemTitles{}
_systemTitles.systemTitlesDo.UseDB(db, opts...)
_systemTitles.systemTitlesDo.UseModel(&model.SystemTitles{})
tableName := _systemTitles.systemTitlesDo.TableName()
_systemTitles.ALL = field.NewAsterisk(tableName)
_systemTitles.ID = field.NewInt64(tableName, "id")
_systemTitles.Name = field.NewString(tableName, "name")
_systemTitles.Description = field.NewString(tableName, "description")
_systemTitles.Status = field.NewInt32(tableName, "status")
_systemTitles.ObtainRulesJSON = field.NewString(tableName, "obtain_rules_json")
_systemTitles.ScopesJSON = field.NewString(tableName, "scopes_json")
_systemTitles.CreatedAt = field.NewTime(tableName, "created_at")
_systemTitles.UpdatedAt = field.NewTime(tableName, "updated_at")
_systemTitles.DeletedAt = field.NewField(tableName, "deleted_at")
_systemTitles.fillFieldMap()
return _systemTitles
}
// systemTitles 头衔模板表
type systemTitles struct {
systemTitlesDo
ALL field.Asterisk
ID field.Int64 // 头衔模板主键ID
Name field.String // 头衔名称(唯一)
Description field.String // 头衔描述
Status field.Int32 // 状态1启用 0停用
ObtainRulesJSON field.String // 获得条件规则JSON任务、等级、付费等
ScopesJSON field.String // 作用范围配置JSON活动/期/分类等)
CreatedAt field.Time // 创建时间
UpdatedAt field.Time // 更新时间
DeletedAt field.Field
fieldMap map[string]field.Expr
}
func (s systemTitles) Table(newTableName string) *systemTitles {
s.systemTitlesDo.UseTable(newTableName)
return s.updateTableName(newTableName)
}
func (s systemTitles) As(alias string) *systemTitles {
s.systemTitlesDo.DO = *(s.systemTitlesDo.As(alias).(*gen.DO))
return s.updateTableName(alias)
}
func (s *systemTitles) updateTableName(table string) *systemTitles {
s.ALL = field.NewAsterisk(table)
s.ID = field.NewInt64(table, "id")
s.Name = field.NewString(table, "name")
s.Description = field.NewString(table, "description")
s.Status = field.NewInt32(table, "status")
s.ObtainRulesJSON = field.NewString(table, "obtain_rules_json")
s.ScopesJSON = field.NewString(table, "scopes_json")
s.CreatedAt = field.NewTime(table, "created_at")
s.UpdatedAt = field.NewTime(table, "updated_at")
s.DeletedAt = field.NewField(table, "deleted_at")
s.fillFieldMap()
return s
}
func (s *systemTitles) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := s.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (s *systemTitles) fillFieldMap() {
s.fieldMap = make(map[string]field.Expr, 9)
s.fieldMap["id"] = s.ID
s.fieldMap["name"] = s.Name
s.fieldMap["description"] = s.Description
s.fieldMap["status"] = s.Status
s.fieldMap["obtain_rules_json"] = s.ObtainRulesJSON
s.fieldMap["scopes_json"] = s.ScopesJSON
s.fieldMap["created_at"] = s.CreatedAt
s.fieldMap["updated_at"] = s.UpdatedAt
s.fieldMap["deleted_at"] = s.DeletedAt
}
func (s systemTitles) clone(db *gorm.DB) systemTitles {
s.systemTitlesDo.ReplaceConnPool(db.Statement.ConnPool)
return s
}
func (s systemTitles) replaceDB(db *gorm.DB) systemTitles {
s.systemTitlesDo.ReplaceDB(db)
return s
}
type systemTitlesDo struct{ gen.DO }
func (s systemTitlesDo) Debug() *systemTitlesDo {
return s.withDO(s.DO.Debug())
}
func (s systemTitlesDo) WithContext(ctx context.Context) *systemTitlesDo {
return s.withDO(s.DO.WithContext(ctx))
}
func (s systemTitlesDo) ReadDB() *systemTitlesDo {
return s.Clauses(dbresolver.Read)
}
func (s systemTitlesDo) WriteDB() *systemTitlesDo {
return s.Clauses(dbresolver.Write)
}
func (s systemTitlesDo) Session(config *gorm.Session) *systemTitlesDo {
return s.withDO(s.DO.Session(config))
}
func (s systemTitlesDo) Clauses(conds ...clause.Expression) *systemTitlesDo {
return s.withDO(s.DO.Clauses(conds...))
}
func (s systemTitlesDo) Returning(value interface{}, columns ...string) *systemTitlesDo {
return s.withDO(s.DO.Returning(value, columns...))
}
func (s systemTitlesDo) Not(conds ...gen.Condition) *systemTitlesDo {
return s.withDO(s.DO.Not(conds...))
}
func (s systemTitlesDo) Or(conds ...gen.Condition) *systemTitlesDo {
return s.withDO(s.DO.Or(conds...))
}
func (s systemTitlesDo) Select(conds ...field.Expr) *systemTitlesDo {
return s.withDO(s.DO.Select(conds...))
}
func (s systemTitlesDo) Where(conds ...gen.Condition) *systemTitlesDo {
return s.withDO(s.DO.Where(conds...))
}
func (s systemTitlesDo) Order(conds ...field.Expr) *systemTitlesDo {
return s.withDO(s.DO.Order(conds...))
}
func (s systemTitlesDo) Distinct(cols ...field.Expr) *systemTitlesDo {
return s.withDO(s.DO.Distinct(cols...))
}
func (s systemTitlesDo) Omit(cols ...field.Expr) *systemTitlesDo {
return s.withDO(s.DO.Omit(cols...))
}
func (s systemTitlesDo) Join(table schema.Tabler, on ...field.Expr) *systemTitlesDo {
return s.withDO(s.DO.Join(table, on...))
}
func (s systemTitlesDo) LeftJoin(table schema.Tabler, on ...field.Expr) *systemTitlesDo {
return s.withDO(s.DO.LeftJoin(table, on...))
}
func (s systemTitlesDo) RightJoin(table schema.Tabler, on ...field.Expr) *systemTitlesDo {
return s.withDO(s.DO.RightJoin(table, on...))
}
func (s systemTitlesDo) Group(cols ...field.Expr) *systemTitlesDo {
return s.withDO(s.DO.Group(cols...))
}
func (s systemTitlesDo) Having(conds ...gen.Condition) *systemTitlesDo {
return s.withDO(s.DO.Having(conds...))
}
func (s systemTitlesDo) Limit(limit int) *systemTitlesDo {
return s.withDO(s.DO.Limit(limit))
}
func (s systemTitlesDo) Offset(offset int) *systemTitlesDo {
return s.withDO(s.DO.Offset(offset))
}
func (s systemTitlesDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *systemTitlesDo {
return s.withDO(s.DO.Scopes(funcs...))
}
func (s systemTitlesDo) Unscoped() *systemTitlesDo {
return s.withDO(s.DO.Unscoped())
}
func (s systemTitlesDo) Create(values ...*model.SystemTitles) error {
if len(values) == 0 {
return nil
}
return s.DO.Create(values)
}
func (s systemTitlesDo) CreateInBatches(values []*model.SystemTitles, batchSize int) error {
return s.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 (s systemTitlesDo) Save(values ...*model.SystemTitles) error {
if len(values) == 0 {
return nil
}
return s.DO.Save(values)
}
func (s systemTitlesDo) First() (*model.SystemTitles, error) {
if result, err := s.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.SystemTitles), nil
}
}
func (s systemTitlesDo) Take() (*model.SystemTitles, error) {
if result, err := s.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.SystemTitles), nil
}
}
func (s systemTitlesDo) Last() (*model.SystemTitles, error) {
if result, err := s.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.SystemTitles), nil
}
}
func (s systemTitlesDo) Find() ([]*model.SystemTitles, error) {
result, err := s.DO.Find()
return result.([]*model.SystemTitles), err
}
func (s systemTitlesDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.SystemTitles, err error) {
buf := make([]*model.SystemTitles, 0, batchSize)
err = s.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 (s systemTitlesDo) FindInBatches(result *[]*model.SystemTitles, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return s.DO.FindInBatches(result, batchSize, fc)
}
func (s systemTitlesDo) Attrs(attrs ...field.AssignExpr) *systemTitlesDo {
return s.withDO(s.DO.Attrs(attrs...))
}
func (s systemTitlesDo) Assign(attrs ...field.AssignExpr) *systemTitlesDo {
return s.withDO(s.DO.Assign(attrs...))
}
func (s systemTitlesDo) Joins(fields ...field.RelationField) *systemTitlesDo {
for _, _f := range fields {
s = *s.withDO(s.DO.Joins(_f))
}
return &s
}
func (s systemTitlesDo) Preload(fields ...field.RelationField) *systemTitlesDo {
for _, _f := range fields {
s = *s.withDO(s.DO.Preload(_f))
}
return &s
}
func (s systemTitlesDo) FirstOrInit() (*model.SystemTitles, error) {
if result, err := s.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.SystemTitles), nil
}
}
func (s systemTitlesDo) FirstOrCreate() (*model.SystemTitles, error) {
if result, err := s.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.SystemTitles), nil
}
}
func (s systemTitlesDo) FindByPage(offset int, limit int) (result []*model.SystemTitles, count int64, err error) {
result, err = s.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 = s.Offset(-1).Limit(-1).Count()
return
}
func (s systemTitlesDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = s.Count()
if err != nil {
return
}
err = s.Offset(offset).Limit(limit).Scan(result)
return
}
func (s systemTitlesDo) Scan(result interface{}) (err error) {
return s.DO.Scan(result)
}
func (s systemTitlesDo) Delete(models ...*model.SystemTitles) (result gen.ResultInfo, err error) {
return s.DO.Delete(models)
}
func (s *systemTitlesDo) withDO(do gen.Dao) *systemTitlesDo {
s.DO = *do.(*gen.DO)
return s
}