328 lines
8.4 KiB
Go
328 lines
8.4 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 newLinkUserRole(db *gorm.DB, opts ...gen.DOOption) linkUserRole {
|
|
_linkUserRole := linkUserRole{}
|
|
|
|
_linkUserRole.linkUserRoleDo.UseDB(db, opts...)
|
|
_linkUserRole.linkUserRoleDo.UseModel(&models.LinkUserRole{})
|
|
|
|
tableName := _linkUserRole.linkUserRoleDo.TableName()
|
|
_linkUserRole.ALL = field.NewAsterisk(tableName)
|
|
_linkUserRole.ID = field.NewInt32(tableName, "id")
|
|
_linkUserRole.UserID = field.NewInt32(tableName, "user_id")
|
|
_linkUserRole.RoleID = field.NewInt32(tableName, "role_id")
|
|
|
|
_linkUserRole.fillFieldMap()
|
|
|
|
return _linkUserRole
|
|
}
|
|
|
|
type linkUserRole struct {
|
|
linkUserRoleDo
|
|
|
|
ALL field.Asterisk
|
|
ID field.Int32
|
|
UserID field.Int32
|
|
RoleID field.Int32
|
|
|
|
fieldMap map[string]field.Expr
|
|
}
|
|
|
|
func (l linkUserRole) Table(newTableName string) *linkUserRole {
|
|
l.linkUserRoleDo.UseTable(newTableName)
|
|
return l.updateTableName(newTableName)
|
|
}
|
|
|
|
func (l linkUserRole) As(alias string) *linkUserRole {
|
|
l.linkUserRoleDo.DO = *(l.linkUserRoleDo.As(alias).(*gen.DO))
|
|
return l.updateTableName(alias)
|
|
}
|
|
|
|
func (l *linkUserRole) updateTableName(table string) *linkUserRole {
|
|
l.ALL = field.NewAsterisk(table)
|
|
l.ID = field.NewInt32(table, "id")
|
|
l.UserID = field.NewInt32(table, "user_id")
|
|
l.RoleID = field.NewInt32(table, "role_id")
|
|
|
|
l.fillFieldMap()
|
|
|
|
return l
|
|
}
|
|
|
|
func (l *linkUserRole) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
|
_f, ok := l.fieldMap[fieldName]
|
|
if !ok || _f == nil {
|
|
return nil, false
|
|
}
|
|
_oe, ok := _f.(field.OrderExpr)
|
|
return _oe, ok
|
|
}
|
|
|
|
func (l *linkUserRole) fillFieldMap() {
|
|
l.fieldMap = make(map[string]field.Expr, 3)
|
|
l.fieldMap["id"] = l.ID
|
|
l.fieldMap["user_id"] = l.UserID
|
|
l.fieldMap["role_id"] = l.RoleID
|
|
}
|
|
|
|
func (l linkUserRole) clone(db *gorm.DB) linkUserRole {
|
|
l.linkUserRoleDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
return l
|
|
}
|
|
|
|
func (l linkUserRole) replaceDB(db *gorm.DB) linkUserRole {
|
|
l.linkUserRoleDo.ReplaceDB(db)
|
|
return l
|
|
}
|
|
|
|
type linkUserRoleDo struct{ gen.DO }
|
|
|
|
func (l linkUserRoleDo) Debug() *linkUserRoleDo {
|
|
return l.withDO(l.DO.Debug())
|
|
}
|
|
|
|
func (l linkUserRoleDo) WithContext(ctx context.Context) *linkUserRoleDo {
|
|
return l.withDO(l.DO.WithContext(ctx))
|
|
}
|
|
|
|
func (l linkUserRoleDo) ReadDB() *linkUserRoleDo {
|
|
return l.Clauses(dbresolver.Read)
|
|
}
|
|
|
|
func (l linkUserRoleDo) WriteDB() *linkUserRoleDo {
|
|
return l.Clauses(dbresolver.Write)
|
|
}
|
|
|
|
func (l linkUserRoleDo) Session(config *gorm.Session) *linkUserRoleDo {
|
|
return l.withDO(l.DO.Session(config))
|
|
}
|
|
|
|
func (l linkUserRoleDo) Clauses(conds ...clause.Expression) *linkUserRoleDo {
|
|
return l.withDO(l.DO.Clauses(conds...))
|
|
}
|
|
|
|
func (l linkUserRoleDo) Returning(value interface{}, columns ...string) *linkUserRoleDo {
|
|
return l.withDO(l.DO.Returning(value, columns...))
|
|
}
|
|
|
|
func (l linkUserRoleDo) Not(conds ...gen.Condition) *linkUserRoleDo {
|
|
return l.withDO(l.DO.Not(conds...))
|
|
}
|
|
|
|
func (l linkUserRoleDo) Or(conds ...gen.Condition) *linkUserRoleDo {
|
|
return l.withDO(l.DO.Or(conds...))
|
|
}
|
|
|
|
func (l linkUserRoleDo) Select(conds ...field.Expr) *linkUserRoleDo {
|
|
return l.withDO(l.DO.Select(conds...))
|
|
}
|
|
|
|
func (l linkUserRoleDo) Where(conds ...gen.Condition) *linkUserRoleDo {
|
|
return l.withDO(l.DO.Where(conds...))
|
|
}
|
|
|
|
func (l linkUserRoleDo) Order(conds ...field.Expr) *linkUserRoleDo {
|
|
return l.withDO(l.DO.Order(conds...))
|
|
}
|
|
|
|
func (l linkUserRoleDo) Distinct(cols ...field.Expr) *linkUserRoleDo {
|
|
return l.withDO(l.DO.Distinct(cols...))
|
|
}
|
|
|
|
func (l linkUserRoleDo) Omit(cols ...field.Expr) *linkUserRoleDo {
|
|
return l.withDO(l.DO.Omit(cols...))
|
|
}
|
|
|
|
func (l linkUserRoleDo) Join(table schema.Tabler, on ...field.Expr) *linkUserRoleDo {
|
|
return l.withDO(l.DO.Join(table, on...))
|
|
}
|
|
|
|
func (l linkUserRoleDo) LeftJoin(table schema.Tabler, on ...field.Expr) *linkUserRoleDo {
|
|
return l.withDO(l.DO.LeftJoin(table, on...))
|
|
}
|
|
|
|
func (l linkUserRoleDo) RightJoin(table schema.Tabler, on ...field.Expr) *linkUserRoleDo {
|
|
return l.withDO(l.DO.RightJoin(table, on...))
|
|
}
|
|
|
|
func (l linkUserRoleDo) Group(cols ...field.Expr) *linkUserRoleDo {
|
|
return l.withDO(l.DO.Group(cols...))
|
|
}
|
|
|
|
func (l linkUserRoleDo) Having(conds ...gen.Condition) *linkUserRoleDo {
|
|
return l.withDO(l.DO.Having(conds...))
|
|
}
|
|
|
|
func (l linkUserRoleDo) Limit(limit int) *linkUserRoleDo {
|
|
return l.withDO(l.DO.Limit(limit))
|
|
}
|
|
|
|
func (l linkUserRoleDo) Offset(offset int) *linkUserRoleDo {
|
|
return l.withDO(l.DO.Offset(offset))
|
|
}
|
|
|
|
func (l linkUserRoleDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *linkUserRoleDo {
|
|
return l.withDO(l.DO.Scopes(funcs...))
|
|
}
|
|
|
|
func (l linkUserRoleDo) Unscoped() *linkUserRoleDo {
|
|
return l.withDO(l.DO.Unscoped())
|
|
}
|
|
|
|
func (l linkUserRoleDo) Create(values ...*models.LinkUserRole) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return l.DO.Create(values)
|
|
}
|
|
|
|
func (l linkUserRoleDo) CreateInBatches(values []*models.LinkUserRole, batchSize int) error {
|
|
return l.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 (l linkUserRoleDo) Save(values ...*models.LinkUserRole) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return l.DO.Save(values)
|
|
}
|
|
|
|
func (l linkUserRoleDo) First() (*models.LinkUserRole, error) {
|
|
if result, err := l.DO.First(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.LinkUserRole), nil
|
|
}
|
|
}
|
|
|
|
func (l linkUserRoleDo) Take() (*models.LinkUserRole, error) {
|
|
if result, err := l.DO.Take(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.LinkUserRole), nil
|
|
}
|
|
}
|
|
|
|
func (l linkUserRoleDo) Last() (*models.LinkUserRole, error) {
|
|
if result, err := l.DO.Last(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.LinkUserRole), nil
|
|
}
|
|
}
|
|
|
|
func (l linkUserRoleDo) Find() ([]*models.LinkUserRole, error) {
|
|
result, err := l.DO.Find()
|
|
return result.([]*models.LinkUserRole), err
|
|
}
|
|
|
|
func (l linkUserRoleDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.LinkUserRole, err error) {
|
|
buf := make([]*models.LinkUserRole, 0, batchSize)
|
|
err = l.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 (l linkUserRoleDo) FindInBatches(result *[]*models.LinkUserRole, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
return l.DO.FindInBatches(result, batchSize, fc)
|
|
}
|
|
|
|
func (l linkUserRoleDo) Attrs(attrs ...field.AssignExpr) *linkUserRoleDo {
|
|
return l.withDO(l.DO.Attrs(attrs...))
|
|
}
|
|
|
|
func (l linkUserRoleDo) Assign(attrs ...field.AssignExpr) *linkUserRoleDo {
|
|
return l.withDO(l.DO.Assign(attrs...))
|
|
}
|
|
|
|
func (l linkUserRoleDo) Joins(fields ...field.RelationField) *linkUserRoleDo {
|
|
for _, _f := range fields {
|
|
l = *l.withDO(l.DO.Joins(_f))
|
|
}
|
|
return &l
|
|
}
|
|
|
|
func (l linkUserRoleDo) Preload(fields ...field.RelationField) *linkUserRoleDo {
|
|
for _, _f := range fields {
|
|
l = *l.withDO(l.DO.Preload(_f))
|
|
}
|
|
return &l
|
|
}
|
|
|
|
func (l linkUserRoleDo) FirstOrInit() (*models.LinkUserRole, error) {
|
|
if result, err := l.DO.FirstOrInit(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.LinkUserRole), nil
|
|
}
|
|
}
|
|
|
|
func (l linkUserRoleDo) FirstOrCreate() (*models.LinkUserRole, error) {
|
|
if result, err := l.DO.FirstOrCreate(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.LinkUserRole), nil
|
|
}
|
|
}
|
|
|
|
func (l linkUserRoleDo) FindByPage(offset int, limit int) (result []*models.LinkUserRole, count int64, err error) {
|
|
result, err = l.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 = l.Offset(-1).Limit(-1).Count()
|
|
return
|
|
}
|
|
|
|
func (l linkUserRoleDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
|
count, err = l.Count()
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
err = l.Offset(offset).Limit(limit).Scan(result)
|
|
return
|
|
}
|
|
|
|
func (l linkUserRoleDo) Scan(result interface{}) (err error) {
|
|
return l.DO.Scan(result)
|
|
}
|
|
|
|
func (l linkUserRoleDo) Delete(models ...*models.LinkUserRole) (result gen.ResultInfo, err error) {
|
|
return l.DO.Delete(models)
|
|
}
|
|
|
|
func (l *linkUserRoleDo) withDO(do gen.Dao) *linkUserRoleDo {
|
|
l.DO = *do.(*gen.DO)
|
|
return l
|
|
}
|