chore(new-storage): Auto-generate new storage impl
Some checks are pending
/ test (push) Waiting to run
Some checks are pending
/ test (push) Waiting to run
This commit is contained in:
parent
8ffd6d0050
commit
68859642f3
19 changed files with 10441 additions and 0 deletions
465
storage-new/dbgen/user_auth_methods.gen.go
Normal file
465
storage-new/dbgen/user_auth_methods.gen.go
Normal file
|
@ -0,0 +1,465 @@
|
|||
// 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 dbgen
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.mstar.dev/mstar/linstrom/storage-new/models"
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
)
|
||||
|
||||
func newUserAuthMethod(db *gorm.DB, opts ...gen.DOOption) userAuthMethod {
|
||||
_userAuthMethod := userAuthMethod{}
|
||||
|
||||
_userAuthMethod.userAuthMethodDo.UseDB(db, opts...)
|
||||
_userAuthMethod.userAuthMethodDo.UseModel(&models.UserAuthMethod{})
|
||||
|
||||
tableName := _userAuthMethod.userAuthMethodDo.TableName()
|
||||
_userAuthMethod.ALL = field.NewAsterisk(tableName)
|
||||
_userAuthMethod.UserId = field.NewString(tableName, "user_id")
|
||||
_userAuthMethod.AuthMethod = field.NewField(tableName, "auth_method")
|
||||
_userAuthMethod.Token = field.NewBytes(tableName, "token")
|
||||
_userAuthMethod.User = userAuthMethodBelongsToUser{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("User", "models.User"),
|
||||
}
|
||||
|
||||
_userAuthMethod.fillFieldMap()
|
||||
|
||||
return _userAuthMethod
|
||||
}
|
||||
|
||||
type userAuthMethod struct {
|
||||
userAuthMethodDo
|
||||
|
||||
ALL field.Asterisk
|
||||
UserId field.String
|
||||
AuthMethod field.Field
|
||||
Token field.Bytes
|
||||
User userAuthMethodBelongsToUser
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (u userAuthMethod) Table(newTableName string) *userAuthMethod {
|
||||
u.userAuthMethodDo.UseTable(newTableName)
|
||||
return u.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (u userAuthMethod) As(alias string) *userAuthMethod {
|
||||
u.userAuthMethodDo.DO = *(u.userAuthMethodDo.As(alias).(*gen.DO))
|
||||
return u.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (u *userAuthMethod) updateTableName(table string) *userAuthMethod {
|
||||
u.ALL = field.NewAsterisk(table)
|
||||
u.UserId = field.NewString(table, "user_id")
|
||||
u.AuthMethod = field.NewField(table, "auth_method")
|
||||
u.Token = field.NewBytes(table, "token")
|
||||
|
||||
u.fillFieldMap()
|
||||
|
||||
return u
|
||||
}
|
||||
|
||||
func (u *userAuthMethod) 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 *userAuthMethod) fillFieldMap() {
|
||||
u.fieldMap = make(map[string]field.Expr, 4)
|
||||
u.fieldMap["user_id"] = u.UserId
|
||||
u.fieldMap["auth_method"] = u.AuthMethod
|
||||
u.fieldMap["token"] = u.Token
|
||||
|
||||
}
|
||||
|
||||
func (u userAuthMethod) clone(db *gorm.DB) userAuthMethod {
|
||||
u.userAuthMethodDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return u
|
||||
}
|
||||
|
||||
func (u userAuthMethod) replaceDB(db *gorm.DB) userAuthMethod {
|
||||
u.userAuthMethodDo.ReplaceDB(db)
|
||||
return u
|
||||
}
|
||||
|
||||
type userAuthMethodBelongsToUser struct {
|
||||
db *gorm.DB
|
||||
|
||||
field.RelationField
|
||||
}
|
||||
|
||||
func (a userAuthMethodBelongsToUser) Where(conds ...field.Expr) *userAuthMethodBelongsToUser {
|
||||
if len(conds) == 0 {
|
||||
return &a
|
||||
}
|
||||
|
||||
exprs := make([]clause.Expression, 0, len(conds))
|
||||
for _, cond := range conds {
|
||||
exprs = append(exprs, cond.BeCond().(clause.Expression))
|
||||
}
|
||||
a.db = a.db.Clauses(clause.Where{Exprs: exprs})
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a userAuthMethodBelongsToUser) WithContext(ctx context.Context) *userAuthMethodBelongsToUser {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a userAuthMethodBelongsToUser) Session(session *gorm.Session) *userAuthMethodBelongsToUser {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a userAuthMethodBelongsToUser) Model(m *models.UserAuthMethod) *userAuthMethodBelongsToUserTx {
|
||||
return &userAuthMethodBelongsToUserTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
type userAuthMethodBelongsToUserTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a userAuthMethodBelongsToUserTx) Find() (result *models.User, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a userAuthMethodBelongsToUserTx) Append(values ...*models.User) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Append(targetValues...)
|
||||
}
|
||||
|
||||
func (a userAuthMethodBelongsToUserTx) Replace(values ...*models.User) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Replace(targetValues...)
|
||||
}
|
||||
|
||||
func (a userAuthMethodBelongsToUserTx) Delete(values ...*models.User) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Delete(targetValues...)
|
||||
}
|
||||
|
||||
func (a userAuthMethodBelongsToUserTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a userAuthMethodBelongsToUserTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
type userAuthMethodDo struct{ gen.DO }
|
||||
|
||||
type IUserAuthMethodDo interface {
|
||||
gen.SubQuery
|
||||
Debug() IUserAuthMethodDo
|
||||
WithContext(ctx context.Context) IUserAuthMethodDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() IUserAuthMethodDo
|
||||
WriteDB() IUserAuthMethodDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) IUserAuthMethodDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) IUserAuthMethodDo
|
||||
Not(conds ...gen.Condition) IUserAuthMethodDo
|
||||
Or(conds ...gen.Condition) IUserAuthMethodDo
|
||||
Select(conds ...field.Expr) IUserAuthMethodDo
|
||||
Where(conds ...gen.Condition) IUserAuthMethodDo
|
||||
Order(conds ...field.Expr) IUserAuthMethodDo
|
||||
Distinct(cols ...field.Expr) IUserAuthMethodDo
|
||||
Omit(cols ...field.Expr) IUserAuthMethodDo
|
||||
Join(table schema.Tabler, on ...field.Expr) IUserAuthMethodDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) IUserAuthMethodDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) IUserAuthMethodDo
|
||||
Group(cols ...field.Expr) IUserAuthMethodDo
|
||||
Having(conds ...gen.Condition) IUserAuthMethodDo
|
||||
Limit(limit int) IUserAuthMethodDo
|
||||
Offset(offset int) IUserAuthMethodDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) IUserAuthMethodDo
|
||||
Unscoped() IUserAuthMethodDo
|
||||
Create(values ...*models.UserAuthMethod) error
|
||||
CreateInBatches(values []*models.UserAuthMethod, batchSize int) error
|
||||
Save(values ...*models.UserAuthMethod) error
|
||||
First() (*models.UserAuthMethod, error)
|
||||
Take() (*models.UserAuthMethod, error)
|
||||
Last() (*models.UserAuthMethod, error)
|
||||
Find() ([]*models.UserAuthMethod, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.UserAuthMethod, err error)
|
||||
FindInBatches(result *[]*models.UserAuthMethod, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*models.UserAuthMethod) (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) IUserAuthMethodDo
|
||||
Assign(attrs ...field.AssignExpr) IUserAuthMethodDo
|
||||
Joins(fields ...field.RelationField) IUserAuthMethodDo
|
||||
Preload(fields ...field.RelationField) IUserAuthMethodDo
|
||||
FirstOrInit() (*models.UserAuthMethod, error)
|
||||
FirstOrCreate() (*models.UserAuthMethod, error)
|
||||
FindByPage(offset int, limit int) (result []*models.UserAuthMethod, 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) IUserAuthMethodDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Debug() IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Debug())
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) WithContext(ctx context.Context) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) ReadDB() IUserAuthMethodDo {
|
||||
return u.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) WriteDB() IUserAuthMethodDo {
|
||||
return u.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Session(config *gorm.Session) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Session(config))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Clauses(conds ...clause.Expression) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Returning(value interface{}, columns ...string) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Not(conds ...gen.Condition) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Or(conds ...gen.Condition) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Select(conds ...field.Expr) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Where(conds ...gen.Condition) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Order(conds ...field.Expr) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Distinct(cols ...field.Expr) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Omit(cols ...field.Expr) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Join(table schema.Tabler, on ...field.Expr) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) LeftJoin(table schema.Tabler, on ...field.Expr) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) RightJoin(table schema.Tabler, on ...field.Expr) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Group(cols ...field.Expr) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Having(conds ...gen.Condition) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Limit(limit int) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Offset(offset int) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Unscoped() IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Create(values ...*models.UserAuthMethod) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return u.DO.Create(values)
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) CreateInBatches(values []*models.UserAuthMethod, 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 userAuthMethodDo) Save(values ...*models.UserAuthMethod) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return u.DO.Save(values)
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) First() (*models.UserAuthMethod, error) {
|
||||
if result, err := u.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserAuthMethod), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Take() (*models.UserAuthMethod, error) {
|
||||
if result, err := u.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserAuthMethod), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Last() (*models.UserAuthMethod, error) {
|
||||
if result, err := u.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserAuthMethod), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Find() ([]*models.UserAuthMethod, error) {
|
||||
result, err := u.DO.Find()
|
||||
return result.([]*models.UserAuthMethod), err
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.UserAuthMethod, err error) {
|
||||
buf := make([]*models.UserAuthMethod, 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 userAuthMethodDo) FindInBatches(result *[]*models.UserAuthMethod, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return u.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Attrs(attrs ...field.AssignExpr) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Assign(attrs ...field.AssignExpr) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Joins(fields ...field.RelationField) IUserAuthMethodDo {
|
||||
for _, _f := range fields {
|
||||
u = *u.withDO(u.DO.Joins(_f))
|
||||
}
|
||||
return &u
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Preload(fields ...field.RelationField) IUserAuthMethodDo {
|
||||
for _, _f := range fields {
|
||||
u = *u.withDO(u.DO.Preload(_f))
|
||||
}
|
||||
return &u
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) FirstOrInit() (*models.UserAuthMethod, error) {
|
||||
if result, err := u.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserAuthMethod), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) FirstOrCreate() (*models.UserAuthMethod, error) {
|
||||
if result, err := u.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserAuthMethod), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) FindByPage(offset int, limit int) (result []*models.UserAuthMethod, 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 userAuthMethodDo) 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 userAuthMethodDo) Scan(result interface{}) (err error) {
|
||||
return u.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Delete(models ...*models.UserAuthMethod) (result gen.ResultInfo, err error) {
|
||||
return u.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (u *userAuthMethodDo) withDO(do gen.Dao) *userAuthMethodDo {
|
||||
u.DO = *do.(*gen.DO)
|
||||
return u
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue