first commit

This commit is contained in:
Yangtao
2025-11-18 17:48:20 +08:00
commit 6e56cab848
196 changed files with 65809 additions and 0 deletions

View File

@ -0,0 +1,453 @@
// 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 repo
import (
"context"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
"servicebase/pkg/model"
)
func newAdminPrivilege(db *gorm.DB, opts ...gen.DOOption) adminPrivilege {
_adminPrivilege := adminPrivilege{}
_adminPrivilege.adminPrivilegeDo.UseDB(db, opts...)
_adminPrivilege.adminPrivilegeDo.UseModel(&model.AdminPrivilege{})
tableName := _adminPrivilege.adminPrivilegeDo.TableName()
_adminPrivilege.ALL = field.NewAsterisk(tableName)
_adminPrivilege.ID = field.NewString(tableName, "id")
_adminPrivilege.TenantID = field.NewString(tableName, "tenant_id")
_adminPrivilege.ScopeID = field.NewString(tableName, "scope_id")
_adminPrivilege.ParentID = field.NewString(tableName, "parent_id")
_adminPrivilege.Code = field.NewString(tableName, "code")
_adminPrivilege.Name = field.NewString(tableName, "name")
_adminPrivilege.Level = field.NewInt32(tableName, "level")
_adminPrivilege.SourceType = field.NewString(tableName, "source_type")
_adminPrivilege.TargetType = field.NewString(tableName, "target_type")
_adminPrivilege.Target = field.NewString(tableName, "target")
_adminPrivilege.Desc = field.NewString(tableName, "desc")
_adminPrivilege.DeleteAt = field.NewField(tableName, "delete_at")
_adminPrivilege.CreateAt = field.NewTime(tableName, "create_at")
_adminPrivilege.CreateBy = field.NewString(tableName, "create_by")
_adminPrivilege.UpdateAt = field.NewTime(tableName, "update_at")
_adminPrivilege.UpdateBy = field.NewString(tableName, "update_by")
_adminPrivilege.fillFieldMap()
return _adminPrivilege
}
// adminPrivilege 租户-权限表
type adminPrivilege struct {
adminPrivilegeDo adminPrivilegeDo
ALL field.Asterisk
ID field.String // 业务ID
TenantID field.String // 企业ID
ScopeID field.String // 范围
ParentID field.String // 父ID
Code field.String // 代码
Name field.String // 权限名称
Level field.Int32 // 权限级别
SourceType field.String // 类型resource、interface等
TargetType field.String
Target field.String // 权限值 resource:菜单路径; api=url-pre
Desc field.String // 描述
DeleteAt field.Field // del标志
CreateAt field.Time // 创建时间
CreateBy field.String // 创建人
UpdateAt field.Time // 更新时间
UpdateBy field.String // 更新人
fieldMap map[string]field.Expr
}
func (a adminPrivilege) Table(newTableName string) *adminPrivilege {
a.adminPrivilegeDo.UseTable(newTableName)
return a.updateTableName(newTableName)
}
func (a adminPrivilege) As(alias string) *adminPrivilege {
a.adminPrivilegeDo.DO = *(a.adminPrivilegeDo.As(alias).(*gen.DO))
return a.updateTableName(alias)
}
func (a *adminPrivilege) updateTableName(table string) *adminPrivilege {
a.ALL = field.NewAsterisk(table)
a.ID = field.NewString(table, "id")
a.TenantID = field.NewString(table, "tenant_id")
a.ScopeID = field.NewString(table, "scope_id")
a.ParentID = field.NewString(table, "parent_id")
a.Code = field.NewString(table, "code")
a.Name = field.NewString(table, "name")
a.Level = field.NewInt32(table, "level")
a.SourceType = field.NewString(table, "source_type")
a.TargetType = field.NewString(table, "target_type")
a.Target = field.NewString(table, "target")
a.Desc = field.NewString(table, "desc")
a.DeleteAt = field.NewField(table, "delete_at")
a.CreateAt = field.NewTime(table, "create_at")
a.CreateBy = field.NewString(table, "create_by")
a.UpdateAt = field.NewTime(table, "update_at")
a.UpdateBy = field.NewString(table, "update_by")
a.fillFieldMap()
return a
}
func (a *adminPrivilege) WithContext(ctx context.Context) IAdminPrivilegeDo {
return a.adminPrivilegeDo.WithContext(ctx)
}
func (a adminPrivilege) TableName() string { return a.adminPrivilegeDo.TableName() }
func (a adminPrivilege) Alias() string { return a.adminPrivilegeDo.Alias() }
func (a adminPrivilege) Columns(cols ...field.Expr) gen.Columns {
return a.adminPrivilegeDo.Columns(cols...)
}
func (a *adminPrivilege) 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 *adminPrivilege) fillFieldMap() {
a.fieldMap = make(map[string]field.Expr, 16)
a.fieldMap["id"] = a.ID
a.fieldMap["tenant_id"] = a.TenantID
a.fieldMap["scope_id"] = a.ScopeID
a.fieldMap["parent_id"] = a.ParentID
a.fieldMap["code"] = a.Code
a.fieldMap["name"] = a.Name
a.fieldMap["level"] = a.Level
a.fieldMap["source_type"] = a.SourceType
a.fieldMap["target_type"] = a.TargetType
a.fieldMap["target"] = a.Target
a.fieldMap["desc"] = a.Desc
a.fieldMap["delete_at"] = a.DeleteAt
a.fieldMap["create_at"] = a.CreateAt
a.fieldMap["create_by"] = a.CreateBy
a.fieldMap["update_at"] = a.UpdateAt
a.fieldMap["update_by"] = a.UpdateBy
}
func (a adminPrivilege) clone(db *gorm.DB) adminPrivilege {
a.adminPrivilegeDo.ReplaceConnPool(db.Statement.ConnPool)
return a
}
func (a adminPrivilege) replaceDB(db *gorm.DB) adminPrivilege {
a.adminPrivilegeDo.ReplaceDB(db)
return a
}
type adminPrivilegeDo struct{ gen.DO }
type IAdminPrivilegeDo interface {
gen.SubQuery
Debug() IAdminPrivilegeDo
WithContext(ctx context.Context) IAdminPrivilegeDo
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
ReplaceDB(db *gorm.DB)
ReadDB() IAdminPrivilegeDo
WriteDB() IAdminPrivilegeDo
As(alias string) gen.Dao
Session(config *gorm.Session) IAdminPrivilegeDo
Columns(cols ...field.Expr) gen.Columns
Clauses(conds ...clause.Expression) IAdminPrivilegeDo
Not(conds ...gen.Condition) IAdminPrivilegeDo
Or(conds ...gen.Condition) IAdminPrivilegeDo
Select(conds ...field.Expr) IAdminPrivilegeDo
Where(conds ...gen.Condition) IAdminPrivilegeDo
Order(conds ...field.Expr) IAdminPrivilegeDo
Distinct(cols ...field.Expr) IAdminPrivilegeDo
Omit(cols ...field.Expr) IAdminPrivilegeDo
Join(table schema.Tabler, on ...field.Expr) IAdminPrivilegeDo
LeftJoin(table schema.Tabler, on ...field.Expr) IAdminPrivilegeDo
RightJoin(table schema.Tabler, on ...field.Expr) IAdminPrivilegeDo
Group(cols ...field.Expr) IAdminPrivilegeDo
Having(conds ...gen.Condition) IAdminPrivilegeDo
Limit(limit int) IAdminPrivilegeDo
Offset(offset int) IAdminPrivilegeDo
Count() (count int64, err error)
Scopes(funcs ...func(gen.Dao) gen.Dao) IAdminPrivilegeDo
Unscoped() IAdminPrivilegeDo
Create(values ...*model.AdminPrivilege) error
CreateInBatches(values []*model.AdminPrivilege, batchSize int) error
Save(values ...*model.AdminPrivilege) error
First() (*model.AdminPrivilege, error)
Take() (*model.AdminPrivilege, error)
Last() (*model.AdminPrivilege, error)
Find() ([]*model.AdminPrivilege, error)
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AdminPrivilege, err error)
FindInBatches(result *[]*model.AdminPrivilege, batchSize int, fc func(tx gen.Dao, batch int) error) error
Pluck(column field.Expr, dest interface{}) error
Delete(...*model.AdminPrivilege) (info gen.ResultInfo, err error)
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
Updates(value interface{}) (info gen.ResultInfo, err error)
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
UpdateFrom(q gen.SubQuery) gen.Dao
Attrs(attrs ...field.AssignExpr) IAdminPrivilegeDo
Assign(attrs ...field.AssignExpr) IAdminPrivilegeDo
Joins(fields ...field.RelationField) IAdminPrivilegeDo
Preload(fields ...field.RelationField) IAdminPrivilegeDo
FirstOrInit() (*model.AdminPrivilege, error)
FirstOrCreate() (*model.AdminPrivilege, error)
FindByPage(offset int, limit int) (result []*model.AdminPrivilege, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IAdminPrivilegeDo
UnderlyingDB() *gorm.DB
schema.Tabler
}
func (a adminPrivilegeDo) Debug() IAdminPrivilegeDo {
return a.withDO(a.DO.Debug())
}
func (a adminPrivilegeDo) WithContext(ctx context.Context) IAdminPrivilegeDo {
return a.withDO(a.DO.WithContext(ctx))
}
func (a adminPrivilegeDo) ReadDB() IAdminPrivilegeDo {
return a.Clauses(dbresolver.Read)
}
func (a adminPrivilegeDo) WriteDB() IAdminPrivilegeDo {
return a.Clauses(dbresolver.Write)
}
func (a adminPrivilegeDo) Session(config *gorm.Session) IAdminPrivilegeDo {
return a.withDO(a.DO.Session(config))
}
func (a adminPrivilegeDo) Clauses(conds ...clause.Expression) IAdminPrivilegeDo {
return a.withDO(a.DO.Clauses(conds...))
}
func (a adminPrivilegeDo) Returning(value interface{}, columns ...string) IAdminPrivilegeDo {
return a.withDO(a.DO.Returning(value, columns...))
}
func (a adminPrivilegeDo) Not(conds ...gen.Condition) IAdminPrivilegeDo {
return a.withDO(a.DO.Not(conds...))
}
func (a adminPrivilegeDo) Or(conds ...gen.Condition) IAdminPrivilegeDo {
return a.withDO(a.DO.Or(conds...))
}
func (a adminPrivilegeDo) Select(conds ...field.Expr) IAdminPrivilegeDo {
return a.withDO(a.DO.Select(conds...))
}
func (a adminPrivilegeDo) Where(conds ...gen.Condition) IAdminPrivilegeDo {
return a.withDO(a.DO.Where(conds...))
}
func (a adminPrivilegeDo) Order(conds ...field.Expr) IAdminPrivilegeDo {
return a.withDO(a.DO.Order(conds...))
}
func (a adminPrivilegeDo) Distinct(cols ...field.Expr) IAdminPrivilegeDo {
return a.withDO(a.DO.Distinct(cols...))
}
func (a adminPrivilegeDo) Omit(cols ...field.Expr) IAdminPrivilegeDo {
return a.withDO(a.DO.Omit(cols...))
}
func (a adminPrivilegeDo) Join(table schema.Tabler, on ...field.Expr) IAdminPrivilegeDo {
return a.withDO(a.DO.Join(table, on...))
}
func (a adminPrivilegeDo) LeftJoin(table schema.Tabler, on ...field.Expr) IAdminPrivilegeDo {
return a.withDO(a.DO.LeftJoin(table, on...))
}
func (a adminPrivilegeDo) RightJoin(table schema.Tabler, on ...field.Expr) IAdminPrivilegeDo {
return a.withDO(a.DO.RightJoin(table, on...))
}
func (a adminPrivilegeDo) Group(cols ...field.Expr) IAdminPrivilegeDo {
return a.withDO(a.DO.Group(cols...))
}
func (a adminPrivilegeDo) Having(conds ...gen.Condition) IAdminPrivilegeDo {
return a.withDO(a.DO.Having(conds...))
}
func (a adminPrivilegeDo) Limit(limit int) IAdminPrivilegeDo {
return a.withDO(a.DO.Limit(limit))
}
func (a adminPrivilegeDo) Offset(offset int) IAdminPrivilegeDo {
return a.withDO(a.DO.Offset(offset))
}
func (a adminPrivilegeDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IAdminPrivilegeDo {
return a.withDO(a.DO.Scopes(funcs...))
}
func (a adminPrivilegeDo) Unscoped() IAdminPrivilegeDo {
return a.withDO(a.DO.Unscoped())
}
func (a adminPrivilegeDo) Create(values ...*model.AdminPrivilege) error {
if len(values) == 0 {
return nil
}
return a.DO.Create(values)
}
func (a adminPrivilegeDo) CreateInBatches(values []*model.AdminPrivilege, 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 adminPrivilegeDo) Save(values ...*model.AdminPrivilege) error {
if len(values) == 0 {
return nil
}
return a.DO.Save(values)
}
func (a adminPrivilegeDo) First() (*model.AdminPrivilege, error) {
if result, err := a.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.AdminPrivilege), nil
}
}
func (a adminPrivilegeDo) Take() (*model.AdminPrivilege, error) {
if result, err := a.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.AdminPrivilege), nil
}
}
func (a adminPrivilegeDo) Last() (*model.AdminPrivilege, error) {
if result, err := a.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.AdminPrivilege), nil
}
}
func (a adminPrivilegeDo) Find() ([]*model.AdminPrivilege, error) {
result, err := a.DO.Find()
return result.([]*model.AdminPrivilege), err
}
func (a adminPrivilegeDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AdminPrivilege, err error) {
buf := make([]*model.AdminPrivilege, 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 adminPrivilegeDo) FindInBatches(result *[]*model.AdminPrivilege, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return a.DO.FindInBatches(result, batchSize, fc)
}
func (a adminPrivilegeDo) Attrs(attrs ...field.AssignExpr) IAdminPrivilegeDo {
return a.withDO(a.DO.Attrs(attrs...))
}
func (a adminPrivilegeDo) Assign(attrs ...field.AssignExpr) IAdminPrivilegeDo {
return a.withDO(a.DO.Assign(attrs...))
}
func (a adminPrivilegeDo) Joins(fields ...field.RelationField) IAdminPrivilegeDo {
for _, _f := range fields {
a = *a.withDO(a.DO.Joins(_f))
}
return &a
}
func (a adminPrivilegeDo) Preload(fields ...field.RelationField) IAdminPrivilegeDo {
for _, _f := range fields {
a = *a.withDO(a.DO.Preload(_f))
}
return &a
}
func (a adminPrivilegeDo) FirstOrInit() (*model.AdminPrivilege, error) {
if result, err := a.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.AdminPrivilege), nil
}
}
func (a adminPrivilegeDo) FirstOrCreate() (*model.AdminPrivilege, error) {
if result, err := a.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.AdminPrivilege), nil
}
}
func (a adminPrivilegeDo) FindByPage(offset int, limit int) (result []*model.AdminPrivilege, 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 adminPrivilegeDo) 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 adminPrivilegeDo) Scan(result interface{}) (err error) {
return a.DO.Scan(result)
}
func (a adminPrivilegeDo) Delete(models ...*model.AdminPrivilege) (result gen.ResultInfo, err error) {
return a.DO.Delete(models)
}
func (a *adminPrivilegeDo) withDO(do gen.Dao) *adminPrivilegeDo {
a.DO = *do.(*gen.DO)
return a
}

431
pkg/repo/admin_role.gen.go Normal file
View File

