340 lines
10 KiB
Go
340 lines
10 KiB
Go
// Code generated by gorm.io/gen. DO NOT EDIT.
|
|
// Code generated by gorm.io/gen. DO NOT EDIT.
|
|
// Code generated by gorm.io/gen. DO NOT EDIT.
|
|
|
|
package queries
|
|
|
|
import (
|
|
"context"
|
|
|
|
"gorm.io/gorm"
|
|
"gorm.io/gorm/clause"
|
|
"gorm.io/gorm/schema"
|
|
|
|
"gorm.io/gen"
|
|
"gorm.io/gen/field"
|
|
|
|
"gorm.io/plugin/dbresolver"
|
|
|
|
"platform/web/models"
|
|
)
|
|
|
|
func newUserRolePermissionLink(db *gorm.DB, opts ...gen.DOOption) userRolePermissionLink {
|
|
_userRolePermissionLink := userRolePermissionLink{}
|
|
|
|
_userRolePermissionLink.userRolePermissionLinkDo.UseDB(db, opts...)
|
|
_userRolePermissionLink.userRolePermissionLinkDo.UseModel(&models.UserRolePermissionLink{})
|
|
|
|
tableName := _userRolePermissionLink.userRolePermissionLinkDo.TableName()
|
|
_userRolePermissionLink.ALL = field.NewAsterisk(tableName)
|
|
_userRolePermissionLink.ID = field.NewInt32(tableName, "id")
|
|
_userRolePermissionLink.RoleID = field.NewInt32(tableName, "role_id")
|
|
_userRolePermissionLink.PermissionID = field.NewInt32(tableName, "permission_id")
|
|
_userRolePermissionLink.CreatedAt = field.NewField(tableName, "created_at")
|
|
_userRolePermissionLink.UpdatedAt = field.NewField(tableName, "updated_at")
|
|
_userRolePermissionLink.DeletedAt = field.NewField(tableName, "deleted_at")
|
|
|
|
_userRolePermissionLink.fillFieldMap()
|
|
|
|
return _userRolePermissionLink
|
|
}
|
|
|
|
type userRolePermissionLink struct {
|
|
userRolePermissionLinkDo
|
|
|
|
ALL field.Asterisk
|
|
ID field.Int32 // 关联ID
|
|
RoleID field.Int32 // 角色ID
|
|
PermissionID field.Int32 // 权限ID
|
|
CreatedAt field.Field // 创建时间
|
|
UpdatedAt field.Field // 更新时间
|
|
DeletedAt field.Field // 删除时间
|
|
|
|
fieldMap map[string]field.Expr
|
|
}
|
|
|
|
func (u userRolePermissionLink) Table(newTableName string) *userRolePermissionLink {
|
|
u.userRolePermissionLinkDo.UseTable(newTableName)
|
|
return u.updateTableName(newTableName)
|
|
}
|
|
|
|
func (u userRolePermissionLink) As(alias string) *userRolePermissionLink {
|
|
u.userRolePermissionLinkDo.DO = *(u.userRolePermissionLinkDo.As(alias).(*gen.DO))
|
|
return u.updateTableName(alias)
|
|
}
|
|
|
|
func (u *userRolePermissionLink) updateTableName(table string) *userRolePermissionLink {
|
|
u.ALL = field.NewAsterisk(table)
|
|
u.ID = field.NewInt32(table, "id")
|
|
u.RoleID = field.NewInt32(table, "role_id")
|
|
u.PermissionID = field.NewInt32(table, "permission_id")
|
|
u.CreatedAt = field.NewField(table, "created_at")
|
|
u.UpdatedAt = field.NewField(table, "updated_at")
|
|
u.DeletedAt = field.NewField(table, "deleted_at")
|
|
|
|
u.fillFieldMap()
|
|
|
|
return u
|
|
}
|
|
|
|
func (u *userRolePermissionLink) 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 *userRolePermissionLink) fillFieldMap() {
|
|
u.fieldMap = make(map[string]field.Expr, 6)
|
|
u.fieldMap["id"] = u.ID
|
|
u.fieldMap["role_id"] = u.RoleID
|
|
u.fieldMap["permission_id"] = u.PermissionID
|
|
u.fieldMap["created_at"] = u.CreatedAt
|
|
u.fieldMap["updated_at"] = u.UpdatedAt
|
|
u.fieldMap["deleted_at"] = u.DeletedAt
|
|
}
|
|
|
|
func (u userRolePermissionLink) clone(db *gorm.DB) userRolePermissionLink {
|
|
u.userRolePermissionLinkDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
return u
|
|
}
|
|
|
|
func (u userRolePermissionLink) replaceDB(db *gorm.DB) userRolePermissionLink {
|
|
u.userRolePermissionLinkDo.ReplaceDB(db)
|
|
return u
|
|
}
|
|
|
|
type userRolePermissionLinkDo struct{ gen.DO }
|
|
|
|
func (u userRolePermissionLinkDo) Debug() *userRolePermissionLinkDo {
|
|
return u.withDO(u.DO.Debug())
|
|
}
|
|
|
|
func (u userRolePermissionLinkDo) WithContext(ctx context.Context) *userRolePermissionLinkDo {
|
|
return u.withDO(u.DO.WithContext(ctx))
|
|
}
|
|
|
|
func (u userRolePermissionLinkDo) ReadDB() *userRolePermissionLinkDo {
|
|
return u.Clauses(dbresolver.Read)
|
|
}
|
|
|
|
func (u userRolePermissionLinkDo) WriteDB() *userRolePermissionLinkDo {
|
|
return u.Clauses(dbresolver.Write)
|
|
}
|
|
|
|
func (u userRolePermissionLinkDo) Session(config *gorm.Session) *userRolePermissionLinkDo {
|
|
return u.withDO(u.DO.Session(config))
|
|
}
|
|
|
|
func (u userRolePermissionLinkDo) Clauses(conds ...clause.Expression) *userRolePermissionLinkDo {
|
|
return u.withDO(u.DO.Clauses(conds...))
|
|
}
|
|
|
|
func (u userRolePermissionLinkDo) Returning(value interface{}, columns ...string) *userRolePermissionLinkDo {
|
|
return u.withDO(u.DO.Returning(value, columns...))
|
|
}
|
|
|
|
func (u userRolePermissionLinkDo) Not(conds ...gen.Condition) *userRolePermissionLinkDo {
|
|
return u.withDO(u.DO.Not(conds...))
|
|
}
|
|
|
|
func (u userRolePermissionLinkDo) Or(conds ...gen.Condition) *userRolePermissionLinkDo {
|
|
return u.withDO(u.DO.Or(conds...))
|
|
}
|
|
|
|
func (u userRolePermissionLinkDo) Select(conds ...field.Expr) *userRolePermissionLinkDo {
|
|
return u.withDO(u.DO.Select(conds...))
|
|
}
|
|
|
|
func (u userRolePermissionLinkDo) Where(conds ...gen.Condition) *userRolePermissionLinkDo {
|
|
return u.withDO(u.DO.Where(conds...))
|
|
}
|
|
|
|
func (u userRolePermissionLinkDo) Order(conds ...field.Expr) *userRolePermissionLinkDo {
|
|
return u.withDO(u.DO.Order(conds...))
|
|
}
|
|
|
|
func (u userRolePermissionLinkDo) Distinct(cols ...field.Expr) *userRolePermissionLinkDo {
|
|
return u.withDO(u.DO.Distinct(cols...))
|
|
}
|
|
|
|
func (u userRolePermissionLinkDo) Omit(cols ...field.Expr) *userRolePermissionLinkDo {
|
|
return u.withDO(u.DO.Omit(cols...))
|
|
}
|
|
|
|
func (u userRolePermissionLinkDo) Join(table schema.Tabler, on ...field.Expr) *userRolePermissionLinkDo {
|
|
return u.withDO(u.DO.Join(table, on...))
|
|
}
|
|
|
|
func (u userRolePermissionLinkDo) LeftJoin(table schema.Tabler, on ...field.Expr) *userRolePermissionLinkDo {
|
|
return u.withDO(u.DO.LeftJoin(table, on...))
|
|
}
|
|
|
|
func (u userRolePermissionLinkDo) RightJoin(table schema.Tabler, on ...field.Expr) *userRolePermissionLinkDo {
|
|
return u.withDO(u.DO.RightJoin(table, on...))
|
|
}
|
|
|
|
func (u userRolePermissionLinkDo) Group(cols ...field.Expr) *userRolePermissionLinkDo {
|
|
return u.withDO(u.DO.Group(cols...))
|
|
}
|
|
|
|
func (u userRolePermissionLinkDo) Having(conds ...gen.Condition) *userRolePermissionLinkDo {
|
|
return u.withDO(u.DO.Having(conds...))
|
|
}
|
|
|
|
func (u userRolePermissionLinkDo) Limit(limit int) *userRolePermissionLinkDo {
|
|
return u.withDO(u.DO.Limit(limit))
|
|
}
|
|
|
|
func (u userRolePermissionLinkDo) Offset(offset int) *userRolePermissionLinkDo {
|
|
return u.withDO(u.DO.Offset(offset))
|
|
}
|
|
|
|
func (u userRolePermissionLinkDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *userRolePermissionLinkDo {
|
|
return u.withDO(u.DO.Scopes(funcs...))
|
|
}
|
|
|
|
func (u userRolePermissionLinkDo) Unscoped() *userRolePermissionLinkDo {
|
|
return u.withDO(u.DO.Unscoped())
|
|
}
|
|
|
|
func (u userRolePermissionLinkDo) Create(values ...*models.UserRolePermissionLink) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return u.DO.Create(values)
|
|
}
|
|
|
|
func (u userRolePermissionLinkDo) CreateInBatches(values []*models.UserRolePermissionLink, 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 userRolePermissionLinkDo) Save(values ...*models.UserRolePermissionLink) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return u.DO.Save(values)
|
|
}
|
|
|
|
func (u userRolePermissionLinkDo) First() (*models.UserRolePermissionLink, error) {
|
|
if result, err := u.DO.First(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.UserRolePermissionLink), nil
|
|
}
|
|
}
|
|
|
|
func (u userRolePermissionLinkDo) Take() (*models.UserRolePermissionLink, error) {
|
|
if result, err := u.DO.Take(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.UserRolePermissionLink), nil
|
|
}
|
|
}
|
|
|
|
func (u userRolePermissionLinkDo) Last() (*models.UserRolePermissionLink, error) {
|
|
if result, err := u.DO.Last(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.UserRolePermissionLink), nil
|
|
}
|
|
}
|
|
|
|
func (u userRolePermissionLinkDo) Find() ([]*models.UserRolePermissionLink, error) {
|
|
result, err := u.DO.Find()
|
|
return result.([]*models.UserRolePermissionLink), err
|
|
}
|
|
|
|
func (u userRolePermissionLinkDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.UserRolePermissionLink, err error) {
|
|
buf := make([]*models.UserRolePermissionLink, 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 userRolePermissionLinkDo) FindInBatches(result *[]*models.UserRolePermissionLink, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
return u.DO.FindInBatches(result, batchSize, fc)
|
|
}
|
|
|
|
func (u userRolePermissionLinkDo) Attrs(attrs ...field.AssignExpr) *userRolePermissionLinkDo {
|
|
return u.withDO(u.DO.Attrs(attrs...))
|
|
}
|
|
|
|
func (u userRolePermissionLinkDo) Assign(attrs ...field.AssignExpr) *userRolePermissionLinkDo {
|
|
return u.withDO(u.DO.Assign(attrs...))
|
|
}
|
|
|
|
func (u userRolePermissionLinkDo) Joins(fields ...field.RelationField) *userRolePermissionLinkDo {
|
|
for _, _f := range fields {
|
|
u = *u.withDO(u.DO.Joins(_f))
|
|
}
|
|
return &u
|
|
}
|
|
|
|
func (u userRolePermissionLinkDo) Preload(fields ...field.RelationField) *userRolePermissionLinkDo {
|
|
for _, _f := range fields {
|
|
u = *u.withDO(u.DO.Preload(_f))
|
|
}
|
|
return &u
|
|
}
|
|
|
|
func (u userRolePermissionLinkDo) FirstOrInit() (*models.UserRolePermissionLink, error) {
|
|
if result, err := u.DO.FirstOrInit(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.UserRolePermissionLink), nil
|
|
}
|
|
}
|
|
|
|
func (u userRolePermissionLinkDo) FirstOrCreate() (*models.UserRolePermissionLink, error) {
|
|
if result, err := u.DO.FirstOrCreate(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.UserRolePermissionLink), nil
|
|
}
|
|
}
|
|
|
|
func (u userRolePermissionLinkDo) FindByPage(offset int, limit int) (result []*models.UserRolePermissionLink, 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 userRolePermissionLinkDo) 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 userRolePermissionLinkDo) Scan(result interface{}) (err error) {
|
|
return u.DO.Scan(result)
|
|
}
|
|
|
|
func (u userRolePermissionLinkDo) Delete(models ...*models.UserRolePermissionLink) (result gen.ResultInfo, err error) {
|
|
return u.DO.Delete(models)
|
|
}
|
|
|
|
func (u *userRolePermissionLinkDo) withDO(do gen.Dao) *userRolePermissionLinkDo {
|
|
u.DO = *do.(*gen.DO)
|
|
return u
|
|
}
|