认证授权主要流程实现
This commit is contained in:
339
web/queries/client_permission_link.gen.go
Normal file
339
web/queries/client_permission_link.gen.go
Normal file
@@ -0,0 +1,339 @@
|
||||
// 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 newClientPermissionLink(db *gorm.DB, opts ...gen.DOOption) clientPermissionLink {
|
||||
_clientPermissionLink := clientPermissionLink{}
|
||||
|
||||
_clientPermissionLink.clientPermissionLinkDo.UseDB(db, opts...)
|
||||
_clientPermissionLink.clientPermissionLinkDo.UseModel(&models.ClientPermissionLink{})
|
||||
|
||||
tableName := _clientPermissionLink.clientPermissionLinkDo.TableName()
|
||||
_clientPermissionLink.ALL = field.NewAsterisk(tableName)
|
||||
_clientPermissionLink.ID = field.NewInt32(tableName, "id")
|
||||
_clientPermissionLink.ClientID = field.NewInt32(tableName, "client_id")
|
||||
_clientPermissionLink.PermissionID = field.NewInt32(tableName, "permission_id")
|
||||
_clientPermissionLink.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_clientPermissionLink.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_clientPermissionLink.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
||||
_clientPermissionLink.fillFieldMap()
|
||||
|
||||
return _clientPermissionLink
|
||||
}
|
||||
|
||||
type clientPermissionLink struct {
|
||||
clientPermissionLinkDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int32 // 关联ID
|
||||
ClientID field.Int32 // 客户端ID
|
||||
PermissionID field.Int32 // 权限ID
|
||||
CreatedAt field.Time // 创建时间
|
||||
UpdatedAt field.Time // 更新时间
|
||||
DeletedAt field.Field // 删除时间
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (c clientPermissionLink) Table(newTableName string) *clientPermissionLink {
|
||||
c.clientPermissionLinkDo.UseTable(newTableName)
|
||||
return c.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (c clientPermissionLink) As(alias string) *clientPermissionLink {
|
||||
c.clientPermissionLinkDo.DO = *(c.clientPermissionLinkDo.As(alias).(*gen.DO))
|
||||
return c.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (c *clientPermissionLink) updateTableName(table string) *clientPermissionLink {
|
||||
c.ALL = field.NewAsterisk(table)
|
||||
c.ID = field.NewInt32(table, "id")
|
||||
c.ClientID = field.NewInt32(table, "client_id")
|
||||
c.PermissionID = field.NewInt32(table, "permission_id")
|
||||
c.CreatedAt = field.NewTime(table, "created_at")
|
||||
c.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
c.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
||||
c.fillFieldMap()
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *clientPermissionLink) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := c.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (c *clientPermissionLink) fillFieldMap() {
|
||||
c.fieldMap = make(map[string]field.Expr, 6)
|
||||
c.fieldMap["id"] = c.ID
|
||||
c.fieldMap["client_id"] = c.ClientID
|
||||
c.fieldMap["permission_id"] = c.PermissionID
|
||||
c.fieldMap["created_at"] = c.CreatedAt
|
||||
c.fieldMap["updated_at"] = c.UpdatedAt
|
||||
c.fieldMap["deleted_at"] = c.DeletedAt
|
||||
}
|
||||
|
||||
func (c clientPermissionLink) clone(db *gorm.DB) clientPermissionLink {
|
||||
c.clientPermissionLinkDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return c
|
||||
}
|
||||
|
||||
func (c clientPermissionLink) replaceDB(db *gorm.DB) clientPermissionLink {
|
||||
c.clientPermissionLinkDo.ReplaceDB(db)
|
||||
return c
|
||||
}
|
||||
|
||||
type clientPermissionLinkDo struct{ gen.DO }
|
||||
|
||||
func (c clientPermissionLinkDo) Debug() *clientPermissionLinkDo {
|
||||
return c.withDO(c.DO.Debug())
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) WithContext(ctx context.Context) *clientPermissionLinkDo {
|
||||
return c.withDO(c.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) ReadDB() *clientPermissionLinkDo {
|
||||
return c.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) WriteDB() *clientPermissionLinkDo {
|
||||
return c.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) Session(config *gorm.Session) *clientPermissionLinkDo {
|
||||
return c.withDO(c.DO.Session(config))
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) Clauses(conds ...clause.Expression) *clientPermissionLinkDo {
|
||||
return c.withDO(c.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) Returning(value interface{}, columns ...string) *clientPermissionLinkDo {
|
||||
return c.withDO(c.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) Not(conds ...gen.Condition) *clientPermissionLinkDo {
|
||||
return c.withDO(c.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) Or(conds ...gen.Condition) *clientPermissionLinkDo {
|
||||
return c.withDO(c.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) Select(conds ...field.Expr) *clientPermissionLinkDo {
|
||||
return c.withDO(c.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) Where(conds ...gen.Condition) *clientPermissionLinkDo {
|
||||
return c.withDO(c.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) Order(conds ...field.Expr) *clientPermissionLinkDo {
|
||||
return c.withDO(c.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) Distinct(cols ...field.Expr) *clientPermissionLinkDo {
|
||||
return c.withDO(c.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) Omit(cols ...field.Expr) *clientPermissionLinkDo {
|
||||
return c.withDO(c.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) Join(table schema.Tabler, on ...field.Expr) *clientPermissionLinkDo {
|
||||
return c.withDO(c.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) LeftJoin(table schema.Tabler, on ...field.Expr) *clientPermissionLinkDo {
|
||||
return c.withDO(c.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) RightJoin(table schema.Tabler, on ...field.Expr) *clientPermissionLinkDo {
|
||||
return c.withDO(c.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) Group(cols ...field.Expr) *clientPermissionLinkDo {
|
||||
return c.withDO(c.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) Having(conds ...gen.Condition) *clientPermissionLinkDo {
|
||||
return c.withDO(c.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) Limit(limit int) *clientPermissionLinkDo {
|
||||
return c.withDO(c.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) Offset(offset int) *clientPermissionLinkDo {
|
||||
return c.withDO(c.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *clientPermissionLinkDo {
|
||||
return c.withDO(c.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) Unscoped() *clientPermissionLinkDo {
|
||||
return c.withDO(c.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) Create(values ...*models.ClientPermissionLink) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return c.DO.Create(values)
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) CreateInBatches(values []*models.ClientPermissionLink, batchSize int) error {
|
||||
return c.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 (c clientPermissionLinkDo) Save(values ...*models.ClientPermissionLink) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return c.DO.Save(values)
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) First() (*models.ClientPermissionLink, error) {
|
||||
if result, err := c.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.ClientPermissionLink), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) Take() (*models.ClientPermissionLink, error) {
|
||||
if result, err := c.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.ClientPermissionLink), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) Last() (*models.ClientPermissionLink, error) {
|
||||
if result, err := c.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.ClientPermissionLink), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) Find() ([]*models.ClientPermissionLink, error) {
|
||||
result, err := c.DO.Find()
|
||||
return result.([]*models.ClientPermissionLink), err
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.ClientPermissionLink, err error) {
|
||||
buf := make([]*models.ClientPermissionLink, 0, batchSize)
|
||||
err = c.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 (c clientPermissionLinkDo) FindInBatches(result *[]*models.ClientPermissionLink, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return c.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) Attrs(attrs ...field.AssignExpr) *clientPermissionLinkDo {
|
||||
return c.withDO(c.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) Assign(attrs ...field.AssignExpr) *clientPermissionLinkDo {
|
||||
return c.withDO(c.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) Joins(fields ...field.RelationField) *clientPermissionLinkDo {
|
||||
for _, _f := range fields {
|
||||
c = *c.withDO(c.DO.Joins(_f))
|
||||
}
|
||||
return &c
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) Preload(fields ...field.RelationField) *clientPermissionLinkDo {
|
||||
for _, _f := range fields {
|
||||
c = *c.withDO(c.DO.Preload(_f))
|
||||
}
|
||||
return &c
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) FirstOrInit() (*models.ClientPermissionLink, error) {
|
||||
if result, err := c.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.ClientPermissionLink), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) FirstOrCreate() (*models.ClientPermissionLink, error) {
|
||||
if result, err := c.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.ClientPermissionLink), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) FindByPage(offset int, limit int) (result []*models.ClientPermissionLink, count int64, err error) {
|
||||
result, err = c.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 = c.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = c.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = c.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) Scan(result interface{}) (err error) {
|
||||
return c.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (c clientPermissionLinkDo) Delete(models ...*models.ClientPermissionLink) (result gen.ResultInfo, err error) {
|
||||
return c.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (c *clientPermissionLinkDo) withDO(do gen.Dao) *clientPermissionLinkDo {
|
||||
c.DO = *do.(*gen.DO)
|
||||
return c
|
||||
}
|
||||
Reference in New Issue
Block a user