@ -0,0 +1,431 @@
// 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 repo
import (
"context"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
"servicebase/pkg/model"
)
func newAdminRole(db *gorm.DB, opts ...gen.DOOption) adminRole {
_adminRole := adminRole{}
_adminRole.adminRoleDo.UseDB(db, opts...)
_adminRole.adminRoleDo.UseModel(&model.AdminRole{})
tableName := _adminRole.adminRoleDo.TableName()
_adminRole.ALL = field.NewAsterisk(tableName)
_adminRole.ID = field.NewString(tableName, "id")
_adminRole.TenantID = field.NewString(tableName, "tenant_id")
_adminRole.ScopeID = field.NewString(tableName, "scope_id")
_adminRole.Code = field.NewString(tableName, "code")
_adminRole.Name = field.NewString(tableName, "name")
_adminRole.Desc = field.NewString(tableName, "desc")
_adminRole.DeleteAt = field.NewField(tableName, "delete_at")
_adminRole.CreateAt = field.NewTime(tableName, "create_at")
_adminRole.CreateBy = field.NewString(tableName, "create_by")
_adminRole.UpdateAt = field.NewTime(tableName, "update_at")
_adminRole.UpdateBy = field.NewString(tableName, "update_by")
_adminRole.fillFieldMap()
return _adminRole
}
// adminRole 租户-角色表
type adminRole struct {
adminRoleDo adminRoleDo
ALL field.Asterisk
ID field.String // 业务ID
TenantID field.String // 企业ID
ScopeID field.String // 角色范围
Code field.String // 代码
Name field.String
Desc field.String // 描述
DeleteAt field.Field // del标志
CreateAt field.Time // 创建时间
CreateBy field.String // 创建人
UpdateAt field.Time // 更新时间
UpdateBy field.String // 更新人
fieldMap map[string]field.Expr
}
func (a adminRole) Table(newTableName string) *adminRole {
a.adminRoleDo.UseTable(newTableName)
return a.updateTableName(newTableName)
}
func (a adminRole) As(alias string) *adminRole {
a.adminRoleDo.DO = *(a.adminRoleDo.As(alias).(*gen.DO))
return a.updateTableName(alias)
}
func (a *adminRole) updateTableName(table string) *adminRole {
a.ALL = field.NewAsterisk(table)
a.ID = field.NewString(table, "id")
a.TenantID = field.NewString(table, "tenant_id")
a.ScopeID = field.NewString(table, "scope_id")
a.Code = field.NewString(table, "code")
a.Name = field.NewString(table, "name")
a.Desc = field.NewString(table, "desc")
a.DeleteAt = field.NewField(table, "delete_at")
a.CreateAt = field.NewTime(table, "create_at")
a.CreateBy = field.NewString(table, "create_by")
a.UpdateAt = field.NewTime(table, "update_at")
a.UpdateBy = field.NewString(table, "update_by")
a.fillFieldMap()
return a
}
func (a *adminRole) WithContext(ctx context.Context) IAdminRoleDo {
return a.adminRoleDo.WithContext(ctx)
}
func (a adminRole) TableName() string { return a.adminRoleDo.TableName() }
func (a adminRole) Alias() string { return a.adminRoleDo.Alias() }
func (a adminRole) Columns(cols ...field.Expr) gen.Columns { return a.adminRoleDo.Columns(cols...) }
func (a *adminRole) 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 *adminRole) fillFieldMap() {
a.fieldMap = make(map[string]field.Expr, 11)
a.fieldMap["id"] = a.ID
a.fieldMap["tenant_id"] = a.TenantID
a.fieldMap["scope_id"] = a.ScopeID
a.fieldMap["code"] = a.Code
a.fieldMap["name"] = a.Name
a.fieldMap["desc"] = a.Desc
a.fieldMap["delete_at"] = a.DeleteAt
a.fieldMap["create_at"] = a.CreateAt
a.fieldMap["create_by"] = a.CreateBy
a.fieldMap["update_at"] = a.UpdateAt
a.fieldMap["update_by"] = a.UpdateBy
}
func (a adminRole) clone(db *gorm.DB) adminRole {
a.adminRoleDo.ReplaceConnPool(db.Statement.ConnPool)
return a
}
func (a adminRole) replaceDB(db *gorm.DB) adminRole {
a.adminRoleDo.ReplaceDB(db)
return a
}
type adminRoleDo struct{ gen.DO }
type IAdminRoleDo interface {
gen.SubQuery
Debug() IAdminRoleDo
WithContext(ctx context.Context) IAdminRoleDo
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
ReplaceDB(db *gorm.DB)
ReadDB() IAdminRoleDo
WriteDB() IAdminRoleDo
As(alias string) gen.Dao
Session(config *gorm.Session) IAdminRoleDo
Columns(cols ...field.Expr) gen.Columns
Clauses(conds ...clause.Expression) IAdminRoleDo
Not(conds ...gen.Condition) IAdminRoleDo
Or(conds ...gen.Condition) IAdminRoleDo
Select(conds ...field.Expr) IAdminRoleDo
Where(conds ...gen.Condition) IAdminRoleDo
Order(conds ...field.Expr) IAdminRoleDo
Distinct(cols ...field.Expr) IAdminRoleDo
Omit(cols ...field.Expr) IAdminRoleDo
Join(table schema.Tabler, on ...field.Expr) IAdminRoleDo
LeftJoin(table schema.Tabler, on ...field.Expr) IAdminRoleDo
RightJoin(table schema.Tabler, on ...field.Expr) IAdminRoleDo
Group(cols ...field.Expr) IAdminRoleDo
Having(conds ...gen.Condition) IAdminRoleDo
Limit(limit int) IAdminRoleDo
Offset(offset int) IAdminRoleDo
Count() (count int64, err error)
Scopes(funcs ...func(gen.Dao) gen.Dao) IAdminRoleDo
Unscoped() IAdminRoleDo
Create(values ...*model.AdminRole) error
CreateInBatches(values []*model.AdminRole, batchSize int) error
Save(values ...*model.AdminRole) error
First() (*model.AdminRole, error)
Take() (*model.AdminRole, error)
Last() (*model.AdminRole, error)
Find() ([]*model.AdminRole, error)
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AdminRole, err error)
FindInBatches(result *[]*model.AdminRole, batchSize int, fc func(tx gen.Dao, batch int) error) error
Pluck(column field.Expr, dest interface{}) error
Delete(...*model.AdminRole) (info gen.ResultInfo, err error)
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
Updates(value interface{}) (info gen.ResultInfo, err error)
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
UpdateFrom(q gen.SubQuery) gen.Dao
Attrs(attrs ...field.AssignExpr) IAdminRoleDo
Assign(attrs ...field.AssignExpr) IAdminRoleDo
Joins(fields ...field.RelationField) IAdminRoleDo
Preload(fields ...field.RelationField) IAdminRoleDo
FirstOrInit() (*model.AdminRole, error)
FirstOrCreate() (*model.AdminRole, error)
FindByPage(offset int, limit int) (result []*model.AdminRole, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IAdminRoleDo
UnderlyingDB() *gorm.DB
schema.Tabler
}
func (a adminRoleDo) Debug() IAdminRoleDo {
return a.withDO(a.DO.Debug())
}
func (a adminRoleDo) WithContext(ctx context.Context) IAdminRoleDo {
return a.withDO(a.DO.WithContext(ctx))
}
func (a adminRoleDo) ReadDB() IAdminRoleDo {
return a.Clauses(dbresolver.Read)
}
func (a adminRoleDo) WriteDB() IAdminRoleDo {
return a.Clauses(dbresolver.Write)
}
func (a adminRoleDo) Session(config *gorm.Session) IAdminRoleDo {
return a.withDO(a.DO.Session(config))
}
func (a adminRoleDo) Clauses(conds ...clause.Expression) IAdminRoleDo {
return a.withDO(a.DO.Clauses(conds...))
}
func (a adminRoleDo) Returning(value interface{}, columns ...string) IAdminRoleDo {
return a.withDO(a.DO.Returning(value, columns...))
}
func (a adminRoleDo) Not(conds ...gen.Condition) IAdminRoleDo {
return a.withDO(a.DO.Not(conds...))
}
func (a adminRoleDo) Or(conds ...gen.Condition) IAdminRoleDo {
return a.withDO(a.DO.Or(conds...))
}
func (a adminRoleDo) Select(conds ...field.Expr) IAdminRoleDo {
return a.withDO(a.DO.Select(conds...))
}
func (a adminRoleDo) Where(conds ...gen.Condition) IAdminRoleDo {
return a.withDO(a.DO.Where(conds...))
}
func (a adminRoleDo) Order(conds ...field.Expr) IAdminRoleDo {
return a.withDO(a.DO.Order(conds...))
}
func (a adminRoleDo) Distinct(cols ...field.Expr) IAdminRoleDo {
return a.withDO(a.DO.Distinct(cols...))
}
func (a adminRoleDo) Omit(cols ...field.Expr) IAdminRoleDo {
return a.withDO(a.DO.Omit(cols...))
}
func (a adminRoleDo) Join(table schema.Tabler, on ...field.Expr) IAdminRoleDo {
return a.withDO(a.DO.Join(table, on...))
}
func (a adminRoleDo) LeftJoin(table schema.Tabler, on ...field.Expr) IAdminRoleDo {
return a.withDO(a.DO.LeftJoin(table, on...))
}
func (a adminRoleDo) RightJoin(table schema.Tabler, on ...field.Expr) IAdminRoleDo {
return a.withDO(a.DO.RightJoin(table, on...))
}
func (a adminRoleDo) Group(cols ...field.Expr) IAdminRoleDo {
return a.withDO(a.DO.Group(cols...))
}
func (a adminRoleDo) Having(conds ...gen.Condition) IAdminRoleDo {
return a.withDO(a.DO.Having(conds...))
}
func (a adminRoleDo) Limit(limit int) IAdminRoleDo {
return a.withDO(a.DO.Limit(limit))
}
func (a adminRoleDo) Offset(offset int) IAdminRoleDo {
return a.withDO(a.DO.Offset(offset))
}
func (a adminRoleDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IAdminRoleDo {
return a.withDO(a.DO.Scopes(funcs...))
}
func (a adminRoleDo) Unscoped() IAdminRoleDo {
return a.withDO(a.DO.Unscoped())
}
func (a adminRoleDo) Create(values ...*model.AdminRole) error {
if len(values) == 0 {
return nil
}
return a.DO.Create(values)
}
func (a adminRoleDo) CreateInBatches(values []*model.AdminRole, 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 adminRoleDo) Save(values ...*model.AdminRole) error {
if len(values) == 0 {
return nil
}
return a.DO.Save(values)
}
func (a adminRoleDo) First() (*model.AdminRole, error) {
if result, err := a.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.AdminRole), nil
}
}
func (a adminRoleDo) Take() (*model.AdminRole, error) {
if result, err := a.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.AdminRole), nil
}
}
func (a adminRoleDo) Last() (*model.AdminRole, error) {
if result, err := a.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.AdminRole), nil
}
}
func (a adminRoleDo) Find() ([]*model.AdminRole, error) {
result, err := a.DO.Find()
return result.([]*model.AdminRole), err
}
func (a adminRoleDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AdminRole, err error) {
buf := make([]*model.AdminRole, 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 adminRoleDo) FindInBatches(result *[]*model.AdminRole, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return a.DO.FindInBatches(result, batchSize, fc)
}
func (a adminRoleDo) Attrs(attrs ...field.AssignExpr) IAdminRoleDo {
return a.withDO(a.DO.Attrs(attrs...))
}
func (a adminRoleDo) Assign(attrs ...field.AssignExpr) IAdminRoleDo {
return a.withDO(a.DO.Assign(attrs...))
}
func (a adminRoleDo) Joins(fields ...field.RelationField) IAdminRoleDo {
for _, _f := range fields {
a = *a.withDO(a.DO.Joins(_f))
}
return &a
}
func (a adminRoleDo) Preload(fields ...field.RelationField) IAdminRoleDo {
for _, _f := range fields {
a = *a.withDO(a.DO.Preload(_f))
}
return &a
}
func (a adminRoleDo) FirstOrInit() (*model.AdminRole, error) {
if result, err := a.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.AdminRole), nil
}
}
func (a adminRoleDo) FirstOrCreate() (*model.AdminRole, error) {
if result, err := a.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.AdminRole), nil
}
}
func (a adminRoleDo) FindByPage(offset int, limit int) (result []*model.AdminRole, 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 adminRoleDo) 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 adminRoleDo) Scan(result interface{}) (err error) {
return a.DO.Scan(result)
}
func (a adminRoleDo) Delete(models ...*model.AdminRole) (result gen.ResultInfo, err error) {
return a.DO.Delete(models)
}
func (a *adminRoleDo) withDO(do gen.Dao) *adminRoleDo {
a.DO = *do.(*gen.DO)
return a
}

View File

@ -0,0 +1,429 @@
// 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 repo
import (
"context"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
"servicebase/pkg/model"
)
func newAdminRolePrivilege(db *gorm.DB, opts ...gen.DOOption) adminRolePrivilege {
_adminRolePrivilege := adminRolePrivilege{}
_adminRolePrivilege.adminRolePrivilegeDo.UseDB(db, opts...)
_adminRolePrivilege.adminRolePrivilegeDo.UseModel(&model.AdminRolePrivilege{})
tableName := _adminRolePrivilege.adminRolePrivilegeDo.TableName()
_adminRolePrivilege.ALL = field.NewAsterisk(tableName)
_adminRolePrivilege.ID = field.NewString(tableName, "id")
_adminRolePrivilege.TenantID = field.NewString(tableName, "tenant_id")
_adminRolePrivilege.ScopeID = field.NewString(tableName, "scope_id")
_adminRolePrivilege.RoleID = field.NewString(tableName, "role_id")
_adminRolePrivilege.PrivilegeID = field.NewString(tableName, "privilege_id")
_adminRolePrivilege.DeleteAt = field.NewField(tableName, "delete_at")
_adminRolePrivilege.CreateAt = field.NewTime(tableName, "create_at")
_adminRolePrivilege.CreateBy = field.NewString(tableName, "create_by")
_adminRolePrivilege.UpdateAt = field.NewTime(tableName, "update_at")
_adminRolePrivilege.UpdateBy = field.NewString(tableName, "update_by")
_adminRolePrivilege.fillFieldMap()
return _adminRolePrivilege
}
// adminRolePrivilege 租户角色-权限表
type adminRolePrivilege struct {
adminRolePrivilegeDo adminRolePrivilegeDo
ALL field.Asterisk
ID field.String // 业务ID
TenantID field.String // 企业ID
ScopeID field.String // 范围
RoleID field.String // 角色ID
PrivilegeID field.String // 权限ID
DeleteAt field.Field // del标志
CreateAt field.Time // 创建时间
CreateBy field.String // 创建人
UpdateAt field.Time // 更新时间
UpdateBy field.String // 更新人
fieldMap map[string]field.Expr
}
func (a adminRolePrivilege) Table(newTableName string) *adminRolePrivilege {
a.adminRolePrivilegeDo.UseTable(newTableName)
return a.updateTableName(newTableName)
}
func (a adminRolePrivilege) As(alias string) *adminRolePrivilege {
a.adminRolePrivilegeDo.DO = *(a.adminRolePrivilegeDo.As(alias).(*gen.DO))
return a.updateTableName(alias)
}
func (a *adminRolePrivilege) updateTableName(table string) *adminRolePrivilege {
a.ALL = field.NewAsterisk(table)
a.ID = field.NewString(table, "id")
a.TenantID = field.NewString(table, "tenant_id")
a.ScopeID = field.NewString(table, "scope_id")
a.RoleID = field.NewString(table, "role_id")
a.PrivilegeID = field.NewString(table, "privilege_id")
a.DeleteAt = field.NewField(table, "delete_at")
a.CreateAt = field.NewTime(table, "create_at")
a.CreateBy = field.NewString(table, "create_by")
a.UpdateAt = field.NewTime(table, "update_at")
a.UpdateBy = field.NewString(table, "update_by")
a.fillFieldMap()
return a
}
func (a *adminRolePrivilege) WithContext(ctx context.Context) IAdminRolePrivilegeDo {
return a.adminRolePrivilegeDo.WithContext(ctx)
}
func (a adminRolePrivilege) TableName() string { return a.adminRolePrivilegeDo.TableName() }
func (a adminRolePrivilege) Alias() string { return a.adminRolePrivilegeDo.Alias() }
func (a adminRolePrivilege) Columns(cols ...field.Expr) gen.Columns {
return a.adminRolePrivilegeDo.Columns(cols...)
}
func (a *adminRolePrivilege) 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 *adminRolePrivilege) fillFieldMap() {
a.fieldMap = make(map[string]field.Expr, 10)
a.fieldMap["id"] = a.ID
a.fieldMap["tenant_id"] = a.TenantID
a.fieldMap["scope_id"] = a.ScopeID
a.fieldMap["role_id"] = a.RoleID
a.fieldMap["privilege_id"] = a.PrivilegeID
a.fieldMap["delete_at"] = a.DeleteAt
a.fieldMap["create_at"] = a.CreateAt
a.fieldMap["create_by"] = a.CreateBy
a.fieldMap["update_at"] = a.UpdateAt
a.fieldMap["update_by"] = a.UpdateBy
}
func (a adminRolePrivilege) clone(db *gorm.DB) adminRolePrivilege {
a.adminRolePrivilegeDo.ReplaceConnPool(db.Statement.ConnPool)
return a
}
func (a adminRolePrivilege) replaceDB(db *gorm.DB) adminRolePrivilege {
a.adminRolePrivilegeDo.ReplaceDB(db)
return a
}
type adminRolePrivilegeDo struct{ gen.DO }
type IAdminRolePrivilegeDo interface {
gen.SubQuery
Debug() IAdminRolePrivilegeDo
WithContext(ctx context.Context) IAdminRolePrivilegeDo
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
ReplaceDB(db *gorm.DB)
ReadDB() IAdminRolePrivilegeDo
WriteDB() IAdminRolePrivilegeDo
As(alias string) gen.Dao
Session(config *gorm.Session) IAdminRolePrivilegeDo
Columns(cols ...field.Expr) gen.Columns
Clauses(conds ...clause.Expression) IAdminRolePrivilegeDo
Not(conds ...gen.Condition) IAdminRolePrivilegeDo
Or(conds ...gen.Condition) IAdminRolePrivilegeDo
Select(conds ...field.Expr) IAdminRolePrivilegeDo
Where(conds ...gen.Condition) IAdminRolePrivilegeDo
Order(conds ...field.Expr) IAdminRolePrivilegeDo
Distinct(cols ...field.Expr) IAdminRolePrivilegeDo
Omit(cols ...field.Expr) IAdminRolePrivilegeDo
Join(table schema.Tabler, on ...field.Expr) IAdminRolePrivilegeDo
LeftJoin(table schema.Tabler, on ...field.Expr) IAdminRolePrivilegeDo
RightJoin(table schema.Tabler, on ...field.Expr) IAdminRolePrivilegeDo
Group(cols ...field.Expr) IAdminRolePrivilegeDo
Having(conds ...gen.Condition) IAdminRolePrivilegeDo
Limit(limit int) IAdminRolePrivilegeDo
Offset(offset int) IAdminRolePrivilegeDo
Count() (count int64, err error)
Scopes(funcs ...func(gen.Dao) gen.Dao) IAdminRolePrivilegeDo
Unscoped() IAdminRolePrivilegeDo
Create(values ...*model.AdminRolePrivilege) error
CreateInBatches(values []*model.AdminRolePrivilege, batchSize int) error
Save(values ...*model.AdminRolePrivilege) error
First() (*model.AdminRolePrivilege, error)
Take() (*model.AdminRolePrivilege, error)
Last() (*model.AdminRolePrivilege, error)
Find() ([]*model.AdminRolePrivilege, error)
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AdminRolePrivilege, err error)
FindInBatches(result *[]*model.AdminRolePrivilege, batchSize int, fc func(tx gen.Dao, batch int) error) error
Pluck(column field.Expr, dest interface{}) error
Delete(...*model.AdminRolePrivilege) (info gen.ResultInfo, err error)
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
Updates(value interface{}) (info gen.ResultInfo, err error)
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
UpdateFrom(q gen.SubQuery) gen.Dao
Attrs(attrs ...field.AssignExpr) IAdminRolePrivilegeDo
Assign(attrs ...field.AssignExpr) IAdminRolePrivilegeDo
Joins(fields ...field.RelationField) IAdminRolePrivilegeDo
Preload(fields ...field.RelationField) IAdminRolePrivilegeDo
FirstOrInit() (*model.AdminRolePrivilege, error)
FirstOrCreate() (*model.AdminRolePrivilege, error)
FindByPage(offset int, limit int) (result []*model.AdminRolePrivilege, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IAdminRolePrivilegeDo
UnderlyingDB() *gorm.DB
schema.Tabler
}
func (a adminRolePrivilegeDo) Debug() IAdminRolePrivilegeDo {
return a.withDO(a.DO.Debug())
}
func (a adminRolePrivilegeDo) WithContext(ctx context.Context) IAdminRolePrivilegeDo {
return a.withDO(a.DO.WithContext(ctx))
}
func (a adminRolePrivilegeDo) ReadDB() IAdminRolePrivilegeDo {
return a.Clauses(dbresolver.Read)
}
func (a adminRolePrivilegeDo) WriteDB() IAdminRolePrivilegeDo {
return a.Clauses(dbresolver.Write)
}
func (a adminRolePrivilegeDo) Session(config *gorm.Session) IAdminRolePrivilegeDo {
return a.withDO(a.DO.Session(config))
}
func (a adminRolePrivilegeDo) Clauses(conds ...clause.Expression) IAdminRolePrivilegeDo {
return a.withDO(a.DO.Clauses(conds...))
}
func (a adminRolePrivilegeDo) Returning(value interface{}, columns ...string) IAdminRolePrivilegeDo {
return a.withDO(a.DO.Returning(value, columns...))
}
func (a adminRolePrivilegeDo) Not(conds ...gen.Condition) IAdminRolePrivilegeDo {
return a.withDO(a.DO.Not(conds...))
}
func (a adminRolePrivilegeDo) Or(conds ...gen.Condition) IAdminRolePrivilegeDo {
return a.withDO(a.DO.Or(conds...))
}
func (a adminRolePrivilegeDo) Select(conds ...field.Expr) IAdminRolePrivilegeDo {
return a.withDO(a.DO.Select(conds...))
}
func (a adminRolePrivilegeDo) Where(conds ...gen.Condition) IAdminRolePrivilegeDo {
return a.withDO(a.DO.Where(conds...))
}
func (a adminRolePrivilegeDo) Order(conds ...field.Expr) IAdminRolePrivilegeDo {
return a.withDO(a.DO.Order(conds...))
}
func (a adminRolePrivilegeDo) Distinct(cols ...field.Expr) IAdminRolePrivilegeDo {
return a.withDO(a.DO.Distinct(cols...))
}
func (a adminRolePrivilegeDo) Omit(cols ...field.Expr) IAdminRolePrivilegeDo {
return a.withDO(a.DO.Omit(cols...))
}
func (a adminRolePrivilegeDo) Join(table schema.Tabler, on ...field.Expr) IAdminRolePrivilegeDo {
return a.withDO(a.DO.Join(table, on...))
}
func (a adminRolePrivilegeDo) LeftJoin(table schema.Tabler, on ...field.Expr) IAdminRolePrivilegeDo {
return a.withDO(a.DO.LeftJoin(table, on...))
}
func (a adminRolePrivilegeDo) RightJoin(table schema.Tabler, on ...field.Expr) IAdminRolePrivilegeDo {
return a.withDO(a.DO.RightJoin(table, on...))
}
func (a adminRolePrivilegeDo) Group(cols ...field.Expr) IAdminRolePrivilegeDo {
return a.withDO(a.DO.Group(cols...))
}
func (a adminRolePrivilegeDo) Having(conds ...gen.Condition) IAdminRolePrivilegeDo {
return a.withDO(a.DO.Having(conds...))
}
func (a adminRolePrivilegeDo) Limit(limit int) IAdminRolePrivilegeDo {
return a.withDO(a.DO.Limit(limit))
}
func (a adminRolePrivilegeDo) Offset(offset int) IAdminRolePrivilegeDo {
return a.withDO(a.DO.Offset(offset))
}
func (a adminRolePrivilegeDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IAdminRolePrivilegeDo {
return a.withDO(a.DO.Scopes(funcs...))
}
func (a adminRolePrivilegeDo) Unscoped() IAdminRolePrivilegeDo {
return a.withDO(a.DO.Unscoped())
}
func (a adminRolePrivilegeDo) Create(values ...*model.AdminRolePrivilege) error {
if len(values) == 0 {
return nil
}
return a.DO.Create(values)
}
func (a adminRolePrivilegeDo) CreateInBatches(values []*model.AdminRolePrivilege, 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 adminRolePrivilegeDo) Save(values ...*model.AdminRolePrivilege) error {
if len(values) == 0 {
return nil
}
return a.DO.Save(values)
}
func (a adminRolePrivilegeDo) First() (*model.AdminRolePrivilege, error) {
if result, err := a.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.AdminRolePrivilege), nil
}
}
func (a adminRolePrivilegeDo) Take() (*model.AdminRolePrivilege, error) {
if result, err := a.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.AdminRolePrivilege), nil
}
}
func (a adminRolePrivilegeDo) Last() (*model.AdminRolePrivilege, error) {
if result, err := a.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.AdminRolePrivilege), nil
}
}
func (a adminRolePrivilegeDo) Find() ([]*model.AdminRolePrivilege, error) {
result, err := a.DO.Find()
return result.([]*model.AdminRolePrivilege), err
}
func (a adminRolePrivilegeDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AdminRolePrivilege, err error) {
buf := make([]*model.AdminRolePrivilege, 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 adminRolePrivilegeDo) FindInBatches(result *[]*model.AdminRolePrivilege, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return a.DO.FindInBatches(result, batchSize, fc)
}
func (a adminRolePrivilegeDo) Attrs(attrs ...field.AssignExpr) IAdminRolePrivilegeDo {
return a.withDO(a.DO.Attrs(attrs...))
}
func (a adminRolePrivilegeDo) Assign(attrs ...field.AssignExpr) IAdminRolePrivilegeDo {
return a.withDO(a.DO.Assign(attrs...))
}
func (a adminRolePrivilegeDo) Joins(fields ...field.RelationField) IAdminRolePrivilegeDo {
for _, _f := range fields {
a = *a.withDO(a.DO.Joins(_f))
}
return &a
}
func (a adminRolePrivilegeDo) Preload(fields ...field.RelationField) IAdminRolePrivilegeDo {
for _, _f := range fields {
a = *a.withDO(a.DO.Preload(_f))
}
return &a
}
func (a adminRolePrivilegeDo) FirstOrInit() (*model.AdminRolePrivilege, error) {
if result, err := a.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.AdminRolePrivilege), nil
}
}
func (a adminRolePrivilegeDo) FirstOrCreate() (*model.AdminRolePrivilege, error) {
if result, err := a.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.AdminRolePrivilege), nil
}
}
func (a adminRolePrivilegeDo) FindByPage(offset int, limit int) (result []*model.AdminRolePrivilege, 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 adminRolePrivilegeDo) 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 adminRolePrivilegeDo) Scan(result interface{}) (err error) {
return a.DO.Scan(result)
}
func (a adminRolePrivilegeDo) Delete(models ...*model.AdminRolePrivilege) (result gen.ResultInfo, err error) {
return a.DO.Delete(models)
}
func (a *adminRolePrivilegeDo) withDO(do gen.Dao) *adminRolePrivilegeDo {
a.DO = *do.(*gen.DO)
return a
}

