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: 添加道具卡测试脚本
352 lines
8.6 KiB
Go
352 lines
8.6 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 newRoles(db *gorm.DB, opts ...gen.DOOption) roles {
|
|
_roles := roles{}
|
|
|
|
_roles.rolesDo.UseDB(db, opts...)
|
|
_roles.rolesDo.UseModel(&model.Roles{})
|
|
|
|
tableName := _roles.rolesDo.TableName()
|
|
_roles.ALL = field.NewAsterisk(tableName)
|
|
_roles.ID = field.NewInt64(tableName, "id")
|
|
_roles.RoleName = field.NewString(tableName, "role_name")
|
|
_roles.RoleCode = field.NewString(tableName, "role_code")
|
|
_roles.Description = field.NewString(tableName, "description")
|
|
_roles.Enabled = field.NewBool(tableName, "enabled")
|
|
_roles.CreatedUser = field.NewString(tableName, "created_user")
|
|
_roles.UpdatedUser = field.NewString(tableName, "updated_user")
|
|
_roles.CreatedAt = field.NewTime(tableName, "created_at")
|
|
_roles.UpdatedAt = field.NewTime(tableName, "updated_at")
|
|
|
|
_roles.fillFieldMap()
|
|
|
|
return _roles
|
|
}
|
|
|
|
type roles struct {
|
|
rolesDo
|
|
|
|
ALL field.Asterisk
|
|
ID field.Int64
|
|
RoleName field.String
|
|
RoleCode field.String
|
|
Description field.String
|
|
Enabled field.Bool
|
|
CreatedUser field.String
|
|
UpdatedUser field.String
|
|
CreatedAt field.Time
|
|
UpdatedAt field.Time
|
|
|
|
fieldMap map[string]field.Expr
|
|
}
|
|
|
|
func (r roles) Table(newTableName string) *roles {
|
|
r.rolesDo.UseTable(newTableName)
|
|
return r.updateTableName(newTableName)
|
|
}
|
|
|
|
func (r roles) As(alias string) *roles {
|
|
r.rolesDo.DO = *(r.rolesDo.As(alias).(*gen.DO))
|
|
return r.updateTableName(alias)
|
|
}
|
|
|
|
func (r *roles) updateTableName(table string) *roles {
|
|
r.ALL = field.NewAsterisk(table)
|
|
r.ID = field.NewInt64(table, "id")
|
|
r.RoleName = field.NewString(table, "role_name")
|
|
r.RoleCode = field.NewString(table, "role_code")
|
|
r.Description = field.NewString(table, "description")
|
|
r.Enabled = field.NewBool(table, "enabled")
|
|
r.CreatedUser = field.NewString(table, "created_user")
|
|
r.UpdatedUser = field.NewString(table, "updated_user")
|
|
r.CreatedAt = field.NewTime(table, "created_at")
|
|
r.UpdatedAt = field.NewTime(table, "updated_at")
|
|
|
|
r.fillFieldMap()
|
|
|
|
return r
|
|
}
|
|
|
|
func (r *roles) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
|
_f, ok := r.fieldMap[fieldName]
|
|
if !ok || _f == nil {
|
|
return nil, false
|
|
}
|
|
_oe, ok := _f.(field.OrderExpr)
|
|
return _oe, ok
|
|
}
|
|
|
|
func (r *roles) fillFieldMap() {
|
|
r.fieldMap = make(map[string]field.Expr, 9)
|
|
r.fieldMap["id"] = r.ID
|
|
r.fieldMap["role_name"] = r.RoleName
|
|
r.fieldMap["role_code"] = r.RoleCode
|
|
r.fieldMap["description"] = r.Description
|
|
r.fieldMap["enabled"] = r.Enabled
|
|
r.fieldMap["created_user"] = r.CreatedUser
|
|
r.fieldMap["updated_user"] = r.UpdatedUser
|
|
r.fieldMap["created_at"] = r.CreatedAt
|
|
r.fieldMap["updated_at"] = r.UpdatedAt
|
|
}
|
|
|
|
func (r roles) clone(db *gorm.DB) roles {
|
|
r.rolesDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
return r
|
|
}
|
|
|
|
func (r roles) replaceDB(db *gorm.DB) roles {
|
|
r.rolesDo.ReplaceDB(db)
|
|
return r
|
|
}
|
|
|
|
type rolesDo struct{ gen.DO }
|
|
|
|
func (r rolesDo) Debug() *rolesDo {
|
|
return r.withDO(r.DO.Debug())
|
|
}
|
|
|
|
func (r rolesDo) WithContext(ctx context.Context) *rolesDo {
|
|
return r.withDO(r.DO.WithContext(ctx))
|
|
}
|
|
|
|
func (r rolesDo) ReadDB() *rolesDo {
|
|
return r.Clauses(dbresolver.Read)
|
|
}
|
|
|
|
func (r rolesDo) WriteDB() *rolesDo {
|
|
return r.Clauses(dbresolver.Write)
|
|
}
|
|
|
|
func (r rolesDo) Session(config *gorm.Session) *rolesDo {
|
|
return r.withDO(r.DO.Session(config))
|
|
}
|
|
|
|
func (r rolesDo) Clauses(conds ...clause.Expression) *rolesDo {
|
|
return r.withDO(r.DO.Clauses(conds...))
|
|
}
|
|
|
|
func (r rolesDo) Returning(value interface{}, columns ...string) *rolesDo {
|
|
return r.withDO(r.DO.Returning(value, columns...))
|
|
}
|
|
|
|
func (r rolesDo) Not(conds ...gen.Condition) *rolesDo {
|
|
return r.withDO(r.DO.Not(conds...))
|
|
}
|
|
|
|
func (r rolesDo) Or(conds ...gen.Condition) *rolesDo {
|
|
return r.withDO(r.DO.Or(conds...))
|
|
}
|
|
|
|
func (r rolesDo) Select(conds ...field.Expr) *rolesDo {
|
|
return r.withDO(r.DO.Select(conds...))
|
|
}
|
|
|
|
func (r rolesDo) Where(conds ...gen.Condition) *rolesDo {
|
|
return r.withDO(r.DO.Where(conds...))
|
|
}
|
|
|
|
func (r rolesDo) Order(conds ...field.Expr) *rolesDo {
|
|
return r.withDO(r.DO.Order(conds...))
|
|
}
|
|
|
|
func (r rolesDo) Distinct(cols ...field.Expr) *rolesDo {
|
|
return r.withDO(r.DO.Distinct(cols...))
|
|
}
|
|
|
|
func (r rolesDo) Omit(cols ...field.Expr) *rolesDo {
|
|
return r.withDO(r.DO.Omit(cols...))
|
|
}
|
|
|
|
func (r rolesDo) Join(table schema.Tabler, on ...field.Expr) *rolesDo {
|
|
return r.withDO(r.DO.Join(table, on...))
|
|
}
|
|
|
|
func (r rolesDo) LeftJoin(table schema.Tabler, on ...field.Expr) *rolesDo {
|
|
return r.withDO(r.DO.LeftJoin(table, on...))
|
|
}
|
|
|
|
func (r rolesDo) RightJoin(table schema.Tabler, on ...field.Expr) *rolesDo {
|
|
return r.withDO(r.DO.RightJoin(table, on...))
|
|
}
|
|
|
|
func (r rolesDo) Group(cols ...field.Expr) *rolesDo {
|
|
return r.withDO(r.DO.Group(cols...))
|
|
}
|
|
|
|
func (r rolesDo) Having(conds ...gen.Condition) *rolesDo {
|
|
return r.withDO(r.DO.Having(conds...))
|
|
}
|
|
|
|
func (r rolesDo) Limit(limit int) *rolesDo {
|
|
return r.withDO(r.DO.Limit(limit))
|
|
}
|
|
|
|
func (r rolesDo) Offset(offset int) *rolesDo {
|
|
return r.withDO(r.DO.Offset(offset))
|
|
}
|
|
|
|
func (r rolesDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *rolesDo {
|
|
return r.withDO(r.DO.Scopes(funcs...))
|
|
}
|
|
|
|
func (r rolesDo) Unscoped() *rolesDo {
|
|
return r.withDO(r.DO.Unscoped())
|
|
}
|
|
|
|
func (r rolesDo) Create(values ...*model.Roles) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return r.DO.Create(values)
|
|
}
|
|
|
|
func (r rolesDo) CreateInBatches(values []*model.Roles, batchSize int) error {
|
|
return r.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 (r rolesDo) Save(values ...*model.Roles) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return r.DO.Save(values)
|
|
}
|
|
|
|
func (r rolesDo) First() (*model.Roles, error) {
|
|
if result, err := r.DO.First(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.Roles), nil
|
|
}
|
|
}
|
|
|
|
func (r rolesDo) Take() (*model.Roles, error) {
|
|
if result, err := r.DO.Take(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.Roles), nil
|
|
}
|
|
}
|
|
|
|
func (r rolesDo) Last() (*model.Roles, error) {
|
|
if result, err := r.DO.Last(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.Roles), nil
|
|
}
|
|
}
|
|
|
|
func (r rolesDo) Find() ([]*model.Roles, error) {
|
|
result, err := r.DO.Find()
|
|
return result.([]*model.Roles), err
|
|
}
|
|
|
|
func (r rolesDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Roles, err error) {
|
|
buf := make([]*model.Roles, 0, batchSize)
|
|
err = r.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 (r rolesDo) FindInBatches(result *[]*model.Roles, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
return r.DO.FindInBatches(result, batchSize, fc)
|
|
}
|
|
|
|
func (r rolesDo) Attrs(attrs ...field.AssignExpr) *rolesDo {
|
|
return r.withDO(r.DO.Attrs(attrs...))
|
|
}
|
|
|
|
func (r rolesDo) Assign(attrs ...field.AssignExpr) *rolesDo {
|
|
return r.withDO(r.DO.Assign(attrs...))
|
|
}
|
|
|
|
func (r rolesDo) Joins(fields ...field.RelationField) *rolesDo {
|
|
for _, _f := range fields {
|
|
r = *r.withDO(r.DO.Joins(_f))
|
|
}
|
|
return &r
|
|
}
|
|
|
|
func (r rolesDo) Preload(fields ...field.RelationField) *rolesDo {
|
|
for _, _f := range fields {
|
|
r = *r.withDO(r.DO.Preload(_f))
|
|
}
|
|
return &r
|
|
}
|
|
|
|
func (r rolesDo) FirstOrInit() (*model.Roles, error) {
|
|
if result, err := r.DO.FirstOrInit(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.Roles), nil
|
|
}
|
|
}
|
|
|
|
func (r rolesDo) FirstOrCreate() (*model.Roles, error) {
|
|
if result, err := r.DO.FirstOrCreate(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.Roles), nil
|
|
}
|
|
}
|
|
|
|
func (r rolesDo) FindByPage(offset int, limit int) (result []*model.Roles, count int64, err error) {
|
|
result, err = r.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 = r.Offset(-1).Limit(-1).Count()
|
|
return
|
|
}
|
|
|
|
func (r rolesDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
|
count, err = r.Count()
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
err = r.Offset(offset).Limit(limit).Scan(result)
|
|
return
|
|
}
|
|
|
|
func (r rolesDo) Scan(result interface{}) (err error) {
|
|
return r.DO.Scan(result)
|
|
}
|
|
|
|
func (r rolesDo) Delete(models ...*model.Roles) (result gen.ResultInfo, err error) {
|
|
return r.DO.Delete(models)
|
|
}
|
|
|
|
func (r *rolesDo) withDO(do gen.Dao) *rolesDo {
|
|
r.DO = *do.(*gen.DO)
|
|
return r
|
|
}
|