455
pkg/repo/admin_user.gen.go Normal file
View File

@ -0,0 +1,455 @@
// 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 repo
import (
"context"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
"servicebase/pkg/model"
)
func newAdminUser(db *gorm.DB, opts ...gen.DOOption) adminUser {
_adminUser := adminUser{}
_adminUser.adminUserDo.UseDB(db, opts...)
_adminUser.adminUserDo.UseModel(&model.AdminUser{})
tableName := _adminUser.adminUserDo.TableName()
_adminUser.ALL = field.NewAsterisk(tableName)
_adminUser.ID = field.NewString(tableName, "id")
_adminUser.TenantID = field.NewString(tableName, "tenant_id")
_adminUser.Username = field.NewString(tableName, "username")
_adminUser.Channel = field.NewString(tableName, "channel")
_adminUser.ChannelCode = field.NewString(tableName, "channel_code")
_adminUser.Nickname = field.NewString(tableName, "nickname")
_adminUser.Desc = field.NewString(tableName, "desc")
_adminUser.State = field.NewInt32(tableName, "state")
_adminUser.Password = field.NewString(tableName, "password")
_adminUser.PassCipher = field.NewString(tableName, "pass_cipher")
_adminUser.PassSalt = field.NewString(tableName, "pass_salt")
_adminUser.ExtID = field.NewString(tableName, "ext_id")
_adminUser.DeleteAt = field.NewField(tableName, "delete_at")
_adminUser.CreateAt = field.NewTime(tableName, "create_at")
_adminUser.CreateBy = field.NewString(tableName, "create_by")
_adminUser.UpdateAt = field.NewTime(tableName, "update_at")
_adminUser.UpdateBy = field.NewString(tableName, "update_by")
_adminUser.fillFieldMap()
return _adminUser
}
// adminUser 用户表
type adminUser struct {
adminUserDo adminUserDo
ALL field.Asterisk
ID field.String // 业务ID
TenantID field.String // 企业ID
Username field.String // 用户名
Channel field.String // 渠道ADMIN=后台维护 LDAP=统一管理获取 REGISTER=注册
ChannelCode field.String
Nickname field.String // 昵称
Desc field.String
State field.Int32 // 1=启用 2=禁用
Password field.String // 密码
PassCipher field.String // 加密方式
PassSalt field.String // 密码盐
ExtID field.String // 外部ID
DeleteAt field.Field // del标志
CreateAt field.Time // 创建时间
CreateBy field.String // 创建人
UpdateAt field.Time // 更新时间
UpdateBy field.String // 更新人
fieldMap map[string]field.Expr
}
func (a adminUser) Table(newTableName string) *adminUser {
a.adminUserDo.UseTable(newTableName)
return a.updateTableName(newTableName)
}
func (a adminUser) As(alias string) *adminUser {
a.adminUserDo.DO = *(a.adminUserDo.As(alias).(*gen.DO))
return a.updateTableName(alias)
}
func (a *adminUser) updateTableName(table string) *adminUser {
a.ALL = field.NewAsterisk(table)
a.ID = field.NewString(table, "id")
a.TenantID = field.NewString(table, "tenant_id")
a.Username = field.NewString(table, "username")
a.Channel = field.NewString(table, "channel")
a.ChannelCode = field.NewString(table, "channel_code")
a.Nickname = field.NewString(table, "nickname")
a.Desc = field.NewString(table, "desc")
a.State = field.NewInt32(table, "state")
a.Password = field.NewString(table, "password")
a.PassCipher = field.NewString(table, "pass_cipher")
a.PassSalt = field.NewString(table, "pass_salt")
a.ExtID = field.NewString(table, "ext_id")
a.DeleteAt = field.NewField(table, "delete_at")
a.CreateAt = field.NewTime(table, "create_at")
a.CreateBy = field.NewString(table, "create_by")
a.UpdateAt = field.NewTime(table, "update_at")
a.UpdateBy = field.NewString(table, "update_by")
a.fillFieldMap()
return a
}
func (a *adminUser) WithContext(ctx context.Context) IAdminUserDo {
return a.adminUserDo.WithContext(ctx)
}
func (a adminUser) TableName() string { return a.adminUserDo.TableName() }
func (a adminUser) Alias() string { return a.adminUserDo.Alias() }
func (a adminUser) Columns(cols ...field.Expr) gen.Columns { return a.adminUserDo.Columns(cols...) }
func (a *adminUser) 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 *adminUser) fillFieldMap() {
a.fieldMap = make(map[string]field.Expr, 17)
a.fieldMap["id"] = a.ID
a.fieldMap["tenant_id"] = a.TenantID
a.fieldMap["username"] = a.Username
a.fieldMap["channel"] = a.Channel
a.fieldMap["channel_code"] = a.ChannelCode
a.fieldMap["nickname"] = a.Nickname
a.fieldMap["desc"] = a.Desc
a.fieldMap["state"] = a.State
a.fieldMap["password"] = a.Password
a.fieldMap["pass_cipher"] = a.PassCipher
a.fieldMap["pass_salt"] = a.PassSalt
a.fieldMap["ext_id"] = a.ExtID
a.fieldMap["delete_at"] = a.DeleteAt
a.fieldMap["create_at"] = a.CreateAt
a.fieldMap["create_by"] = a.CreateBy
a.fieldMap["update_at"] = a.UpdateAt
a.fieldMap["update_by"] = a.UpdateBy
}
func (a adminUser) clone(db *gorm.DB) adminUser {
a.adminUserDo.ReplaceConnPool(db.Statement.ConnPool)
return a
}
func (a adminUser) replaceDB(db *gorm.DB) adminUser {
a.adminUserDo.ReplaceDB(db)
return a
}
type adminUserDo struct{ gen.DO }
type IAdminUserDo interface {
gen.SubQuery
Debug() IAdminUserDo
WithContext(ctx context.Context) IAdminUserDo
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
ReplaceDB(db *gorm.DB)
ReadDB() IAdminUserDo
WriteDB() IAdminUserDo
As(alias string) gen.Dao
Session(config *gorm.Session) IAdminUserDo
Columns(cols ...field.Expr) gen.Columns
Clauses(conds ...clause.Expression) IAdminUserDo
Not(conds ...gen.Condition) IAdminUserDo
Or(conds ...gen.Condition) IAdminUserDo
Select(conds ...field.Expr) IAdminUserDo
Where(conds ...gen.Condition) IAdminUserDo
Order(conds ...field.Expr) IAdminUserDo
Distinct(cols ...field.Expr) IAdminUserDo
Omit(cols ...field.Expr) IAdminUserDo
Join(table schema.Tabler, on ...field.Expr) IAdminUserDo
LeftJoin(table schema.Tabler, on ...field.Expr) IAdminUserDo
RightJoin(table schema.Tabler, on ...field.Expr) IAdminUserDo
Group(cols ...field.Expr) IAdminUserDo
Having(conds ...gen.Condition) IAdminUserDo
Limit(limit int) IAdminUserDo
Offset(offset int) IAdminUserDo
Count() (count int64, err error)
Scopes(funcs ...func(gen.Dao) gen.Dao) IAdminUserDo
Unscoped() IAdminUserDo
Create(values ...*model.AdminUser) error
CreateInBatches(values []*model.AdminUser, batchSize int) error
Save(values ...*model.AdminUser) error
First() (*model.AdminUser, error)
Take() (*model.AdminUser, error)
Last() (*model.AdminUser, error)
Find() ([]*model.AdminUser, error)
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AdminUser, err error)
FindInBatches(result *[]*model.AdminUser, batchSize int, fc func(tx gen.Dao, batch int) error) error
Pluck(column field.Expr, dest interface{}) error
Delete(...*model.AdminUser) (info gen.ResultInfo, err error)
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
Updates(value interface{}) (info gen.ResultInfo, err error)
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
UpdateFrom(q gen.SubQuery) gen.Dao
Attrs(attrs ...field.AssignExpr) IAdminUserDo
Assign(attrs ...field.AssignExpr) IAdminUserDo
Joins(fields ...field.RelationField) IAdminUserDo
Preload(fields ...field.RelationField) IAdminUserDo
FirstOrInit() (*model.AdminUser, error)
FirstOrCreate() (*model.AdminUser, error)
FindByPage(offset int, limit int) (result []*model.AdminUser, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IAdminUserDo
UnderlyingDB() *gorm.DB
schema.Tabler
}
func (a adminUserDo) Debug() IAdminUserDo {
return a.withDO(a.DO.Debug())
}
func (a adminUserDo) WithContext(ctx context.Context) IAdminUserDo {
return a.withDO(a.DO.WithContext(ctx))
}
func (a adminUserDo) ReadDB() IAdminUserDo {
return a.Clauses(dbresolver.Read)
}
func (a adminUserDo) WriteDB() IAdminUserDo {
return a.Clauses(dbresolver.Write)
}
func (a adminUserDo) Session(config *gorm.Session) IAdminUserDo {
return a.withDO(a.DO.Session(config))
}
func (a adminUserDo) Clauses(conds ...clause.Expression) IAdminUserDo {
return a.withDO(a.DO.Clauses(conds...))
}
func (a adminUserDo) Returning(value interface{}, columns ...string) IAdminUserDo {
return a.withDO(a.DO.Returning(value, columns...))
}
func (a adminUserDo) Not(conds ...gen.Condition) IAdminUserDo {
return a.withDO(a.DO.Not(conds...))
}
func (a adminUserDo) Or(conds ...gen.Condition) IAdminUserDo {
return a.withDO(a.DO.Or(conds...))
}
func (a adminUserDo) Select(conds ...field.Expr) IAdminUserDo {
return a.withDO(a.DO.Select(conds...))
}
func (a adminUserDo) Where(conds ...gen.Condition) IAdminUserDo {
return a.withDO(a.DO.Where(conds...))
}
func (a adminUserDo) Order(conds ...field.Expr) IAdminUserDo {
return a.withDO(a.DO.Order(conds...))
}
func (a adminUserDo) Distinct(cols ...field.Expr) IAdminUserDo {
return a.withDO(a.DO.Distinct(cols...))
}
func (a adminUserDo) Omit(cols ...field.Expr) IAdminUserDo {
return a.withDO(a.DO.Omit(cols...))
}
func (a adminUserDo) Join(table schema.Tabler, on ...field.Expr) IAdminUserDo {
return a.withDO(a.DO.Join(table, on...))
}
func (a adminUserDo) LeftJoin(table schema.Tabler, on ...field.Expr) IAdminUserDo {
return a.withDO(a.DO.LeftJoin(table, on...))
}
func (a adminUserDo) RightJoin(table schema.Tabler, on ...field.Expr) IAdminUserDo {
return a.withDO(a.DO.RightJoin(table, on...))
}
func (a adminUserDo) Group(cols ...field.Expr) IAdminUserDo {
return a.withDO(a.DO.Group(cols...))
}
func (a adminUserDo) Having(conds ...gen.Condition) IAdminUserDo {
return a.withDO(a.DO.Having(conds...))
}
func (a adminUserDo) Limit(limit int) IAdminUserDo {
return a.withDO(a.DO.Limit(limit))
}
func (a adminUserDo) Offset(offset int) IAdminUserDo {
return a.withDO(a.DO.Offset(offset))
}
func (a adminUserDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IAdminUserDo {
return a.withDO(a.DO.Scopes(funcs...))
}
func (a adminUserDo) Unscoped() IAdminUserDo {
return a.withDO(a.DO.Unscoped())
}
func (a adminUserDo) Create(values ...*model.AdminUser) error {
if len(values) == 0 {
return nil
}
return a.DO.Create(values)
}
func (a adminUserDo) CreateInBatches(values []*model.AdminUser, 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 adminUserDo) Save(values ...*model.AdminUser) error {
if len(values) == 0 {
return nil
}
return a.DO.Save(values)
}
func (a adminUserDo) First() (*model.AdminUser, error) {
if result, err := a.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.AdminUser), nil
}
}
func (a adminUserDo) Take() (*model.AdminUser, error) {
if result, err := a.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.AdminUser), nil
}
}
func (a adminUserDo) Last() (*model.AdminUser, error) {
if result, err := a.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.AdminUser), nil
}
}
func (a adminUserDo) Find() ([]*model.AdminUser, error) {
result, err := a.DO.Find()
return result.([]*model.AdminUser), err
}
func (a adminUserDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AdminUser, err error) {
buf := make([]*model.AdminUser, 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 adminUserDo) FindInBatches(result *[]*model.AdminUser, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return a.DO.FindInBatches(result, batchSize, fc)
}
func (a adminUserDo) Attrs(attrs ...field.AssignExpr) IAdminUserDo {
return a.withDO(a.DO.Attrs(attrs...))
}
func (a adminUserDo) Assign(attrs ...field.AssignExpr) IAdminUserDo {
return a.withDO(a.DO.Assign(attrs...))
}
func (a adminUserDo) Joins(fields ...field.RelationField) IAdminUserDo {
for _, _f := range fields {
a = *a.withDO(a.DO.Joins(_f))
}
return &a
}
func (a adminUserDo) Preload(fields ...field.RelationField) IAdminUserDo {
for _, _f := range fields {
a = *a.withDO(a.DO.Preload(_f))
}
return &a
}
func (a adminUserDo) FirstOrInit() (*model.AdminUser, error) {
if result, err := a.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.AdminUser), nil
}
}
func (a adminUserDo) FirstOrCreate() (*model.AdminUser, error) {
if result, err := a.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.AdminUser), nil
}
}
func (a adminUserDo) FindByPage(offset int, limit int) (result []*model.AdminUser, 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 adminUserDo) 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 adminUserDo) Scan(result interface{}) (err error) {
return a.DO.Scan(result)
}
func (a adminUserDo) Delete(models ...*model.AdminUser) (result gen.ResultInfo, err error) {
return a.DO.Delete(models)
}
func (a *adminUserDo) withDO(do gen.Dao) *adminUserDo {
a.DO = *do.(*gen.DO)
return a
}

View File

@ -0,0 +1,429 @@
// 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 repo
import (
"context"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
"servicebase/pkg/model"
)
func newAdminUserRole(db *gorm.DB, opts ...gen.DOOption) adminUserRole {
_adminUserRole := adminUserRole{}
_adminUserRole.adminUserRoleDo.UseDB(db, opts...)
_adminUserRole.adminUserRoleDo.UseModel(&model.AdminUserRole{})
tableName := _adminUserRole.adminUserRoleDo.TableName()
_adminUserRole.ALL = field.NewAsterisk(tableName)
_adminUserRole.ID = field.NewString(tableName, "id")
_adminUserRole.TenantID = field.NewString(tableName, "tenant_id")
_adminUserRole.ScopeID = field.NewString(tableName, "scope_id")
_adminUserRole.UserID = field.NewString(tableName, "user_id")
_adminUserRole.RoleID = field.NewString(tableName, "role_id")
_adminUserRole.DeleteAt = field.NewField(tableName, "delete_at")
_adminUserRole.CreateAt = field.NewTime(tableName, "create_at")
_adminUserRole.CreateBy = field.NewString(tableName, "create_by")
_adminUserRole.UpdateAt = field.NewTime(tableName, "update_at")
_adminUserRole.UpdateBy = field.NewString(tableName, "update_by")
_adminUserRole.fillFieldMap()
return _adminUserRole
}
// adminUserRole 租户用户-角色表
type adminUserRole struct {
adminUserRoleDo adminUserRoleDo
ALL field.Asterisk
ID field.String // 业务ID
TenantID field.String // 企业ID
ScopeID field.String // 范围
UserID field.String // 用户ID
RoleID field.String // 角色ID
DeleteAt field.Field // del标志
CreateAt field.Time // 创建时间
CreateBy field.String // 创建人
UpdateAt field.Time // 更新时间
UpdateBy field.String // 更新人
fieldMap map[string]field.Expr
}
func (a adminUserRole) Table(newTableName string) *adminUserRole {
a.adminUserRoleDo.UseTable(newTableName)
return a.updateTableName(newTableName)
}
func (a adminUserRole) As(alias string) *adminUserRole {
a.adminUserRoleDo.DO = *(a.adminUserRoleDo.As(alias).(*gen.DO))
return a.updateTableName(alias)
}
func (a *adminUserRole) updateTableName(table string) *adminUserRole {
a.ALL = field.NewAsterisk(table)
a.ID = field.NewString(table, "id")
a.TenantID = field.NewString(table, "tenant_id")
a.ScopeID = field.NewString(table, "scope_id")
a.UserID = field.NewString(table, "user_id")
a.RoleID = field.NewString(table, "role_id")
a.DeleteAt = field.NewField(table, "delete_at")
a.CreateAt = field.NewTime(table, "create_at")
a.CreateBy = field.NewString(table, "create_by")
a.UpdateAt = field.NewTime(table, "update_at")
a.UpdateBy = field.NewString(table, "update_by")
a.fillFieldMap()
return a
}
func (a *adminUserRole) WithContext(ctx context.Context) IAdminUserRoleDo {
return a.adminUserRoleDo.WithContext(ctx)
}
func (a adminUserRole) TableName() string { return a.adminUserRoleDo.TableName() }
func (a adminUserRole) Alias() string { return a.adminUserRoleDo.Alias() }
func (a adminUserRole) Columns(cols ...field.Expr) gen.Columns {
return a.adminUserRoleDo.Columns(cols...)
}
func (a *adminUserRole) 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 *adminUserRole) fillFieldMap() {
a.fieldMap = make(map[string]field.Expr, 10)
a.fieldMap["id"] = a.ID
a.fieldMap["tenant_id"] = a.TenantID
a.fieldMap["scope_id"] = a.ScopeID
a.fieldMap["user_id"] = a.UserID
a.fieldMap["role_id"] = a.RoleID
a.fieldMap["delete_at"] = a.DeleteAt
a.fieldMap["create_at"] = a.CreateAt
a.fieldMap["create_by"] = a.CreateBy
a.fieldMap["update_at"] = a.UpdateAt
a.fieldMap["update_by"] = a.UpdateBy
}
func (a adminUserRole) clone(db *gorm.DB) adminUserRole {
a.adminUserRoleDo.ReplaceConnPool(db.Statement.ConnPool)
return a
}
func (a adminUserRole) replaceDB(db *gorm.DB) adminUserRole {
a.adminUserRoleDo.ReplaceDB(db)
return a
}
type adminUserRoleDo struct{ gen.DO }
type IAdminUserRoleDo interface {
gen.SubQuery
Debug() IAdminUserRoleDo
WithContext(ctx context.Context) IAdminUserRoleDo
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
ReplaceDB(db *gorm.DB)
ReadDB() IAdminUserRoleDo
WriteDB() IAdminUserRoleDo
As(alias string) gen.Dao
Session(config *gorm.Session) IAdminUserRoleDo
Columns(cols ...field.Expr) gen.Columns
Clauses(conds ...clause.Expression) IAdminUserRoleDo
Not(conds ...gen.Condition) IAdminUserRoleDo
Or(conds ...gen.Condition) IAdminUserRoleDo
Select(conds ...field.Expr) IAdminUserRoleDo
Where(conds ...gen.Condition) IAdminUserRoleDo
Order(conds ...field.Expr) IAdminUserRoleDo
Distinct(cols ...field.Expr) IAdminUserRoleDo
Omit(cols ...field.Expr) IAdminUserRoleDo
Join(table schema.Tabler, on ...field.Expr) IAdminUserRoleDo
LeftJoin(table schema.Tabler, on ...field.Expr) IAdminUserRoleDo
RightJoin(table schema.Tabler, on ...field.Expr) IAdminUserRoleDo
Group(cols ...field.Expr) IAdminUserRoleDo
Having(conds ...gen.Condition) IAdminUserRoleDo
Limit(limit int) IAdminUserRoleDo
Offset(offset int) IAdminUserRoleDo
Count() (count int64, err error)
Scopes(funcs ...func(gen.Dao) gen.Dao) IAdminUserRoleDo
Unscoped() IAdminUserRoleDo
Create(values ...*model.AdminUserRole) error
CreateInBatches(values []*model.AdminUserRole, batchSize int) error
Save(values ...*model.AdminUserRole) error
First() (*model.AdminUserRole, error)
Take() (*model.AdminUserRole, error)
Last() (*model.AdminUserRole, error)
Find() ([]*model.AdminUserRole, error)
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AdminUserRole, err error)
FindInBatches(result *[]*model.AdminUserRole, batchSize int, fc func(tx gen.Dao, batch int) error) error
Pluck(column field.Expr, dest interface{}) error
Delete(...*model.AdminUserRole) (info gen.ResultInfo, err error)
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
Updates(value interface{}) (info gen.ResultInfo, err error)
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
UpdateFrom(q gen.SubQuery) gen.Dao
Attrs(attrs ...field.AssignExpr) IAdminUserRoleDo
Assign(attrs ...field.AssignExpr) IAdminUserRoleDo
Joins(fields ...field.RelationField) IAdminUserRoleDo
Preload(fields ...field.RelationField) IAdminUserRoleDo
FirstOrInit() (*model.AdminUserRole, error)
FirstOrCreate() (*model.AdminUserRole, error)
FindByPage(offset int, limit int) (result []*model.AdminUserRole, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IAdminUserRoleDo
UnderlyingDB() *gorm.DB
schema.Tabler
}
func (a adminUserRoleDo) Debug() IAdminUserRoleDo {
return a.withDO(a.DO.Debug())
}
func (a adminUserRoleDo) WithContext(ctx context.Context) IAdminUserRoleDo {
return a.withDO(a.DO.WithContext(ctx))
}
func (a adminUserRoleDo) ReadDB() IAdminUserRoleDo {
return a.Clauses(dbresolver.Read)
}
func (a adminUserRoleDo) WriteDB() IAdminUserRoleDo {
return a.Clauses(dbresolver.Write)
}
func (a adminUserRoleDo) Session(config *gorm.Session) IAdminUserRoleDo {
return a.withDO(a.DO.Session(config))
}
func (a adminUserRoleDo) Clauses(conds ...clause.Expression) IAdminUserRoleDo {
return a.withDO(a.DO.Clauses(conds...))
}
func (a adminUserRoleDo) Returning(value interface{}, columns ...string) IAdminUserRoleDo {
return a.withDO(a.DO.Returning(value, columns...))
}
func (a adminUserRoleDo) Not(conds ...gen.Condition) IAdminUserRoleDo {
return a.withDO(a.DO.Not(conds...))
}
func (a adminUserRoleDo) Or(conds ...gen.Condition) IAdminUserRoleDo {
return a.withDO(a.DO.Or(conds...))
}
func (a adminUserRoleDo) Select(conds ...field.Expr) IAdminUserRoleDo {
return a.withDO(a.DO.Select(conds...))
}
func (a adminUserRoleDo) Where(conds ...gen.Condition) IAdminUserRoleDo {
return a.withDO(a.DO.Where(conds...))
}
func (a adminUserRoleDo) Order(conds ...field.Expr) IAdminUserRoleDo {
return a.withDO(a.DO.Order(conds...))
}
func (a adminUserRoleDo) Distinct(cols ...field.Expr) IAdminUserRoleDo {
return a.withDO(a.DO.Distinct(cols...))
}
func (a adminUserRoleDo) Omit(cols ...field.Expr) IAdminUserRoleDo {
return a.withDO(a.DO.Omit(cols...))
}
func (a adminUserRoleDo) Join(table schema.Tabler, on ...field.Expr) IAdminUserRoleDo {
return a.withDO(a.DO.Join(table, on...))
}
func (a adminUserRoleDo) LeftJoin(table schema.Tabler, on ...field.Expr) IAdminUserRoleDo {
return a.withDO(a.DO.LeftJoin(table, on...))
}
func (a adminUserRoleDo) RightJoin(table schema.Tabler, on ...field.Expr) IAdminUserRoleDo {
return a.withDO(a.DO.RightJoin(table, on...))
}
func (a adminUserRoleDo) Group(cols ...field.Expr) IAdminUserRoleDo {
return a.withDO(a.DO.Group(cols...))
}
func (a adminUserRoleDo) Having(conds ...gen.Condition) IAdminUserRoleDo {
return a.withDO(a.DO.Having(conds...))
}
func (a adminUserRoleDo) Limit(limit int) IAdminUserRoleDo {
return a.withDO(a.DO.Limit(limit))
}
func (a adminUserRoleDo) Offset(offset int) IAdminUserRoleDo {
return a.withDO(a.DO.Offset(offset))
}
func (a adminUserRoleDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IAdminUserRoleDo {
return a.withDO(a.DO.Scopes(funcs...))
}
func (a adminUserRoleDo) Unscoped() IAdminUserRoleDo {
return a.withDO(a.DO.Unscoped())
}
func (a adminUserRoleDo) Create(values ...*model.AdminUserRole) error {
if len(values) == 0 {
return nil
}
return a.DO.Create(values)
}
func (a adminUserRoleDo) CreateInBatches(values []*model.AdminUserRole, 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 adminUserRoleDo) Save(values ...*model.AdminUserRole) error {
if len(values) == 0 {
return nil
}
return a.DO.Save(values)
}
func (a adminUserRoleDo) First() (*model.AdminUserRole, error) {
if result, err := a.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.AdminUserRole), nil
}
}
func (a adminUserRoleDo) Take() (*model.AdminUserRole, error) {
if result, err := a.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.AdminUserRole), nil
}
}
func (a adminUserRoleDo) Last() (*model.AdminUserRole, error) {
if result, err := a.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.AdminUserRole), nil
}
}
func (a adminUserRoleDo) Find() ([]*model.AdminUserRole, error) {
result, err := a.DO.Find()
return result.([]*model.AdminUserRole), err
}
func (a adminUserRoleDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AdminUserRole, err error) {
buf := make([]*model.AdminUserRole, 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 adminUserRoleDo) FindInBatches(result *[]*model.AdminUserRole, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return a.DO.FindInBatches(result, batchSize, fc)
}
func (a adminUserRoleDo) Attrs(attrs ...field.AssignExpr) IAdminUserRoleDo {
return a.withDO(a.DO.Attrs(attrs...))
}
func (a adminUserRoleDo) Assign(attrs ...field.AssignExpr) IAdminUserRoleDo {
return a.withDO(a.DO.Assign(attrs...))
}
func (a adminUserRoleDo) Joins(fields ...field.RelationField) IAdminUserRoleDo {
for _, _f := range fields {
a = *a.withDO(a.DO.Joins(_f))
}
return &a
}
func (a adminUserRoleDo) Preload(fields ...field.RelationField) IAdminUserRoleDo {
for _, _f := range fields {
a = *a.withDO(a.DO.Preload(_f))
}
return &a
}
func (a adminUserRoleDo) FirstOrInit() (*model.AdminUserRole, error) {
if result, err := a.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.AdminUserRole), nil
}
}
func (a adminUserRoleDo) FirstOrCreate() (*model.AdminUserRole, error) {
if result, err := a.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.AdminUserRole), nil
}
}
func (a adminUserRoleDo) FindByPage(offset int, limit int) (result []*model.AdminUserRole, 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 adminUserRoleDo) 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 adminUserRoleDo) Scan(result interface{}) (err error) {
return a.DO.Scan(result)
}
func (a adminUserRoleDo) Delete(models ...*model.AdminUserRole) (result gen.ResultInfo, err error) {
return a.DO.Delete(models)
}
func (a *adminUserRoleDo) withDO(do gen.Dao) *adminUserRoleDo {
a.DO = *do.(*gen.DO)
return a
}

471
pkg/repo/data_attach.gen.go Normal file
View File

@ -0,0 +1,471 @@
// 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 repo
import (
"context"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
"servicebase/pkg/model"
)
func newDataAttach(db *gorm.DB, opts ...gen.DOOption) dataAttach {
_dataAttach := dataAttach{}
_dataAttach.dataAttachDo.UseDB(db, opts...)
_dataAttach.dataAttachDo.UseModel(&model.DataAttach{})
tableName := _dataAttach.dataAttachDo.TableName()
_dataAttach.ALL = field.NewAsterisk(tableName)
_dataAttach.ID = field.NewString(tableName, "id")
_dataAttach.TenantID = field.NewString(tableName, "tenant_id")
_dataAttach.PartUploadID = field.NewString(tableName, "part_upload_id")
_dataAttach.TotalChunks = field.NewInt32(tableName, "total_chunks")
_dataAttach.PartSize = field.NewInt32(tableName, "part_size")
_dataAttach.Md5 = field.NewString(tableName, "md5")
_dataAttach.DataType = field.NewString(tableName, "data_type")
_dataAttach.DataID = field.NewString(tableName, "data_id")
_dataAttach.CommonType = field.NewString(tableName, "common_type")
_dataAttach.FileType = field.NewString(tableName, "file_type")
_dataAttach.FileSize = field.NewInt32(tableName, "file_size")
_dataAttach.FileName = field.NewString(tableName, "file_name")
_dataAttach.FilePath = field.NewString(tableName, "file_path")
_dataAttach.FileThumbPath = field.NewString(tableName, "file_thumb_path")
_dataAttach.FileThumbType = field.NewString(tableName, "file_thumb_type")
_dataAttach.UploadState = field.NewInt32(tableName, "upload_state")
_dataAttach.DeleteAt = field.NewField(tableName, "delete_at")
_dataAttach.CreateAt = field.NewTime(tableName, "create_at")
_dataAttach.CreateBy = field.NewString(tableName, "create_by")
_dataAttach.UpdateAt = field.NewTime(tableName, "update_at")
_dataAttach.UpdateBy = field.NewString(tableName, "update_by")
_dataAttach.fillFieldMap()
return _dataAttach
}
// dataAttach 通用附件
type dataAttach struct {
dataAttachDo dataAttachDo
ALL field.Asterisk
ID field.String // 业务ID
TenantID field.String // 企业ID
PartUploadID field.String // 分片上传upload id
TotalChunks field.Int32 // 分片总数
PartSize field.Int32 // 分片大小-单位M
Md5 field.String // 文件md5
DataType field.String // 数据类型SATELLITE=卫星图,其他请使用时完善定义
DataID field.String // 数据ID
CommonType field.String // 通用类型IMAGE = 图片(jfif、png、jpg等)DOC = 文档excel、docs、ppt、pdf等BINARY = 二进制文件exe等
FileType field.String // 文件类型
FileSize field.Int32 // 文件大小
FileName field.String // 文件名称
FilePath field.String // 文件路径
FileThumbPath field.String // 缩略文件路径
FileThumbType field.String // 缩略图文件类型
UploadState field.Int32 // 0未上传,1上传
DeleteAt field.Field // del标志
CreateAt field.Time // 创建时间
CreateBy field.String // 创建人
UpdateAt field.Time // 更新时间
UpdateBy field.String // 更新人
fieldMap map[string]field.Expr
}
func (d dataAttach) Table(newTableName string) *dataAttach {
d.dataAttachDo.UseTable(newTableName)
return d.updateTableName(newTableName)
}
func (d dataAttach) As(alias string) *dataAttach {
d.dataAttachDo.DO = *(d.dataAttachDo.As(alias).(*gen.DO))
return d.updateTableName(alias)
}
func (d *dataAttach) updateTableName(table string) *dataAttach {
d.ALL = field.NewAsterisk(table)
d.ID = field.NewString(table, "id")
d.TenantID = field.NewString(table, "tenant_id")
d.PartUploadID = field.NewString(table, "part_upload_id")
d.TotalChunks = field.NewInt32(table, "total_chunks")
d.PartSize = field.NewInt32(table, "part_size")
d.Md5 = field.NewString(table, "md5")
d.DataType = field.NewString(table, "data_type")
d.DataID = field.NewString(table, "data_id")
d.CommonType = field.NewString(table, "common_type")
d.FileType = field.NewString(table, "file_type")
d.FileSize = field.NewInt32(table, "file_size")
d.FileName = field.NewString(table, "file_name")
d.FilePath = field.NewString(table, "file_path")
d.FileThumbPath = field.NewString(table, "file_thumb_path")
d.FileThumbType = field.NewString(table, "file_thumb_type")
d.UploadState = field.NewInt32(table, "upload_state")
d.DeleteAt = field.NewField(table, "delete_at")
d.CreateAt = field.NewTime(table, "create_at")
d.CreateBy = field.NewString(table, "create_by")
d.UpdateAt = field.NewTime(table, "update_at")
d.UpdateBy = field.NewString(table, "update_by")
d.fillFieldMap()
return d
}
func (d *dataAttach) WithContext(ctx context.Context) IDataAttachDo {
return d.dataAttachDo.WithContext(ctx)
}
func (d dataAttach) TableName() string { return d.dataAttachDo.TableName() }
func (d dataAttach) Alias() string { return d.dataAttachDo.Alias() }
func (d dataAttach) Columns(cols ...field.Expr) gen.Columns { return d.dataAttachDo.Columns(cols...) }
func (d *dataAttach) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := d.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (d *dataAttach) fillFieldMap() {
d.fieldMap = make(map[string]field.Expr, 21)
d.fieldMap["id"] = d.ID
d.fieldMap["tenant_id"] = d.TenantID
d.fieldMap["part_upload_id"] = d.PartUploadID
d.fieldMap["total_chunks"] = d.TotalChunks
d.fieldMap["part_size"] = d.PartSize
d.fieldMap["md5"] = d.Md5
d.fieldMap["data_type"] = d.DataType
d.fieldMap["data_id"] = d.DataID
d.fieldMap["common_type"] = d.CommonType
d.fieldMap["file_type"] = d.FileType
d.fieldMap["file_size"] = d.FileSize
d.fieldMap["file_name"] = d.FileName
d.fieldMap["file_path"] = d.FilePath
d.fieldMap["file_thumb_path"] = d.FileThumbPath
d.fieldMap["file_thumb_type"] = d.FileThumbType
d.fieldMap["upload_state"] = d.UploadState
d.fieldMap["delete_at"] = d.DeleteAt
d.fieldMap["create_at"] = d.CreateAt
d.fieldMap["create_by"] = d.CreateBy
d.fieldMap["update_at"] = d.UpdateAt
d.fieldMap["update_by"] = d.UpdateBy
}
func (d dataAttach) clone(db *gorm.DB) dataAttach {
d.dataAttachDo.ReplaceConnPool(db.Statement.ConnPool)
return d
}
func (d dataAttach) replaceDB(db *gorm.DB) dataAttach {
d.dataAttachDo.ReplaceDB(db)
return d
}
type dataAttachDo struct{ gen.DO }
type IDataAttachDo interface {
gen.SubQuery
Debug() IDataAttachDo
WithContext(ctx context.Context) IDataAttachDo
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
ReplaceDB(db *gorm.DB)
ReadDB() IDataAttachDo
WriteDB() IDataAttachDo
As(alias string) gen.Dao
Session(config *gorm.Session) IDataAttachDo
Columns(cols ...field.Expr) gen.Columns
Clauses(conds ...clause.Expression) IDataAttachDo
Not(conds ...gen.Condition) IDataAttachDo
Or(conds ...gen.Condition) IDataAttachDo
Select(conds ...field.Expr) IDataAttachDo
Where(conds ...gen.Condition) IDataAttachDo
Order(conds ...field.Expr) IDataAttachDo
Distinct(cols ...field.Expr) IDataAttachDo
Omit(cols ...field.Expr) IDataAttachDo
Join(table schema.Tabler, on ...field.Expr) IDataAttachDo
LeftJoin(table schema.Tabler, on ...field.Expr) IDataAttachDo
RightJoin(table schema.Tabler, on ...field.Expr) IDataAttachDo
Group(cols ...field.Expr) IDataAttachDo
Having(conds ...gen.Condition) IDataAttachDo
Limit(limit int) IDataAttachDo
Offset(offset int) IDataAttachDo
Count() (count int64, err error)
Scopes(funcs ...func(gen.Dao) gen.Dao) IDataAttachDo
Unscoped() IDataAttachDo
Create(values ...*model.DataAttach) error
CreateInBatches(values []*model.DataAttach, batchSize int) error
Save(values ...*model.DataAttach) error
First() (*model.DataAttach, error)
Take() (*model.DataAttach, error)
Last() (*model.DataAttach, error)
Find() ([]*model.DataAttach, error)
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.DataAttach, err error)
FindInBatches(result *[]*model.DataAttach, batchSize int, fc func(tx gen.Dao, batch int) error) error
Pluck(column field.Expr, dest interface{}) error
Delete(...*model.DataAttach) (info gen.ResultInfo, err error)
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
Updates(value interface{}) (info gen.ResultInfo, err error)
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
UpdateFrom(q gen.SubQuery) gen.Dao
Attrs(attrs ...field.AssignExpr) IDataAttachDo
Assign(attrs ...field.AssignExpr) IDataAttachDo
Joins(fields ...field.RelationField) IDataAttachDo
Preload(fields ...field.RelationField) IDataAttachDo
FirstOrInit() (*model.DataAttach, error)
FirstOrCreate() (*model.DataAttach, error)
FindByPage(offset int, limit int) (result []*model.DataAttach, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IDataAttachDo
UnderlyingDB() *gorm.DB
schema.Tabler
}
func (d dataAttachDo) Debug() IDataAttachDo {
return d.withDO(d.DO.Debug())
}
func (d dataAttachDo) WithContext(ctx context.Context) IDataAttachDo {
return d.withDO(d.DO.WithContext(ctx))
}
func (d dataAttachDo) ReadDB() IDataAttachDo {
return d.Clauses(dbresolver.Read)
}
func (d dataAttachDo) WriteDB() IDataAttachDo {
return d.Clauses(dbresolver.Write)
}
func (d dataAttachDo) Session(config *gorm.Session) IDataAttachDo {
return d.withDO(d.DO.Session(config))
}
func (d dataAttachDo) Clauses(conds ...clause.Expression) IDataAttachDo {
return d.withDO(d.DO.Clauses(conds...))
}
func (d dataAttachDo) Returning(value interface{}, columns ...string) IDataAttachDo {
return d.withDO(d.DO.Returning(value, columns...))
}
func (d dataAttachDo) Not(conds ...gen.Condition) IDataAttachDo {
return d.withDO(d.DO.Not(conds...))
}
func (d dataAttachDo) Or(conds ...gen.Condition) IDataAttachDo {
return d.withDO(d.DO.Or(conds...))
}
func (d dataAttachDo) Select(conds ...field.Expr) IDataAttachDo {
return d.withDO(d.DO.Select(conds...))
}
func (d dataAttachDo) Where(conds ...gen.Condition) IDataAttachDo {
return d.withDO(d.DO.Where(conds...))
}
func (d dataAttachDo) Order(conds ...field.Expr) IDataAttachDo {
return d.withDO(d.DO.Order(conds...))
}
func (d dataAttachDo) Distinct(cols ...field.Expr) IDataAttachDo {
return d.withDO(d.DO.Distinct(cols...))
}
func (d dataAttachDo) Omit(cols ...field.Expr) IDataAttachDo {
return d.withDO(d.DO.Omit(cols...))
}
func (d dataAttachDo) Join(table schema.Tabler, on ...field.Expr) IDataAttachDo {
return d.withDO(d.DO.Join(table, on...))
}
func (d dataAttachDo) LeftJoin(table schema.Tabler, on ...field.Expr) IDataAttachDo {
return d.withDO(d.DO.LeftJoin(table, on...))
}
func (d dataAttachDo) RightJoin(table schema.Tabler, on ...field.Expr) IDataAttachDo {
return d.withDO(d.DO.RightJoin(table, on...))
}
func (d dataAttachDo) Group(cols ...field.Expr) IDataAttachDo {
return d.withDO(d.DO.Group(cols...))
}
func (d dataAttachDo) Having(conds ...gen.Condition) IDataAttachDo {
return d.withDO(d.DO.Having(conds...))
}
func (d dataAttachDo) Limit(limit int) IDataAttachDo {
return d.withDO(d.DO.Limit(limit))
}
func (d dataAttachDo) Offset(offset int) IDataAttachDo {
return d.withDO(d.DO.Offset(offset))
}
func (d dataAttachDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IDataAttachDo {
return d.withDO(d.DO.Scopes(funcs...))
}
func (d dataAttachDo) Unscoped() IDataAttachDo {
return d.withDO(d.DO.Unscoped())
}
func (d dataAttachDo) Create(values ...*model.DataAttach) error {
if len(values) == 0 {
return nil
}
return d.DO.Create(values)
}
func (d dataAttachDo) CreateInBatches(values []*model.DataAttach, batchSize int) error {
return d.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 (d dataAttachDo) Save(values ...*model.DataAttach) error {
if len(values) == 0 {
return nil
}
return d.DO.Save(values)
}
func (d dataAttachDo) First() (*model.DataAttach, error) {
if result, err := d.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.DataAttach), nil
}
}
func (d dataAttachDo) Take() (*model.DataAttach, error) {
if result, err := d.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.DataAttach), nil
}
}
func (d dataAttachDo) Last() (*model.DataAttach, error) {
if result, err := d.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.DataAttach), nil
}
}
func (d dataAttachDo) Find() ([]*model.DataAttach, error) {
result, err := d.DO.Find()
return result.([]*model.DataAttach), err
}
func (d dataAttachDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.DataAttach, err error) {
buf := make([]*model.DataAttach, 0, batchSize)
err = d.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 (d dataAttachDo) FindInBatches(result *[]*model.DataAttach, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return d.DO.FindInBatches(result, batchSize, fc)
}
func (d dataAttachDo) Attrs(attrs ...field.AssignExpr) IDataAttachDo {
return d.withDO(d.DO.Attrs(attrs...))
}
func (d dataAttachDo) Assign(attrs ...field.AssignExpr) IDataAttachDo {
return d.withDO(d.DO.Assign(attrs...))
}
func (d dataAttachDo) Joins(fields ...field.RelationField) IDataAttachDo {
for _, _f := range fields {
d = *d.withDO(d.DO.Joins(_f))
}
return &d
}
func (d dataAttachDo) Preload(fields ...field.RelationField) IDataAttachDo {
for _, _f := range fields {
d = *d.withDO(d.DO.Preload(_f))
}
return &d
}
func (d dataAttachDo) FirstOrInit() (*model.DataAttach, error) {
if result, err := d.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.DataAttach), nil
}
}
func (d dataAttachDo) FirstOrCreate() (*model.DataAttach, error) {
if result, err := d.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.DataAttach), nil
}
}
func (d dataAttachDo) FindByPage(offset int, limit int) (result []*model.DataAttach, count int64, err error) {
result, err = d.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 = d.Offset(-1).Limit(-1).Count()
return
}
func (d dataAttachDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = d.Count()
if err != nil {
return
}
err = d.Offset(offset).Limit(limit).Scan(result)
return
}
func (d dataAttachDo) Scan(result interface{}) (err error) {
return d.DO.Scan(result)
}
func (d dataAttachDo) Delete(models ...*model.DataAttach) (result gen.ResultInfo, err error) {
return d.DO.Delete(models)
}
func (d *dataAttachDo) withDO(do gen.Dao) *dataAttachDo {
d.DO = *do.(*gen.DO)
return d
}

433
pkg/repo/game.gen.go Normal file
View File

@ -0,0 +1,433 @@
// 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 repo
import (
"context"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
"servicebase/pkg/model"
)
func newGame(db *gorm.DB, opts ...gen.DOOption) game {
_game := game{}
_game.gameDo.UseDB(db, opts...)
_game.gameDo.UseModel(&model.Game{})
tableName := _game.gameDo.TableName()
_game.ALL = field.NewAsterisk(tableName)
_game.ID = field.NewString(tableName, "id")
_game.Name = field.NewString(tableName, "name")
_game.Desc = field.NewString(tableName, "desc")
_game.Icon = field.NewString(tableName, "icon")
_game.Logo = field.NewString(tableName, "logo")
_game.Sort = field.NewInt32(tableName, "sort")
_game.State = field.NewInt32(tableName, "state")
_game.DeleteAt = field.NewField(tableName, "delete_at")
_game.CreateAt = field.NewTime(tableName, "create_at")
_game.CreateBy = field.NewString(tableName, "create_by")
_game.UpdateAt = field.NewTime(tableName, "update_at")
_game.UpdateBy = field.NewString(tableName, "update_by")
_game.fillFieldMap()
return _game
}
// game 交易游戏
type game struct {
gameDo gameDo
ALL field.Asterisk
ID field.String // 业务ID
Name field.String // 游戏名称
Desc field.String // 描述
Icon field.String // 图标
Logo field.String // logo
Sort field.Int32 // 排序
State field.Int32 // 状态1=启用 2=禁用
DeleteAt field.Field // del标志
CreateAt field.Time // 创建时间
CreateBy field.String // 创建人
UpdateAt field.Time // 更新时间
UpdateBy field.String // 更新人
fieldMap map[string]field.Expr
}
func (g game) Table(newTableName string) *game {
g.gameDo.UseTable(newTableName)
return g.updateTableName(newTableName)
}
func (g game) As(alias string) *game {
g.gameDo.DO = *(g.gameDo.As(alias).(*gen.DO))
return g.updateTableName(alias)
}
func (g *game) updateTableName(table string) *game {
g.ALL = field.NewAsterisk(table)
g.ID = field.NewString(table, "id")
g.Name = field.NewString(table, "name")
g.Desc = field.NewString(table, "desc")
g.Icon = field.NewString(table, "icon")
g.Logo = field.NewString(table, "logo")
g.Sort = field.NewInt32(table, "sort")
g.State = field.NewInt32(table, "state")
g.DeleteAt = field.NewField(table, "delete_at")
g.CreateAt = field.NewTime(table, "create_at")
g.CreateBy = field.NewString(table, "create_by")
g.UpdateAt = field.NewTime(table, "update_at")
g.UpdateBy = field.NewString(table, "update_by")
g.fillFieldMap()
return g
}
func (g *game) WithContext(ctx context.Context) IGameDo { return g.gameDo.WithContext(ctx) }
func (g game) TableName() string { return g.gameDo.TableName() }
func (g game) Alias() string { return g.gameDo.Alias() }
func (g game) Columns(cols ...field.Expr) gen.Columns { return g.gameDo.Columns(cols...) }
func (g *game) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := g.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (g *game) fillFieldMap() {
g.fieldMap = make(map[string]field.Expr, 12)
g.fieldMap["id"] = g.ID
g.fieldMap["name"] = g.Name
g.fieldMap["desc"] = g.Desc
g.fieldMap["icon"] = g.Icon
g.fieldMap["logo"] = g.Logo
g.fieldMap["sort"] = g.Sort
g.fieldMap["state"] = g.State
g.fieldMap["delete_at"] = g.DeleteAt
g.fieldMap["create_at"] = g.CreateAt
g.fieldMap["create_by"] = g.CreateBy
g.fieldMap["update_at"] = g.UpdateAt
g.fieldMap["update_by"] = g.UpdateBy
}
func (g game) clone(db *gorm.DB) game {
g.gameDo.ReplaceConnPool(db.Statement.ConnPool)
return g
}
func (g game) replaceDB(db *gorm.DB) game {
g.gameDo.ReplaceDB(db)
return g
}
type gameDo struct{ gen.DO }
type IGameDo interface {
gen.SubQuery
Debug() IGameDo
WithContext(ctx context.Context) IGameDo
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
ReplaceDB(db *gorm.DB)
ReadDB() IGameDo
WriteDB() IGameDo
As(alias string) gen.Dao
Session(config *gorm.Session) IGameDo
Columns(cols ...field.Expr) gen.Columns
Clauses(conds ...clause.Expression) IGameDo
Not(conds ...gen.Condition) IGameDo
Or(conds ...gen.Condition) IGameDo
Select(conds ...field.Expr) IGameDo
Where(conds ...gen.Condition) IGameDo
Order(conds ...field.Expr) IGameDo
Distinct(cols ...field.Expr) IGameDo
Omit(cols ...field.Expr) IGameDo
Join(table schema.Tabler, on ...field.Expr) IGameDo
LeftJoin(table schema.Tabler, on ...field.Expr) IGameDo
RightJoin(table schema.Tabler, on ...field.Expr) IGameDo
Group(cols ...field.Expr) IGameDo
Having(conds ...gen.Condition) IGameDo
Limit(limit int) IGameDo
Offset(offset int) IGameDo
Count() (count int64, err error)
Scopes(funcs ...func(gen.Dao) gen.Dao) IGameDo
Unscoped() IGameDo
Create(values ...*model.Game) error
CreateInBatches(values []*model.Game, batchSize int) error
Save(values ...*model.Game) error
First() (*model.Game, error)
Take() (*model.Game, error)
Last() (*model.Game, error)
Find() ([]*model.Game, error)
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Game, err error)
FindInBatches(result *[]*model.Game, batchSize int, fc func(tx gen.Dao, batch int) error) error
Pluck(column field.Expr, dest interface{}) error
Delete(...*model.Game) (info gen.ResultInfo, err error)
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
Updates(value interface{}) (info gen.ResultInfo, err error)
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
UpdateFrom(q gen.SubQuery) gen.Dao
Attrs(attrs ...field.AssignExpr) IGameDo
Assign(attrs ...field.AssignExpr) IGameDo
Joins(fields ...field.RelationField) IGameDo
Preload(fields ...field.RelationField) IGameDo
FirstOrInit() (*model.Game, error)
FirstOrCreate() (*model.Game, error)
FindByPage(offset int, limit int) (result []*model.Game, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IGameDo
UnderlyingDB() *gorm.DB
schema.Tabler
}
func (g gameDo) Debug() IGameDo {
return g.withDO(g.DO.Debug())
}
func (g gameDo) WithContext(ctx context.Context) IGameDo {
return g.withDO(g.DO.WithContext(ctx))
}
func (g gameDo) ReadDB() IGameDo {
return g.Clauses(dbresolver.Read)
}
func (g gameDo) WriteDB() IGameDo {
return g.Clauses(dbresolver.Write)
}
func (g gameDo) Session(config *gorm.Session) IGameDo {
return g.withDO(g.DO.Session(config))
}
func (g gameDo) Clauses(conds ...clause.Expression) IGameDo {
return g.withDO(g.DO.Clauses(conds...))
}
func (g gameDo) Returning(value interface{}, columns ...string) IGameDo {
return g.withDO(g.DO.Returning(value, columns...))
}
func (g gameDo) Not(conds ...gen.Condition) IGameDo {
return g.withDO(g.DO.Not(conds...))
}
func (g gameDo) Or(conds ...gen.Condition) IGameDo {
return g.withDO(g.DO.Or(conds...))
}
func (g gameDo) Select(conds ...field.Expr) IGameDo {
return g.withDO(g.DO.Select(conds...))
}
func (g gameDo) Where(conds ...gen.Condition) IGameDo {
return g.withDO(g.DO.Where(conds...))
}
func (g gameDo) Order(conds ...field.Expr) IGameDo {
return g.withDO(g.DO.Order(conds...))
}
func (g gameDo) Distinct(cols ...field.Expr) IGameDo {
return g.withDO(g.DO.Distinct(cols...))
}
func (g gameDo) Omit(cols ...field.Expr) IGameDo {
return g.withDO(g.DO.Omit(cols...))
}
func (g gameDo) Join(table schema.Tabler, on ...field.Expr) IGameDo {
return g.withDO(g.DO.Join(table, on...))
}
func (g gameDo) LeftJoin(table schema.Tabler, on ...field.Expr) IGameDo {
return g.withDO(g.DO.LeftJoin(table, on...))
}
func (g gameDo) RightJoin(table schema.Tabler, on ...field.Expr) IGameDo {
return g.withDO(g.DO.RightJoin(table, on...))
}
func (g gameDo) Group(cols ...field.Expr) IGameDo {
return g.withDO(g.DO.Group(cols...))
}
func (g gameDo) Having(conds ...gen.Condition) IGameDo {
return g.withDO(g.DO.Having(conds...))
}
func (g gameDo) Limit(limit int) IGameDo {
return g.withDO(g.DO.Limit(limit))
}
func (g gameDo) Offset(offset int) IGameDo {
return g.withDO(g.DO.Offset(offset))
}
func (g gameDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IGameDo {
return g.withDO(g.DO.Scopes(funcs...))
}
func (g gameDo) Unscoped() IGameDo {
return g.withDO(g.DO.Unscoped())
}
func (g gameDo) Create(values ...*model.Game) error {
if len(values) == 0 {
return nil
}
return g.DO.Create(values)
}
func (g gameDo) CreateInBatches(values []*model.Game, batchSize int) error {
return g.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 (g gameDo) Save(values ...*model.Game) error {
if len(values) == 0 {
return nil
}
return g.DO.Save(values)
}
func (g gameDo) First() (*model.Game, error) {
if result, err := g.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.Game), nil
}
}
func (g gameDo) Take() (*model.Game, error) {
if result, err := g.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.Game), nil
}
}
func (g gameDo) Last() (*model.Game, error) {
if result, err := g.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.Game), nil
}
}
func (g gameDo) Find() ([]*model.Game, error) {
result, err := g.DO.Find()
return result.([]*model.Game), err
}
func (g gameDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Game, err error) {
buf := make([]*model.Game, 0, batchSize)
err = g.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 (g gameDo) FindInBatches(result *[]*model.Game, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return g.DO.FindInBatches(result, batchSize, fc)
}
func (g gameDo) Attrs(attrs ...field.AssignExpr) IGameDo {
return g.withDO(g.DO.Attrs(attrs...))
}
func (g gameDo) Assign(attrs ...field.AssignExpr) IGameDo {
return g.withDO(g.DO.Assign(attrs...))
}
func (g gameDo) Joins(fields ...field.RelationField) IGameDo {
for _, _f := range fields {
g = *g.withDO(g.DO.Joins(_f))
}
return &g
}
func (g gameDo) Preload(fields ...field.RelationField) IGameDo {
for _, _f := range fields {
g = *g.withDO(g.DO.Preload(_f))
}
return &g
}
func (g gameDo) FirstOrInit() (*model.Game, error) {
if result, err := g.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.Game), nil
}
}
func (g gameDo) FirstOrCreate() (*model.Game, error) {
if result, err := g.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.Game), nil
}
}
func (g gameDo) FindByPage(offset int, limit int) (result []*model.Game, count int64, err error) {
result, err = g.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 = g.Offset(-1).Limit(-1).Count()
return
}
func (g gameDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = g.Count()
if err != nil {
return
}
err = g.Offset(offset).Limit(limit).Scan(result)
return
}
func (g gameDo) Scan(result interface{}) (err error) {
return g.DO.Scan(result)
}
func (g gameDo) Delete(models ...*model.Game) (result gen.ResultInfo, err error) {
return g.DO.Delete(models)
}
func (g *gameDo) withDO(do gen.Dao) *gameDo {
g.DO = *do.(*gen.DO)
return g
}

183
pkg/repo/gen.go Normal file
View File

@ -0,0 +1,183 @@
// 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 repo
import (
"context"
"database/sql"
"gorm.io/gorm"
"gorm.io/gen"
"gorm.io/plugin/dbresolver"
)
var (
Q = new(Query)
AdminPrivilege *adminPrivilege
AdminRole *adminRole
AdminRolePrivilege *adminRolePrivilege
AdminUser *adminUser
AdminUserRole *adminUserRole
DataAttach *dataAttach
Game *game
TradeCommodity *tradeCommodity
User *user
UserGameRole *userGameRole
UserGameRoleProp *userGameRoleProp
)
func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
*Q = *Use(db, opts...)
AdminPrivilege = &Q.AdminPrivilege
AdminRole = &Q.AdminRole
AdminRolePrivilege = &Q.AdminRolePrivilege
AdminUser = &Q.AdminUser
AdminUserRole = &Q.AdminUserRole
DataAttach = &Q.DataAttach
Game = &Q.Game
TradeCommodity = &Q.TradeCommodity
User = &Q.User
UserGameRole = &Q.UserGameRole
UserGameRoleProp = &Q.UserGameRoleProp
}
func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
return &Query{
db: db,
AdminPrivilege: newAdminPrivilege(db, opts...),
AdminRole: newAdminRole(db, opts...),
AdminRolePrivilege: newAdminRolePrivilege(db, opts...),
AdminUser: newAdminUser(db, opts...),
AdminUserRole: newAdminUserRole(db, opts...),
DataAttach: newDataAttach(db, opts...),
Game: newGame(db, opts...),
TradeCommodity: newTradeCommodity(db, opts...),
User: newUser(db, opts...),
UserGameRole: newUserGameRole(db, opts...),
UserGameRoleProp: newUserGameRoleProp(db, opts...),
}
}
type Query struct {
db *gorm.DB
AdminPrivilege adminPrivilege
AdminRole adminRole
AdminRolePrivilege adminRolePrivilege
AdminUser adminUser
AdminUserRole adminUserRole
DataAttach dataAttach
Game game
TradeCommodity tradeCommodity
User user
UserGameRole userGameRole
UserGameRoleProp userGameRoleProp
}
func (q *Query) Available() bool { return q.db != nil }
func (q *Query) clone(db *gorm.DB) *Query {
return &Query{
db: db,
AdminPrivilege: q.AdminPrivilege.clone(db),
AdminRole: q.AdminRole.clone(db),
AdminRolePrivilege: q.AdminRolePrivilege.clone(db),
AdminUser: q.AdminUser.clone(db),
AdminUserRole: q.AdminUserRole.clone(db),
DataAttach: q.DataAttach.clone(db),
Game: q.Game.clone(db),
TradeCommodity: q.TradeCommodity.clone(db),
User: q.User.clone(db),
UserGameRole: q.UserGameRole.clone(db),
UserGameRoleProp: q.UserGameRoleProp.clone(db),
}
}
func (q *Query) ReadDB() *Query {
return q.ReplaceDB(q.db.Clauses(dbresolver.Read))
}
func (q *Query) WriteDB() *Query {
return q.ReplaceDB(q.db.Clauses(dbresolver.Write))
}
func (q *Query) ReplaceDB(db *gorm.DB) *Query {
return &Query{
db: db,
AdminPrivilege: q.AdminPrivilege.replaceDB(db),
AdminRole: q.AdminRole.replaceDB(db),
AdminRolePrivilege: q.AdminRolePrivilege.replaceDB(db),
AdminUser: q.AdminUser.replaceDB(db),
AdminUserRole: q.AdminUserRole.replaceDB(db),
DataAttach: q.DataAttach.replaceDB(db),
Game: q.Game.replaceDB(db),
TradeCommodity: q.TradeCommodity.replaceDB(db),
User: q.User.replaceDB(db),
UserGameRole: q.UserGameRole.replaceDB(db),
UserGameRoleProp: q.UserGameRoleProp.replaceDB(db),
}
}
type queryCtx struct {
AdminPrivilege IAdminPrivilegeDo
AdminRole IAdminRoleDo
AdminRolePrivilege IAdminRolePrivilegeDo
AdminUser IAdminUserDo
AdminUserRole IAdminUserRoleDo
DataAttach IDataAttachDo
Game IGameDo
TradeCommodity ITradeCommodityDo
User IUserDo
UserGameRole IUserGameRoleDo
UserGameRoleProp IUserGameRolePropDo
}
func (q *Query) WithContext(ctx context.Context) *queryCtx {
return &queryCtx{
AdminPrivilege: q.AdminPrivilege.WithContext(ctx),
AdminRole: q.AdminRole.WithContext(ctx),
AdminRolePrivilege: q.AdminRolePrivilege.WithContext(ctx),
AdminUser: q.AdminUser.WithContext(ctx),
AdminUserRole: q.AdminUserRole.WithContext(ctx),
DataAttach: q.DataAttach.WithContext(ctx),
Game: q.Game.WithContext(ctx),
TradeCommodity: q.TradeCommodity.WithContext(ctx),
User: q.User.WithContext(ctx),
UserGameRole: q.UserGameRole.WithContext(ctx),
UserGameRoleProp: q.UserGameRoleProp.WithContext(ctx),
}
}
func (q *Query) Transaction(fc func(tx *Query) error, opts ...*sql.TxOptions) error {
return q.db.Transaction(func(tx *gorm.DB) error { return fc(q.clone(tx)) }, opts...)
}
func (q *Query) Begin(opts ...*sql.TxOptions) *QueryTx {
tx := q.db.Begin(opts...)
return &QueryTx{Query: q.clone(tx), Error: tx.Error}
}
type QueryTx struct {
*Query
Error error
}
func (q *QueryTx) Commit() error {
return q.db.Commit().Error
}
func (q *QueryTx) Rollback() error {
return q.db.Rollback().Error
}
func (q *QueryTx) SavePoint(name string) error {
return q.db.SavePoint(name).Error
}
func (q *QueryTx) RollbackTo(name string) error {
return q.db.RollbackTo(name).Error
}

View File

@ -0,0 +1,445 @@
// 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 repo
import (
"context"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
"servicebase/pkg/model"
)
func newTradeCommodity(db *gorm.DB, opts ...gen.DOOption) tradeCommodity {
_tradeCommodity := tradeCommodity{}
_tradeCommodity.tradeCommodityDo.UseDB(db, opts...)
_tradeCommodity.tradeCommodityDo.UseModel(&model.TradeCommodity{})
tableName := _tradeCommodity.tradeCommodityDo.TableName()
_tradeCommodity.ALL = field.NewAsterisk(tableName)
_tradeCommodity.ID = field.NewString(tableName, "id")
_tradeCommodity.CommodityType = field.NewString(tableName, "commodity_type")
_tradeCommodity.UserID = field.NewString(tableName, "user_id")
_tradeCommodity.CommodityID = field.NewString(tableName, "commodity_id")
_tradeCommodity.Desc = field.NewString(tableName, "desc")
_tradeCommodity.Price = field.NewInt32(tableName, "price")
_tradeCommodity.Icon = field.NewString(tableName, "icon")
_tradeCommodity.Logo = field.NewString(tableName, "logo")
_tradeCommodity.State = field.NewInt32(tableName, "state")
_tradeCommodity.DeleteAt = field.NewField(tableName, "delete_at")
_tradeCommodity.CreateAt = field.NewTime(tableName, "create_at")
_tradeCommodity.CreateBy = field.NewString(tableName, "create_by")
_tradeCommodity.UpdateAt = field.NewTime(tableName, "update_at")
_tradeCommodity.UpdateBy = field.NewString(tableName, "update_by")
_tradeCommodity.fillFieldMap()
return _tradeCommodity
}
// tradeCommodity 交易的商品
type tradeCommodity struct {
tradeCommodityDo tradeCommodityDo
ALL field.Asterisk
ID field.String // 业务ID
CommodityType field.String // GAME_ROLE=游戏角色
UserID field.String // 用户ID
CommodityID field.String // 如游戏角色IDuser_game_role的ID
Desc field.String // 描述
Price field.Int32 // 价格,单位为分
Icon field.String // 图标
Logo field.String // logo
State field.Int32 // 状态1=启用 2=禁用
DeleteAt field.Field // del标志
CreateAt field.Time // 创建时间
CreateBy field.String // 创建人
UpdateAt field.Time // 更新时间
UpdateBy field.String // 更新人
fieldMap map[string]field.Expr
}
func (t tradeCommodity) Table(newTableName string) *tradeCommodity {
t.tradeCommodityDo.UseTable(newTableName)
return t.updateTableName(newTableName)
}
func (t tradeCommodity) As(alias string) *tradeCommodity {
t.tradeCommodityDo.DO = *(t.tradeCommodityDo.As(alias).(*gen.DO))
return t.updateTableName(alias)
}
func (t *tradeCommodity) updateTableName(table string) *tradeCommodity {
t.ALL = field.NewAsterisk(table)
t.ID = field.NewString(table, "id")
t.CommodityType = field.NewString(table, "commodity_type")
t.UserID = field.NewString(table, "user_id")
t.CommodityID = field.NewString(table, "commodity_id")
t.Desc = field.NewString(table, "desc")
t.Price = field.NewInt32(table, "price")
t.Icon = field.NewString(table, "icon")
t.Logo = field.NewString(table, "logo")
t.State = field.NewInt32(table, "state")
t.DeleteAt = field.NewField(table, "delete_at")
t.CreateAt = field.NewTime(table, "create_at")
t.CreateBy = field.NewString(table, "create_by")
t.UpdateAt = field.NewTime(table, "update_at")
t.UpdateBy = field.NewString(table, "update_by")
t.fillFieldMap()
return t
}
func (t *tradeCommodity) WithContext(ctx context.Context) ITradeCommodityDo {
return t.tradeCommodityDo.WithContext(ctx)
}
func (t tradeCommodity) TableName() string { return t.tradeCommodityDo.TableName() }
func (t tradeCommodity) Alias() string { return t.tradeCommodityDo.Alias() }
func (t tradeCommodity) Columns(cols ...field.Expr) gen.Columns {
return t.tradeCommodityDo.Columns(cols...)
}
func (t *tradeCommodity) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := t.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (t *tradeCommodity) fillFieldMap() {
t.fieldMap = make(map[string]field.Expr, 14)
t.fieldMap["id"] = t.ID
t.fieldMap["commodity_type"] = t.CommodityType
t.fieldMap["user_id"] = t.UserID
t.fieldMap["commodity_id"] = t.CommodityID
t.fieldMap["desc"] = t.Desc
t.fieldMap["price"] = t.Price
t.fieldMap["icon"] = t.Icon
t.fieldMap["logo"] = t.Logo
t.fieldMap["state"] = t.State
t.fieldMap["delete_at"] = t.DeleteAt
t.fieldMap["create_at"] = t.CreateAt
t.fieldMap["create_by"] = t.CreateBy
t.fieldMap["update_at"] = t.UpdateAt
t.fieldMap["update_by"] = t.UpdateBy
}
func (t tradeCommodity) clone(db *gorm.DB) tradeCommodity {
t.tradeCommodityDo.ReplaceConnPool(db.Statement.ConnPool)
return t
}
func (t tradeCommodity) replaceDB(db *gorm.DB) tradeCommodity {
t.tradeCommodityDo.ReplaceDB(db)
return t
}
type tradeCommodityDo struct{ gen.DO }
type ITradeCommodityDo interface {
gen.SubQuery
Debug() ITradeCommodityDo
WithContext(ctx context.Context) ITradeCommodityDo
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
ReplaceDB(db *gorm.DB)
ReadDB() ITradeCommodityDo
WriteDB() ITradeCommodityDo
As(alias string) gen.Dao
Session(config *gorm.Session) ITradeCommodityDo
Columns(cols ...field.Expr) gen.Columns
Clauses(conds ...clause.Expression) ITradeCommodityDo
Not(conds ...gen.Condition) ITradeCommodityDo
Or(conds ...gen.Condition) ITradeCommodityDo
Select(conds ...field.Expr) ITradeCommodityDo
Where(conds ...gen.Condition) ITradeCommodityDo
Order(conds ...field.Expr) ITradeCommodityDo
Distinct(cols ...field.Expr) ITradeCommodityDo
Omit(cols ...field.Expr) ITradeCommodityDo
Join(table schema.Tabler, on ...field.Expr) ITradeCommodityDo
LeftJoin(table schema.Tabler, on ...field.Expr) ITradeCommodityDo
RightJoin(table schema.Tabler, on ...field.Expr) ITradeCommodityDo
Group(cols ...field.Expr) ITradeCommodityDo
Having(conds ...gen.Condition) ITradeCommodityDo
Limit(limit int) ITradeCommodityDo
Offset(offset int) ITradeCommodityDo
Count() (count int64, err error)
Scopes(funcs ...func(gen.Dao) gen.Dao) ITradeCommodityDo
Unscoped() ITradeCommodityDo
Create(values ...*model.TradeCommodity) error
CreateInBatches(values []*model.TradeCommodity, batchSize int) error
Save(values ...*model.TradeCommodity) error
First() (*model.TradeCommodity, error)
Take() (*model.TradeCommodity, error)
Last() (*model.TradeCommodity, error)
Find() ([]*model.TradeCommodity, error)
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.TradeCommodity, err error)
FindInBatches(result *[]*model.TradeCommodity, batchSize int, fc func(tx gen.Dao, batch int) error) error
Pluck(column field.Expr, dest interface{}) error
Delete(...*model.TradeCommodity) (info gen.ResultInfo, err error)
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
Updates(value interface{}) (info gen.ResultInfo, err error)
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
UpdateFrom(q gen.SubQuery) gen.Dao
Attrs(attrs ...field.AssignExpr) ITradeCommodityDo
Assign(attrs ...field.AssignExpr) ITradeCommodityDo
Joins(fields ...field.RelationField) ITradeCommodityDo
Preload(fields ...field.RelationField) ITradeCommodityDo
FirstOrInit() (*model.TradeCommodity, error)
FirstOrCreate() (*model.TradeCommodity, error)
FindByPage(offset int, limit int) (result []*model.TradeCommodity, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) ITradeCommodityDo
UnderlyingDB() *gorm.DB
schema.Tabler
}
func (t tradeCommodityDo) Debug() ITradeCommodityDo {
return t.withDO(t.DO.Debug())
}
func (t tradeCommodityDo) WithContext(ctx context.Context) ITradeCommodityDo {
return t.withDO(t.DO.WithContext(ctx))
}
func (t tradeCommodityDo) ReadDB() ITradeCommodityDo {
return t.Clauses(dbresolver.Read)
}
func (t tradeCommodityDo) WriteDB() ITradeCommodityDo {
return t.Clauses(dbresolver.Write)
}
func (t tradeCommodityDo) Session(config *gorm.Session) ITradeCommodityDo {
return t.withDO(t.DO.Session(config))
}
func (t tradeCommodityDo) Clauses(conds ...clause.Expression) ITradeCommodityDo {
return t.withDO(t.DO.Clauses(conds...))
}
func (t tradeCommodityDo) Returning(value interface{}, columns ...string) ITradeCommodityDo {
return t.withDO(t.DO.Returning(value, columns...))
}
func (t tradeCommodityDo) Not(conds ...gen.Condition) ITradeCommodityDo {
return t.withDO(t.DO.Not(conds...))
}
func (t tradeCommodityDo) Or(conds ...gen.Condition) ITradeCommodityDo {
return t.withDO(t.DO.Or(conds...))
}
func (t tradeCommodityDo) Select(conds ...field.Expr) ITradeCommodityDo {
return t.withDO(t.DO.Select(conds...))
}
func (t tradeCommodityDo) Where(conds ...gen.Condition) ITradeCommodityDo {
return t.withDO(t.DO.Where(conds...))
}
func (t tradeCommodityDo) Order(conds ...field.Expr) ITradeCommodityDo {
return t.withDO(t.DO.Order(conds...))
}
func (t tradeCommodityDo) Distinct(cols ...field.Expr) ITradeCommodityDo {
return t.withDO(t.DO.Distinct(cols...))
}
func (t tradeCommodityDo) Omit(cols ...field.Expr) ITradeCommodityDo {
return t.withDO(t.DO.Omit(cols...))
}
func (t tradeCommodityDo) Join(table schema.Tabler, on ...field.Expr) ITradeCommodityDo {
return t.withDO(t.DO.Join(table, on...))
}
func (t tradeCommodityDo) LeftJoin(table schema.Tabler, on ...field.Expr) ITradeCommodityDo {
return t.withDO(t.DO.LeftJoin(table, on...))
}
func (t tradeCommodityDo) RightJoin(table schema.Tabler, on ...field.Expr) ITradeCommodityDo {
return t.withDO(t.DO.RightJoin(table, on...))
}
func (t tradeCommodityDo) Group(cols ...field.Expr) ITradeCommodityDo {
return t.withDO(t.DO.Group(cols...))
}
func (t tradeCommodityDo) Having(conds ...gen.Condition) ITradeCommodityDo {
return t.withDO(t.DO.Having(conds...))
}
func (t tradeCommodityDo) Limit(limit int) ITradeCommodityDo {
return t.withDO(t.DO.Limit(limit))
}
func (t tradeCommodityDo) Offset(offset int) ITradeCommodityDo {
return t.withDO(t.DO.Offset(offset))
}
func (t tradeCommodityDo) Scopes(funcs ...func(gen.Dao) gen.Dao) ITradeCommodityDo {
return t.withDO(t.DO.Scopes(funcs...))
}
func (t tradeCommodityDo) Unscoped() ITradeCommodityDo {
return t.withDO(t.DO.Unscoped())
}
func (t tradeCommodityDo) Create(values ...*model.TradeCommodity) error {
if len(values) == 0 {
return nil
}
return t.DO.Create(values)
}
func (t tradeCommodityDo) CreateInBatches(values []*model.TradeCommodity, batchSize int) error {
return t.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 (t tradeCommodityDo) Save(values ...*model.TradeCommodity) error {
if len(values) == 0 {
return nil
}
return t.DO.Save(values)
}
func (t tradeCommodityDo) First() (*model.TradeCommodity, error) {
if result, err := t.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.TradeCommodity), nil
}
}
func (t tradeCommodityDo) Take() (*model.TradeCommodity, error) {
if result, err := t.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.TradeCommodity), nil
}
}
func (t tradeCommodityDo) Last() (*model.TradeCommodity, error) {
if result, err := t.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.TradeCommodity), nil
}
}
func (t tradeCommodityDo) Find() ([]*model.TradeCommodity, error) {
result, err := t.DO.Find()
return result.([]*model.TradeCommodity), err
}
func (t tradeCommodityDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.TradeCommodity, err error) {
buf := make([]*model.TradeCommodity, 0, batchSize)
err = t.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 (t tradeCommodityDo) FindInBatches(result *[]*model.TradeCommodity, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return t.DO.FindInBatches(result, batchSize, fc)
}
func (t tradeCommodityDo) Attrs(attrs ...field.AssignExpr) ITradeCommodityDo {
return t.withDO(t.DO.Attrs(attrs...))
}
func (t tradeCommodityDo) Assign(attrs ...field.AssignExpr) ITradeCommodityDo {
return t.withDO(t.DO.Assign(attrs...))
}
func (t tradeCommodityDo) Joins(fields ...field.RelationField) ITradeCommodityDo {
for _, _f := range fields {
t = *t.withDO(t.DO.Joins(_f))
}
return &t
}
func (t tradeCommodityDo) Preload(fields ...field.RelationField) ITradeCommodityDo {
for _, _f := range fields {
t = *t.withDO(t.DO.Preload(_f))
}
return &t
}
func (t tradeCommodityDo) FirstOrInit() (*model.TradeCommodity, error) {
if result, err := t.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.TradeCommodity), nil
}
}
func (t tradeCommodityDo) FirstOrCreate() (*model.TradeCommodity, error) {
if result, err := t.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.TradeCommodity), nil
}
}
func (t tradeCommodityDo) FindByPage(offset int, limit int) (result []*model.TradeCommodity, count int64, err error) {
result, err = t.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 = t.Offset(-1).Limit(-1).Count()
return
}
func (t tradeCommodityDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = t.Count()
if err != nil {
return
}
err = t.Offset(offset).Limit(limit).Scan(result)
return
}
func (t tradeCommodityDo) Scan(result interface{}) (err error) {
return t.DO.Scan(result)
}
func (t tradeCommodityDo) Delete(models ...*model.TradeCommodity) (result gen.ResultInfo, err error) {
return t.DO.Delete(models)
}
func (t *tradeCommodityDo) withDO(do gen.Dao) *tradeCommodityDo {
t.DO = *do.(*gen.DO)
return t
}

433
pkg/repo/user.gen.go Normal file
View File

@ -0,0 +1,433 @@
// 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 repo
import (
"context"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
"servicebase/pkg/model"
)
func newUser(db *gorm.DB, opts ...gen.DOOption) user {
_user := user{}
_user.userDo.UseDB(db, opts...)
_user.userDo.UseModel(&model.User{})
tableName := _user.userDo.TableName()
_user.ALL = field.NewAsterisk(tableName)
_user.ID = field.NewString(tableName, "id")
_user.No = field.NewString(tableName, "no")
_user.Nickname = field.NewString(tableName, "nickname")
_user.Sign = field.NewString(tableName, "sign")
_user.Avatar = field.NewString(tableName, "avatar")
_user.Password = field.NewString(tableName, "password")
_user.PassSalt = field.NewString(tableName, "pass_salt")
_user.WxOpenID = field.NewString(tableName, "wx_open_id")
_user.WxUnionID = field.NewString(tableName, "wx_union_id")
_user.DeleteAt = field.NewField(tableName, "delete_at")
_user.CreateAt = field.NewTime(tableName, "create_at")
_user.UpdateAt = field.NewTime(tableName, "update_at")
_user.fillFieldMap()
return _user
}
// user 用户
type user struct {
userDo userDo
ALL field.Asterisk
ID field.String // ID
No field.String // 用户号、用户名
Nickname field.String // 昵称
Sign field.String // 签名
Avatar field.String // 头像
Password field.String // 密码
PassSalt field.String // 密码盐
WxOpenID field.String // OPEN ID
WxUnionID field.String // UNION ID
DeleteAt field.Field // del标志
CreateAt field.Time // 创建时间
UpdateAt field.Time // 更新时间
fieldMap map[string]field.Expr
}
func (u user) Table(newTableName string) *user {
u.userDo.UseTable(newTableName)
return u.updateTableName(newTableName)
}
func (u user) As(alias string) *user {
u.userDo.DO = *(u.userDo.As(alias).(*gen.DO))
return u.updateTableName(alias)
}
func (u *user) updateTableName(table string) *user {
u.ALL = field.NewAsterisk(table)
u.ID = field.NewString(table, "id")
u.No = field.NewString(table, "no")
u.Nickname = field.NewString(table, "nickname")
u.Sign = field.NewString(table, "sign")
u.Avatar = field.NewString(table, "avatar")
u.Password = field.NewString(table, "password")
u.PassSalt = field.NewString(table, "pass_salt")
u.WxOpenID = field.NewString(table, "wx_open_id")
u.WxUnionID = field.NewString(table, "wx_union_id")
u.DeleteAt = field.NewField(table, "delete_at")
u.CreateAt = field.NewTime(table, "create_at")
u.UpdateAt = field.NewTime(table, "update_at")
u.fillFieldMap()
return u
}
func (u *user) WithContext(ctx context.Context) IUserDo { return u.userDo.WithContext(ctx) }
func (u user) TableName() string { return u.userDo.TableName() }
func (u user) Alias() string { return u.userDo.Alias() }
func (u user) Columns(cols ...field.Expr) gen.Columns { return u.userDo.Columns(cols...) }
func (u *user) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := u.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (u *user) fillFieldMap() {
u.fieldMap = make(map[string]field.Expr, 12)
u.fieldMap["id"] = u.ID
u.fieldMap["no"] = u.No
u.fieldMap["nickname"] = u.Nickname
u.fieldMap["sign"] = u.Sign
u.fieldMap["avatar"] = u.Avatar
u.fieldMap["password"] = u.Password
u.fieldMap["pass_salt"] = u.PassSalt
u.fieldMap["wx_open_id"] = u.WxOpenID
u.fieldMap["wx_union_id"] = u.WxUnionID
u.fieldMap["delete_at"] = u.DeleteAt
u.fieldMap["create_at"] = u.CreateAt
u.fieldMap["update_at"] = u.UpdateAt
}
func (u user) clone(db *gorm.DB) user {
u.userDo.ReplaceConnPool(db.Statement.ConnPool)
return u
}
func (u user) replaceDB(db *gorm.DB) user {
u.userDo.ReplaceDB(db)
return u
}
type userDo struct{ gen.DO }
type IUserDo interface {
gen.SubQuery
Debug() IUserDo
WithContext(ctx context.Context) IUserDo
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
ReplaceDB(db *gorm.DB)
ReadDB() IUserDo
WriteDB() IUserDo
As(alias string) gen.Dao
Session(config *gorm.Session) IUserDo
Columns(cols ...field.Expr) gen.Columns
Clauses(conds ...clause.Expression) IUserDo
Not(conds ...gen.Condition) IUserDo
Or(conds ...gen.Condition) IUserDo
Select(conds ...field.Expr) IUserDo
Where(conds ...gen.Condition) IUserDo
Order(conds ...field.Expr) IUserDo
Distinct(cols ...field.Expr) IUserDo
Omit(cols ...field.Expr) IUserDo
Join(table schema.Tabler, on ...field.Expr) IUserDo
LeftJoin(table schema.Tabler, on ...field.Expr) IUserDo
RightJoin(table schema.Tabler, on ...field.Expr) IUserDo
Group(cols ...field.Expr) IUserDo
Having(conds ...gen.Condition) IUserDo
Limit(limit int) IUserDo
Offset(offset int) IUserDo
Count() (count int64, err error)
Scopes(funcs ...func(gen.Dao) gen.Dao) IUserDo
Unscoped() IUserDo
Create(values ...*model.User) error
CreateInBatches(values []*model.User, batchSize int) error
Save(values ...*model.User) error
First() (*model.User, error)
Take() (*model.User, error)
Last() (*model.User, error)
Find() ([]*model.User, error)
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.User, err error)
FindInBatches(result *[]*model.User, batchSize int, fc func(tx gen.Dao, batch int) error) error
Pluck(column field.Expr, dest interface{}) error
Delete(...*model.User) (info gen.ResultInfo, err error)
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
Updates(value interface{}) (info gen.ResultInfo, err error)
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
UpdateFrom(q gen.SubQuery) gen.Dao
Attrs(attrs ...field.AssignExpr) IUserDo
Assign(attrs ...field.AssignExpr) IUserDo
Joins(fields ...field.RelationField) IUserDo
Preload(fields ...field.RelationField) IUserDo
FirstOrInit() (*model.User, error)
FirstOrCreate() (*model.User, error)
FindByPage(offset int, limit int) (result []*model.User, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IUserDo
UnderlyingDB() *gorm.DB
schema.Tabler
}
func (u userDo) Debug() IUserDo {
return u.withDO(u.DO.Debug())
}
func (u userDo) WithContext(ctx context.Context) IUserDo {
return u.withDO(u.DO.WithContext(ctx))
}
func (u userDo) ReadDB() IUserDo {
return u.Clauses(dbresolver.Read)
}
func (u userDo) WriteDB() IUserDo {
return u.Clauses(dbresolver.Write)
}
func (u userDo) Session(config *gorm.Session) IUserDo {
return u.withDO(u.DO.Session(config))
}
func (u userDo) Clauses(conds ...clause.Expression) IUserDo {
return u.withDO(u.DO.Clauses(conds...))
}
func (u userDo) Returning(value interface{}, columns ...string) IUserDo {
return u.withDO(u.DO.Returning(value, columns...))
}
func (u userDo) Not(conds ...gen.Condition) IUserDo {
return u.withDO(u.DO.Not(conds...))
}
func (u userDo) Or(conds ...gen.Condition) IUserDo {
return u.withDO(u.DO.Or(conds...))
}
func (u userDo) Select(conds ...field.Expr) IUserDo {
return u.withDO(u.DO.Select(conds...))
}
func (u userDo) Where(conds ...gen.Condition) IUserDo {
return u.withDO(u.DO.Where(conds...))
}
func (u userDo) Order(conds ...field.Expr) IUserDo {
return u.withDO(u.DO.Order(conds...))
}
func (u userDo) Distinct(cols ...field.Expr) IUserDo {
return u.withDO(u.DO.Distinct(cols...))
}
func (u userDo) Omit(cols ...field.Expr) IUserDo {
return u.withDO(u.DO.Omit(cols...))
}
func (u userDo) Join(table schema.Tabler, on ...field.Expr) IUserDo {
return u.withDO(u.DO.Join(table, on...))
}
func (u userDo) LeftJoin(table schema.Tabler, on ...field.Expr) IUserDo {
return u.withDO(u.DO.LeftJoin(table, on...))
}
func (u userDo) RightJoin(table schema.Tabler, on ...field.Expr) IUserDo {
return u.withDO(u.DO.RightJoin(table, on...))
}
func (u userDo) Group(cols ...field.Expr) IUserDo {
return u.withDO(u.DO.Group(cols...))
}
func (u userDo) Having(conds ...gen.Condition) IUserDo {
return u.withDO(u.DO.Having(conds...))
}
func (u userDo) Limit(limit int) IUserDo {
return u.withDO(u.DO.Limit(limit))
}
func (u userDo) Offset(offset int) IUserDo {
return u.withDO(u.DO.Offset(offset))
}
func (u userDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IUserDo {
return u.withDO(u.DO.Scopes(funcs...))
}
func (u userDo) Unscoped() IUserDo {
return u.withDO(u.DO.Unscoped())
}
func (u userDo) Create(values ...*model.User) error {
if len(values) == 0 {
return nil
}
return u.DO.Create(values)
}
func (u userDo) CreateInBatches(values []*model.User, batchSize int) error {
return u.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 (u userDo) Save(values ...*model.User) error {
if len(values) == 0 {
return nil
}
return u.DO.Save(values)
}
func (u userDo) First() (*model.User, error) {
if result, err := u.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.User), nil
}
}
func (u userDo) Take() (*model.User, error) {
if result, err := u.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.User), nil
}
}
func (u userDo) Last() (*model.User, error) {
if result, err := u.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.User), nil
}
}
func (u userDo) Find() ([]*model.User, error) {
result, err := u.DO.Find()
return result.([]*model.User), err
}
func (u userDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.User, err error) {
buf := make([]*model.User, 0, batchSize)
err = u.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 (u userDo) FindInBatches(result *[]*model.User, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return u.DO.FindInBatches(result, batchSize, fc)
}
func (u userDo) Attrs(attrs ...field.AssignExpr) IUserDo {
return u.withDO(u.DO.Attrs(attrs...))
}
func (u userDo) Assign(attrs ...field.AssignExpr) IUserDo {
return u.withDO(u.DO.Assign(attrs...))
}
func (u userDo) Joins(fields ...field.RelationField) IUserDo {
for _, _f := range fields {
u = *u.withDO(u.DO.Joins(_f))
}
return &u
}
func (u userDo) Preload(fields ...field.RelationField) IUserDo {
for _, _f := range fields {
u = *u.withDO(u.DO.Preload(_f))
}
return &u
}
func (u userDo) FirstOrInit() (*model.User, error) {
if result, err := u.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.User), nil
}
}
func (u userDo) FirstOrCreate() (*model.User, error) {
if result, err := u.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.User), nil
}
}
func (u userDo) FindByPage(offset int, limit int) (result []*model.User, count int64, err error) {
result, err = u.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 = u.Offset(-1).Limit(-1).Count()
return
}
func (u userDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = u.Count()
if err != nil {
return
}
err = u.Offset(offset).Limit(limit).Scan(result)
return
}
func (u userDo) Scan(result interface{}) (err error) {
return u.DO.Scan(result)
}
func (u userDo) Delete(models ...*model.User) (result gen.ResultInfo, err error) {
return u.DO.Delete(models)
}
func (u *userDo) withDO(do gen.Dao) *userDo {
u.DO = *do.(*gen.DO)
return u
}

View File

@ -0,0 +1,441 @@
// 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 repo
import (
"context"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
"servicebase/pkg/model"
)
func newUserGameRole(db *gorm.DB, opts ...gen.DOOption) userGameRole {
_userGameRole := userGameRole{}
_userGameRole.userGameRoleDo.UseDB(db, opts...)
_userGameRole.userGameRoleDo.UseModel(&model.UserGameRole{})
tableName := _userGameRole.userGameRoleDo.TableName()
_userGameRole.ALL = field.NewAsterisk(tableName)
_userGameRole.ID = field.NewString(tableName, "id")
_userGameRole.GameID = field.NewString(tableName, "game_id")
_userGameRole.GameRoleName = field.NewString(tableName, "game_role_name")
_userGameRole.GameRoleID = field.NewString(tableName, "game_role_id")
_userGameRole.Desc = field.NewString(tableName, "desc")
_userGameRole.Icon = field.NewString(tableName, "icon")
_userGameRole.Logo = field.NewString(tableName, "logo")
_userGameRole.State = field.NewInt32(tableName, "state")
_userGameRole.DeleteAt = field.NewField(tableName, "delete_at")
_userGameRole.CreateAt = field.NewTime(tableName, "create_at")
_userGameRole.CreateBy = field.NewString(tableName, "create_by")
_userGameRole.UpdateAt = field.NewTime(tableName, "update_at")
_userGameRole.UpdateBy = field.NewString(tableName, "update_by")
_userGameRole.fillFieldMap()
return _userGameRole
}
// userGameRole 用户的游戏角色
type userGameRole struct {
userGameRoleDo userGameRoleDo
ALL field.Asterisk
ID field.String // 业务ID
GameID field.String // 游戏
GameRoleName field.String // 角色名称
GameRoleID field.String // 角色ID
Desc field.String // 描述
Icon field.String // 图标
Logo field.String // logo
State field.Int32 // 状态1=启用 2=禁用
DeleteAt field.Field // del标志
CreateAt field.Time // 创建时间
CreateBy field.String // 创建人
UpdateAt field.Time // 更新时间
UpdateBy field.String // 更新人
fieldMap map[string]field.Expr
}
func (u userGameRole) Table(newTableName string) *userGameRole {
u.userGameRoleDo.UseTable(newTableName)
return u.updateTableName(newTableName)
}
func (u userGameRole) As(alias string) *userGameRole {
u.userGameRoleDo.DO = *(u.userGameRoleDo.As(alias).(*gen.DO))
return u.updateTableName(alias)
}
func (u *userGameRole) updateTableName(table string) *userGameRole {
u.ALL = field.NewAsterisk(table)
u.ID = field.NewString(table, "id")
u.GameID = field.NewString(table, "game_id")
u.GameRoleName = field.NewString(table, "game_role_name")
u.GameRoleID = field.NewString(table, "game_role_id")
u.Desc = field.NewString(table, "desc")
u.Icon = field.NewString(table, "icon")
u.Logo = field.NewString(table, "logo")
u.State = field.NewInt32(table, "state")
u.DeleteAt = field.NewField(table, "delete_at")
u.CreateAt = field.NewTime(table, "create_at")
u.CreateBy = field.NewString(table, "create_by")
u.UpdateAt = field.NewTime(table, "update_at")
u.UpdateBy = field.NewString(table, "update_by")
u.fillFieldMap()
return u
}
func (u *userGameRole) WithContext(ctx context.Context) IUserGameRoleDo {
return u.userGameRoleDo.WithContext(ctx)
}
func (u userGameRole) TableName() string { return u.userGameRoleDo.TableName() }
func (u userGameRole) Alias() string { return u.userGameRoleDo.Alias() }
func (u userGameRole) Columns(cols ...field.Expr) gen.Columns {
return u.userGameRoleDo.Columns(cols...)
}
func (u *userGameRole) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := u.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (u *userGameRole) fillFieldMap() {
u.fieldMap = make(map[string]field.Expr, 13)
u.fieldMap["id"] = u.ID
u.fieldMap["game_id"] = u.GameID
u.fieldMap["game_role_name"] = u.GameRoleName
u.fieldMap["game_role_id"] = u.GameRoleID
u.fieldMap["desc"] = u.Desc
u.fieldMap["icon"] = u.Icon
u.fieldMap["logo"] = u.Logo
u.fieldMap["state"] = u.State
u.fieldMap["delete_at"] = u.DeleteAt
u.fieldMap["create_at"] = u.CreateAt
u.fieldMap["create_by"] = u.CreateBy
u.fieldMap["update_at"] = u.UpdateAt
u.fieldMap["update_by"] = u.UpdateBy
}
func (u userGameRole) clone(db *gorm.DB) userGameRole {
u.userGameRoleDo.ReplaceConnPool(db.Statement.ConnPool)
return u
}
func (u userGameRole) replaceDB(db *gorm.DB) userGameRole {
u.userGameRoleDo.ReplaceDB(db)
return u
}
type userGameRoleDo struct{ gen.DO }
type IUserGameRoleDo interface {
gen.SubQuery
Debug() IUserGameRoleDo
WithContext(ctx context.Context) IUserGameRoleDo
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
ReplaceDB(db *gorm.DB)
ReadDB() IUserGameRoleDo
WriteDB() IUserGameRoleDo
As(alias string) gen.Dao
Session(config *gorm.Session) IUserGameRoleDo
Columns(cols ...field.Expr) gen.Columns
Clauses(conds ...clause.Expression) IUserGameRoleDo
Not(conds ...gen.Condition) IUserGameRoleDo
Or(conds ...gen.Condition) IUserGameRoleDo
Select(conds ...field.Expr) IUserGameRoleDo
Where(conds ...gen.Condition) IUserGameRoleDo
Order(conds ...field.Expr) IUserGameRoleDo
Distinct(cols ...field.Expr) IUserGameRoleDo
Omit(cols ...field.Expr) IUserGameRoleDo
Join(table schema.Tabler, on ...field.Expr) IUserGameRoleDo
LeftJoin(table schema.Tabler, on ...field.Expr) IUserGameRoleDo
RightJoin(table schema.Tabler, on ...field.Expr) IUserGameRoleDo
Group(cols ...field.Expr) IUserGameRoleDo
Having(conds ...gen.Condition) IUserGameRoleDo
Limit(limit int) IUserGameRoleDo
Offset(offset int) IUserGameRoleDo
Count() (count int64, err error)
Scopes(funcs ...func(gen.Dao) gen.Dao) IUserGameRoleDo
Unscoped() IUserGameRoleDo
Create(values ...*model.UserGameRole) error
CreateInBatches(values []*model.UserGameRole, batchSize int) error
Save(values ...*model.UserGameRole) error
First() (*model.UserGameRole, error)
Take() (*model.UserGameRole, error)
Last() (*model.UserGameRole, error)
Find() ([]*model.UserGameRole, error)
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.UserGameRole, err error)
FindInBatches(result *[]*model.UserGameRole, batchSize int, fc func(tx gen.Dao, batch int) error) error
Pluck(column field.Expr, dest interface{}) error
Delete(...*model.UserGameRole) (info gen.ResultInfo, err error)
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
Updates(value interface{}) (info gen.ResultInfo, err error)
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
UpdateFrom(q gen.SubQuery) gen.Dao
Attrs(attrs ...field.AssignExpr) IUserGameRoleDo
Assign(attrs ...field.AssignExpr) IUserGameRoleDo
Joins(fields ...field.RelationField) IUserGameRoleDo
Preload(fields ...field.RelationField) IUserGameRoleDo
FirstOrInit() (*model.UserGameRole, error)
FirstOrCreate() (*model.UserGameRole, error)
FindByPage(offset int, limit int) (result []*model.UserGameRole, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IUserGameRoleDo
UnderlyingDB() *gorm.DB
schema.Tabler
}
func (u userGameRoleDo) Debug() IUserGameRoleDo {
return u.withDO(u.DO.Debug())
}
func (u userGameRoleDo) WithContext(ctx context.Context) IUserGameRoleDo {
return u.withDO(u.DO.WithContext(ctx))
}
func (u userGameRoleDo) ReadDB() IUserGameRoleDo {
return u.Clauses(dbresolver.Read)
}
func (u userGameRoleDo) WriteDB() IUserGameRoleDo {
return u.Clauses(dbresolver.Write)
}
func (u userGameRoleDo) Session(config *gorm.Session) IUserGameRoleDo {
return u.withDO(u.DO.Session(config))
}
func (u userGameRoleDo) Clauses(conds ...clause.Expression) IUserGameRoleDo {
return u.withDO(u.DO.Clauses(conds...))
}
func (u userGameRoleDo) Returning(value interface{}, columns ...string) IUserGameRoleDo {
return u.withDO(u.DO.Returning(value, columns...))
}
func (u userGameRoleDo) Not(conds ...gen.Condition) IUserGameRoleDo {
return u.withDO(u.DO.Not(conds...))
}
func (u userGameRoleDo) Or(conds ...gen.Condition) IUserGameRoleDo {
return u.withDO(u.DO.Or(conds...))
}
func (u userGameRoleDo) Select(conds ...field.Expr) IUserGameRoleDo {
return u.withDO(u.DO.Select(conds...))
}
func (u userGameRoleDo) Where(conds ...gen.Condition) IUserGameRoleDo {
return u.withDO(u.DO.Where(conds...))
}
func (u userGameRoleDo) Order(conds ...field.Expr) IUserGameRoleDo {
return u.withDO(u.DO.Order(conds...))
}
func (u userGameRoleDo) Distinct(cols ...field.Expr) IUserGameRoleDo {
return u.withDO(u.DO.Distinct(cols...))
}
func (u userGameRoleDo) Omit(cols ...field.Expr) IUserGameRoleDo {
return u.withDO(u.DO.Omit(cols...))
}
func (u userGameRoleDo) Join(table schema.Tabler, on ...field.Expr) IUserGameRoleDo {
return u.withDO(u.DO.Join(table, on...))
}
func (u userGameRoleDo) LeftJoin(table schema.Tabler, on ...field.Expr) IUserGameRoleDo {
return u.withDO(u.DO.LeftJoin(table, on...))
}
func (u userGameRoleDo) RightJoin(table schema.Tabler, on ...field.Expr) IUserGameRoleDo {
return u.withDO(u.DO.RightJoin(table, on...))
}
func (u userGameRoleDo) Group(cols ...field.Expr) IUserGameRoleDo {
return u.withDO(u.DO.Group(cols...))
}
func (u userGameRoleDo) Having(conds ...gen.Condition) IUserGameRoleDo {
return u.withDO(u.DO.Having(conds...))
}
func (u userGameRoleDo) Limit(limit int) IUserGameRoleDo {
return u.withDO(u.DO.Limit(limit))
}
func (u userGameRoleDo) Offset(offset int) IUserGameRoleDo {
return u.withDO(u.DO.Offset(offset))
}
func (u userGameRoleDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IUserGameRoleDo {
return u.withDO(u.DO.Scopes(funcs...))
}
func (u userGameRoleDo) Unscoped() IUserGameRoleDo {
return u.withDO(u.DO.Unscoped())
}
func (u userGameRoleDo) Create(values ...*model.UserGameRole) error {
if len(values) == 0 {
return nil
}
return u.DO.Create(values)
}
func (u userGameRoleDo) CreateInBatches(values []*model.UserGameRole, batchSize int) error {
return u.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 (u userGameRoleDo) Save(values ...*model.UserGameRole) error {
if len(values) == 0 {
return nil
}
return u.DO.Save(values)
}
func (u userGameRoleDo) First() (*model.UserGameRole, error) {
if result, err := u.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.UserGameRole), nil
}
}
func (u userGameRoleDo) Take() (*model.UserGameRole, error) {
if result, err := u.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.UserGameRole), nil
}
}
func (u userGameRoleDo) Last() (*model.UserGameRole, error) {
if result, err := u.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.UserGameRole), nil
}
}
func (u userGameRoleDo) Find() ([]*model.UserGameRole, error) {
result, err := u.DO.Find()
return result.([]*model.UserGameRole), err
}
func (u userGameRoleDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.UserGameRole, err error) {
buf := make([]*model.UserGameRole, 0, batchSize)
err = u.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 (u userGameRoleDo) FindInBatches(result *[]*model.UserGameRole, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return u.DO.FindInBatches(result, batchSize, fc)
}
func (u userGameRoleDo) Attrs(attrs ...field.AssignExpr) IUserGameRoleDo {
return u.withDO(u.DO.Attrs(attrs...))
}
func (u userGameRoleDo) Assign(attrs ...field.AssignExpr) IUserGameRoleDo {
return u.withDO(u.DO.Assign(attrs...))
}
func (u userGameRoleDo) Joins(fields ...field.RelationField) IUserGameRoleDo {
for _, _f := range fields {
u = *u.withDO(u.DO.Joins(_f))
}
return &u
}
func (u userGameRoleDo) Preload(fields ...field.RelationField) IUserGameRoleDo {
for _, _f := range fields {
u = *u.withDO(u.DO.Preload(_f))
}
return &u
}
func (u userGameRoleDo) FirstOrInit() (*model.UserGameRole, error) {
if result, err := u.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.UserGameRole), nil
}
}
func (u userGameRoleDo) FirstOrCreate() (*model.UserGameRole, error) {
if result, err := u.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.UserGameRole), nil
}
}
func (u userGameRoleDo) FindByPage(offset int, limit int) (result []*model.UserGameRole, count int64, err error) {
result, err = u.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 = u.Offset(-1).Limit(-1).Count()
return
}
func (u userGameRoleDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = u.Count()
if err != nil {
return
}
err = u.Offset(offset).Limit(limit).Scan(result)
return
}
func (u userGameRoleDo) Scan(result interface{}) (err error) {
return u.DO.Scan(result)
}
func (u userGameRoleDo) Delete(models ...*model.UserGameRole) (result gen.ResultInfo, err error) {
return u.DO.Delete(models)
}
func (u *userGameRoleDo) withDO(do gen.Dao) *userGameRoleDo {
u.DO = *do.(*gen.DO)
return u
}

View File

@ -0,0 +1,453 @@
// 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 repo
import (
"context"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
"servicebase/pkg/model"
)
func newUserGameRoleProp(db *gorm.DB, opts ...gen.DOOption) userGameRoleProp {
_userGameRoleProp := userGameRoleProp{}
_userGameRoleProp.userGameRolePropDo.UseDB(db, opts...)
_userGameRoleProp.userGameRolePropDo.UseModel(&model.UserGameRoleProp{})
tableName := _userGameRoleProp.userGameRolePropDo.TableName()
_userGameRoleProp.ALL = field.NewAsterisk(tableName)
_userGameRoleProp.ID = field.NewString(tableName, "id")
_userGameRoleProp.UserID = field.NewString(tableName, "user_id")
_userGameRoleProp.GameID = field.NewString(tableName, "game_id")
_userGameRoleProp.RoleID = field.NewString(tableName, "role_id")
_userGameRoleProp.Type = field.NewString(tableName, "type")
_userGameRoleProp.Title = field.NewString(tableName, "title")
_userGameRoleProp.Content = field.NewString(tableName, "content")
_userGameRoleProp.URL = field.NewString(tableName, "url")
_userGameRoleProp.Ext = field.NewString(tableName, "ext")
_userGameRoleProp.State = field.NewInt32(tableName, "state")
_userGameRoleProp.Sort = field.NewInt32(tableName, "sort")
_userGameRoleProp.DeleteAt = field.NewField(tableName, "delete_at")
_userGameRoleProp.CreateAt = field.NewTime(tableName, "create_at")
_userGameRoleProp.CreateBy = field.NewString(tableName, "create_by")
_userGameRoleProp.UpdateAt = field.NewTime(tableName, "update_at")
_userGameRoleProp.UpdateBy = field.NewString(tableName, "update_by")
_userGameRoleProp.fillFieldMap()
return _userGameRoleProp
}
// userGameRoleProp 用户的游戏角色属性
type userGameRoleProp struct {
userGameRolePropDo userGameRolePropDo
ALL field.Asterisk
ID field.String // 业务ID
UserID field.String // 用户ID
GameID field.String // 游戏
RoleID field.String // 角色IDuser_game_role的ID
Type field.String // TEXT=文字 SKIN=皮肤
Title field.String // 标题
Content field.String // 内容
URL field.String // 链接
Ext field.String // 扩展字段
State field.Int32 // 状态1=启用 2=禁用
Sort field.Int32 // 排序
DeleteAt field.Field // del标志
CreateAt field.Time // 创建时间
CreateBy field.String // 创建人
UpdateAt field.Time // 更新时间
UpdateBy field.String // 更新人
fieldMap map[string]field.Expr
}
func (u userGameRoleProp) Table(newTableName string) *userGameRoleProp {
u.userGameRolePropDo.UseTable(newTableName)
return u.updateTableName(newTableName)
}
func (u userGameRoleProp) As(alias string) *userGameRoleProp {
u.userGameRolePropDo.DO = *(u.userGameRolePropDo.As(alias).(*gen.DO))
return u.updateTableName(alias)
}
func (u *userGameRoleProp) updateTableName(table string) *userGameRoleProp {
u.ALL = field.NewAsterisk(table)
u.ID = field.NewString(table, "id")
u.UserID = field.NewString(table, "user_id")
u.GameID = field.NewString(table, "game_id")
u.RoleID = field.NewString(table, "role_id")
u.Type = field.NewString(table, "type")
u.Title = field.NewString(table, "title")
u.Content = field.NewString(table, "content")
u.URL = field.NewString(table, "url")
u.Ext = field.NewString(table, "ext")
u.State = field.NewInt32(table, "state")
u.Sort = field.NewInt32(table, "sort")
u.DeleteAt = field.NewField(table, "delete_at")
u.CreateAt = field.NewTime(table, "create_at")
u.CreateBy = field.NewString(table, "create_by")
u.UpdateAt = field.NewTime(table, "update_at")
u.UpdateBy = field.NewString(table, "update_by")
u.fillFieldMap()
return u
}
func (u *userGameRoleProp) WithContext(ctx context.Context) IUserGameRolePropDo {
return u.userGameRolePropDo.WithContext(ctx)
}
func (u userGameRoleProp) TableName() string { return u.userGameRolePropDo.TableName() }
func (u userGameRoleProp) Alias() string { return u.userGameRolePropDo.Alias() }
func (u userGameRoleProp) Columns(cols ...field.Expr) gen.Columns {
return u.userGameRolePropDo.Columns(cols...)
}
func (u *userGameRoleProp) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := u.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (u *userGameRoleProp) fillFieldMap() {
u.fieldMap = make(map[string]field.Expr, 16)
u.fieldMap["id"] = u.ID
u.fieldMap["user_id"] = u.UserID
u.fieldMap["game_id"] = u.GameID
u.fieldMap["role_id"] = u.RoleID
u.fieldMap["type"] = u.Type
u.fieldMap["title"] = u.Title
u.fieldMap["content"] = u.Content
u.fieldMap["url"] = u.URL
u.fieldMap["ext"] = u.Ext
u.fieldMap["state"] = u.State
u.fieldMap["sort"] = u.Sort
u.fieldMap["delete_at"] = u.DeleteAt
u.fieldMap["create_at"] = u.CreateAt
u.fieldMap["create_by"] = u.CreateBy
u.fieldMap["update_at"] = u.UpdateAt
u.fieldMap["update_by"] = u.UpdateBy
}
func (u userGameRoleProp) clone(db *gorm.DB) userGameRoleProp {
u.userGameRolePropDo.ReplaceConnPool(db.Statement.ConnPool)
return u
}
func (u userGameRoleProp) replaceDB(db *gorm.DB) userGameRoleProp {
u.userGameRolePropDo.ReplaceDB(db)
return u
}
type userGameRolePropDo struct{ gen.DO }
type IUserGameRolePropDo interface {
gen.SubQuery
Debug() IUserGameRolePropDo
WithContext(ctx context.Context) IUserGameRolePropDo
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
ReplaceDB(db *gorm.DB)
ReadDB() IUserGameRolePropDo
WriteDB() IUserGameRolePropDo
As(alias string) gen.Dao
Session(config *gorm.Session) IUserGameRolePropDo
Columns(cols ...field.Expr) gen.Columns
Clauses(conds ...clause.Expression) IUserGameRolePropDo
Not(conds ...gen.Condition) IUserGameRolePropDo
Or(conds ...gen.Condition) IUserGameRolePropDo
Select(conds ...field.Expr) IUserGameRolePropDo
Where(conds ...gen.Condition) IUserGameRolePropDo
Order(conds ...field.Expr) IUserGameRolePropDo
Distinct(cols ...field.Expr) IUserGameRolePropDo
Omit(cols ...field.Expr) IUserGameRolePropDo
Join(table schema.Tabler, on ...field.Expr) IUserGameRolePropDo
LeftJoin(table schema.Tabler, on ...field.Expr) IUserGameRolePropDo
RightJoin(table schema.Tabler, on ...field.Expr) IUserGameRolePropDo
Group(cols ...field.Expr) IUserGameRolePropDo
Having(conds ...gen.Condition) IUserGameRolePropDo
Limit(limit int) IUserGameRolePropDo
Offset(offset int) IUserGameRolePropDo
Count() (count int64, err error)
Scopes(funcs ...func(gen.Dao) gen.Dao) IUserGameRolePropDo
Unscoped() IUserGameRolePropDo
Create(values ...*model.UserGameRoleProp) error
CreateInBatches(values []*model.UserGameRoleProp, batchSize int) error
Save(values ...*model.UserGameRoleProp) error
First() (*model.UserGameRoleProp, error)
Take() (*model.UserGameRoleProp, error)
Last() (*model.UserGameRoleProp, error)
Find() ([]*model.UserGameRoleProp, error)
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.UserGameRoleProp, err error)
FindInBatches(result *[]*model.UserGameRoleProp, batchSize int, fc func(tx gen.Dao, batch int) error) error
Pluck(column field.Expr, dest interface{}) error
Delete(...*model.UserGameRoleProp) (info gen.ResultInfo, err error)
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
Updates(value interface{}) (info gen.ResultInfo, err error)
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
UpdateFrom(q gen.SubQuery) gen.Dao
Attrs(attrs ...field.AssignExpr) IUserGameRolePropDo
Assign(attrs ...field.AssignExpr) IUserGameRolePropDo
Joins(fields ...field.RelationField) IUserGameRolePropDo
Preload(fields ...field.RelationField) IUserGameRolePropDo
FirstOrInit() (*model.UserGameRoleProp, error)
FirstOrCreate() (*model.UserGameRoleProp, error)
FindByPage(offset int, limit int) (result []*model.UserGameRoleProp, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IUserGameRolePropDo
UnderlyingDB() *gorm.DB
schema.Tabler
}
func (u userGameRolePropDo) Debug() IUserGameRolePropDo {
return u.withDO(u.DO.Debug())
}
func (u userGameRolePropDo) WithContext(ctx context.Context) IUserGameRolePropDo {
return u.withDO(u.DO.WithContext(ctx))
}
func (u userGameRolePropDo) ReadDB() IUserGameRolePropDo {
return u.Clauses(dbresolver.Read)
}
func (u userGameRolePropDo) WriteDB() IUserGameRolePropDo {
return u.Clauses(dbresolver.Write)
}
func (u userGameRolePropDo) Session(config *gorm.Session) IUserGameRolePropDo {
return u.withDO(u.DO.Session(config))
}
func (u userGameRolePropDo) Clauses(conds ...clause.Expression) IUserGameRolePropDo {
return u.withDO(u.DO.Clauses(conds...))
}
func (u userGameRolePropDo) Returning(value interface{}, columns ...string) IUserGameRolePropDo {
return u.withDO(u.DO.Returning(value, columns...))
}
func (u userGameRolePropDo) Not(conds ...gen.Condition) IUserGameRolePropDo {
return u.withDO(u.DO.Not(conds...))
}
func (u userGameRolePropDo) Or(conds ...gen.Condition) IUserGameRolePropDo {
return u.withDO(u.DO.Or(conds...))
}
func (u userGameRolePropDo) Select(conds ...field.Expr) IUserGameRolePropDo {
return u.withDO(u.DO.Select(conds...))
}
func (u userGameRolePropDo) Where(conds ...gen.Condition) IUserGameRolePropDo {
return u.withDO(u.DO.Where(conds...))
}
func (u userGameRolePropDo) Order(conds ...field.Expr) IUserGameRolePropDo {
return u.withDO(u.DO.Order(conds...))
}
func (u userGameRolePropDo) Distinct(cols ...field.Expr) IUserGameRolePropDo {
return u.withDO(u.DO.Distinct(cols...))
}
func (u userGameRolePropDo) Omit(cols ...field.Expr) IUserGameRolePropDo {
return u.withDO(u.DO.Omit(cols...))
}
func (u userGameRolePropDo) Join(table schema.Tabler, on ...field.Expr) IUserGameRolePropDo {
return u.withDO(u.DO.Join(table, on...))
}
func (u userGameRolePropDo) LeftJoin(table schema.Tabler, on ...field.Expr) IUserGameRolePropDo {
return u.withDO(u.DO.LeftJoin(table, on...))
}
func (u userGameRolePropDo) RightJoin(table schema.Tabler, on ...field.Expr) IUserGameRolePropDo {
return u.withDO(u.DO.RightJoin(table, on...))
}
func (u userGameRolePropDo) Group(cols ...field.Expr) IUserGameRolePropDo {
return u.withDO(u.DO.Group(cols...))
}
func (u userGameRolePropDo) Having(conds ...gen.Condition) IUserGameRolePropDo {
return u.withDO(u.DO.Having(conds...))
}
func (u userGameRolePropDo) Limit(limit int) IUserGameRolePropDo {
return u.withDO(u.DO.Limit(limit))
}
func (u userGameRolePropDo) Offset(offset int) IUserGameRolePropDo {
return u.withDO(u.DO.Offset(offset))
}
func (u userGameRolePropDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IUserGameRolePropDo {
return u.withDO(u.DO.Scopes(funcs...))
}
func (u userGameRolePropDo) Unscoped() IUserGameRolePropDo {
return u.withDO(u.DO.Unscoped())
}
func (u userGameRolePropDo) Create(values ...*model.UserGameRoleProp) error {
if len(values) == 0 {
return nil
}
return u.DO.Create(values)
}
func (u userGameRolePropDo) CreateInBatches(values []*model.UserGameRoleProp, batchSize int) error {
return u.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 (u userGameRolePropDo) Save(values ...*model.UserGameRoleProp) error {
if len(values) == 0 {
return nil
}
return u.DO.Save(values)
}
func (u userGameRolePropDo) First() (*model.UserGameRoleProp, error) {
if result, err := u.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.UserGameRoleProp), nil
}
}
func (u userGameRolePropDo) Take() (*model.UserGameRoleProp, error) {
if result, err := u.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.UserGameRoleProp), nil
}
}
func (u userGameRolePropDo) Last() (*model.UserGameRoleProp, error) {
if result, err := u.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.UserGameRoleProp), nil
}
}
func (u userGameRolePropDo) Find() ([]*model.UserGameRoleProp, error) {
result, err := u.DO.Find()
return result.([]*model.UserGameRoleProp), err
}
func (u userGameRolePropDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.UserGameRoleProp, err error) {
buf := make([]*model.UserGameRoleProp, 0, batchSize)
err = u.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 (u userGameRolePropDo) FindInBatches(result *[]*model.UserGameRoleProp, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return u.DO.FindInBatches(result, batchSize, fc)
}
func (u userGameRolePropDo) Attrs(attrs ...field.AssignExpr) IUserGameRolePropDo {
return u.withDO(u.DO.Attrs(attrs...))
}
func (u userGameRolePropDo) Assign(attrs ...field.AssignExpr) IUserGameRolePropDo {
return u.withDO(u.DO.Assign(attrs...))
}
func (u userGameRolePropDo) Joins(fields ...field.RelationField) IUserGameRolePropDo {
for _, _f := range fields {
u = *u.withDO(u.DO.Joins(_f))
}
return &u
}
func (u userGameRolePropDo) Preload(fields ...field.RelationField) IUserGameRolePropDo {
for _, _f := range fields {
u = *u.withDO(u.DO.Preload(_f))
}
return &u
}
func (u userGameRolePropDo) FirstOrInit() (*model.UserGameRoleProp, error) {
if result, err := u.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.UserGameRoleProp), nil
}
}
func (u userGameRolePropDo) FirstOrCreate() (*model.UserGameRoleProp, error) {
if result, err := u.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.UserGameRoleProp), nil
}
}
func (u userGameRolePropDo) FindByPage(offset int, limit int) (result []*model.UserGameRoleProp, count int64, err error) {
result, err = u.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 = u.Offset(-1).Limit(-1).Count()
return
}
func (u userGameRolePropDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = u.Count()
if err != nil {
return
}
err = u.Offset(offset).Limit(limit).Scan(result)
return
}
func (u userGameRolePropDo) Scan(result interface{}) (err error) {
return u.DO.Scan(result)
}
func (u userGameRolePropDo) Delete(models ...*model.UserGameRoleProp) (result gen.ResultInfo, err error) {
return u.DO.Delete(models)
}
func (u *userGameRolePropDo) withDO(do gen.Dao) *userGameRolePropDo {
u.DO = *do.(*gen.DO)
return u
}