360 lines
9.4 KiB
Go
360 lines
9.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 query
|
|
|
|
import (
|
|
"context"
|
|
|
|
"gorm.io/gorm"
|
|
"gorm.io/gorm/clause"
|
|
"gorm.io/gorm/schema"
|
|
|
|
"gorm.io/gen"
|
|
"gorm.io/gen/field"
|
|
|
|
"gorm.io/plugin/dbresolver"
|
|
|
|
"gitea.youtukeji.com.cn/xiabin/youtu_server/gorm-gen/dao/model"
|
|
)
|
|
|
|
func newAppUser(db *gorm.DB, opts ...gen.DOOption) appUser {
|
|
_appUser := appUser{}
|
|
|
|
_appUser.appUserDo.UseDB(db, opts...)
|
|
_appUser.appUserDo.UseModel(&model.AppUser{})
|
|
|
|
tableName := _appUser.appUserDo.TableName()
|
|
_appUser.ALL = field.NewAsterisk(tableName)
|
|
_appUser.ID = field.NewUint64(tableName, "id")
|
|
_appUser.AppAccountID = field.NewUint32(tableName, "app_account_id")
|
|
_appUser.Openid = field.NewString(tableName, "openid")
|
|
_appUser.Unionid = field.NewString(tableName, "unionid")
|
|
_appUser.Nickname = field.NewString(tableName, "nickname")
|
|
_appUser.Avatar = field.NewString(tableName, "avatar")
|
|
_appUser.AnonymousOpenid = field.NewString(tableName, "anonymous_openid")
|
|
_appUser.CreatedAt = field.NewTime(tableName, "created_at")
|
|
_appUser.UpdatedAt = field.NewTime(tableName, "updated_at")
|
|
|
|
_appUser.fillFieldMap()
|
|
|
|
return _appUser
|
|
}
|
|
|
|
type appUser struct {
|
|
appUserDo appUserDo
|
|
|
|
ALL field.Asterisk
|
|
ID field.Uint64
|
|
AppAccountID field.Uint32 // app_account表外键
|
|
Openid field.String
|
|
Unionid field.String
|
|
Nickname field.String // 昵称
|
|
Avatar field.String // 头像
|
|
AnonymousOpenid field.String // 匿名openid
|
|
CreatedAt field.Time // 创建时间
|
|
UpdatedAt field.Time // 更新时间
|
|
|
|
fieldMap map[string]field.Expr
|
|
}
|
|
|
|
func (a appUser) Table(newTableName string) *appUser {
|
|
a.appUserDo.UseTable(newTableName)
|
|
return a.updateTableName(newTableName)
|
|
}
|
|
|
|
func (a appUser) As(alias string) *appUser {
|
|
a.appUserDo.DO = *(a.appUserDo.As(alias).(*gen.DO))
|
|
return a.updateTableName(alias)
|
|
}
|
|
|
|
func (a *appUser) updateTableName(table string) *appUser {
|
|
a.ALL = field.NewAsterisk(table)
|
|
a.ID = field.NewUint64(table, "id")
|
|
a.AppAccountID = field.NewUint32(table, "app_account_id")
|
|
a.Openid = field.NewString(table, "openid")
|
|
a.Unionid = field.NewString(table, "unionid")
|
|
a.Nickname = field.NewString(table, "nickname")
|
|
a.Avatar = field.NewString(table, "avatar")
|
|
a.AnonymousOpenid = field.NewString(table, "anonymous_openid")
|
|
a.CreatedAt = field.NewTime(table, "created_at")
|
|
a.UpdatedAt = field.NewTime(table, "updated_at")
|
|
|
|
a.fillFieldMap()
|
|
|
|
return a
|
|
}
|
|
|
|
func (a *appUser) WithContext(ctx context.Context) *appUserDo { return a.appUserDo.WithContext(ctx) }
|
|
|
|
func (a appUser) TableName() string { return a.appUserDo.TableName() }
|
|
|
|
func (a appUser) Alias() string { return a.appUserDo.Alias() }
|
|
|
|
func (a appUser) Columns(cols ...field.Expr) gen.Columns { return a.appUserDo.Columns(cols...) }
|
|
|
|
func (a *appUser) 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 *appUser) fillFieldMap() {
|
|
a.fieldMap = make(map[string]field.Expr, 9)
|
|
a.fieldMap["id"] = a.ID
|
|
a.fieldMap["app_account_id"] = a.AppAccountID
|
|
a.fieldMap["openid"] = a.Openid
|
|
a.fieldMap["unionid"] = a.Unionid
|
|
a.fieldMap["nickname"] = a.Nickname
|
|
a.fieldMap["avatar"] = a.Avatar
|
|
a.fieldMap["anonymous_openid"] = a.AnonymousOpenid
|
|
a.fieldMap["created_at"] = a.CreatedAt
|
|
a.fieldMap["updated_at"] = a.UpdatedAt
|
|
}
|
|
|
|
func (a appUser) clone(db *gorm.DB) appUser {
|
|
a.appUserDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
return a
|
|
}
|
|
|
|
func (a appUser) replaceDB(db *gorm.DB) appUser {
|
|
a.appUserDo.ReplaceDB(db)
|
|
return a
|
|
}
|
|
|
|
type appUserDo struct{ gen.DO }
|
|
|
|
func (a appUserDo) Debug() *appUserDo {
|
|
return a.withDO(a.DO.Debug())
|
|
}
|
|
|
|
func (a appUserDo) WithContext(ctx context.Context) *appUserDo {
|
|
return a.withDO(a.DO.WithContext(ctx))
|
|
}
|
|
|
|
func (a appUserDo) ReadDB() *appUserDo {
|
|
return a.Clauses(dbresolver.Read)
|
|
}
|
|
|
|
func (a appUserDo) WriteDB() *appUserDo {
|
|
return a.Clauses(dbresolver.Write)
|
|
}
|
|
|
|
func (a appUserDo) Session(config *gorm.Session) *appUserDo {
|
|
return a.withDO(a.DO.Session(config))
|
|
}
|
|
|
|
func (a appUserDo) Clauses(conds ...clause.Expression) *appUserDo {
|
|
return a.withDO(a.DO.Clauses(conds...))
|
|
}
|
|
|
|
func (a appUserDo) Returning(value interface{}, columns ...string) *appUserDo {
|
|
return a.withDO(a.DO.Returning(value, columns...))
|
|
}
|
|
|
|
func (a appUserDo) Not(conds ...gen.Condition) *appUserDo {
|
|
return a.withDO(a.DO.Not(conds...))
|
|
}
|
|
|
|
func (a appUserDo) Or(conds ...gen.Condition) *appUserDo {
|
|
return a.withDO(a.DO.Or(conds...))
|
|
}
|
|
|
|
func (a appUserDo) Select(conds ...field.Expr) *appUserDo {
|
|
return a.withDO(a.DO.Select(conds...))
|
|
}
|
|
|
|
func (a appUserDo) Where(conds ...gen.Condition) *appUserDo {
|
|
return a.withDO(a.DO.Where(conds...))
|
|
}
|
|
|
|
func (a appUserDo) Order(conds ...field.Expr) *appUserDo {
|
|
return a.withDO(a.DO.Order(conds...))
|
|
}
|
|
|
|
func (a appUserDo) Distinct(cols ...field.Expr) *appUserDo {
|
|
return a.withDO(a.DO.Distinct(cols...))
|
|
}
|
|
|
|
func (a appUserDo) Omit(cols ...field.Expr) *appUserDo {
|
|
return a.withDO(a.DO.Omit(cols...))
|
|
}
|
|
|
|
func (a appUserDo) Join(table schema.Tabler, on ...field.Expr) *appUserDo {
|
|
return a.withDO(a.DO.Join(table, on...))
|
|
}
|
|
|
|
func (a appUserDo) LeftJoin(table schema.Tabler, on ...field.Expr) *appUserDo {
|
|
return a.withDO(a.DO.LeftJoin(table, on...))
|
|
}
|
|
|
|
func (a appUserDo) RightJoin(table schema.Tabler, on ...field.Expr) *appUserDo {
|
|
return a.withDO(a.DO.RightJoin(table, on...))
|
|
}
|
|
|
|
func (a appUserDo) Group(cols ...field.Expr) *appUserDo {
|
|
return a.withDO(a.DO.Group(cols...))
|
|
}
|
|
|
|
func (a appUserDo) Having(conds ...gen.Condition) *appUserDo {
|
|
return a.withDO(a.DO.Having(conds...))
|
|
}
|
|
|
|
func (a appUserDo) Limit(limit int) *appUserDo {
|
|
return a.withDO(a.DO.Limit(limit))
|
|
}
|
|
|
|
func (a appUserDo) Offset(offset int) *appUserDo {
|
|
return a.withDO(a.DO.Offset(offset))
|
|
}
|
|
|
|
func (a appUserDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *appUserDo {
|
|
return a.withDO(a.DO.Scopes(funcs...))
|
|
}
|
|
|
|
func (a appUserDo) Unscoped() *appUserDo {
|
|
return a.withDO(a.DO.Unscoped())
|
|
}
|
|
|
|
func (a appUserDo) Create(values ...*model.AppUser) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return a.DO.Create(values)
|
|
}
|
|
|
|
func (a appUserDo) CreateInBatches(values []*model.AppUser, 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 appUserDo) Save(values ...*model.AppUser) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return a.DO.Save(values)
|
|
}
|
|
|
|
func (a appUserDo) First() (*model.AppUser, error) {
|
|
if result, err := a.DO.First(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.AppUser), nil
|
|
}
|
|
}
|
|
|
|
func (a appUserDo) Take() (*model.AppUser, error) {
|
|
if result, err := a.DO.Take(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.AppUser), nil
|
|
}
|
|
}
|
|
|
|
func (a appUserDo) Last() (*model.AppUser, error) {
|
|
if result, err := a.DO.Last(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.AppUser), nil
|
|
}
|
|
}
|
|
|
|
func (a appUserDo) Find() ([]*model.AppUser, error) {
|
|
result, err := a.DO.Find()
|
|
return result.([]*model.AppUser), err
|
|
}
|
|
|
|
func (a appUserDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AppUser, err error) {
|
|
buf := make([]*model.AppUser, 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 appUserDo) FindInBatches(result *[]*model.AppUser, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
return a.DO.FindInBatches(result, batchSize, fc)
|
|
}
|
|
|
|
func (a appUserDo) Attrs(attrs ...field.AssignExpr) *appUserDo {
|
|
return a.withDO(a.DO.Attrs(attrs...))
|
|
}
|
|
|
|
func (a appUserDo) Assign(attrs ...field.AssignExpr) *appUserDo {
|
|
return a.withDO(a.DO.Assign(attrs...))
|
|
}
|
|
|
|
func (a appUserDo) Joins(fields ...field.RelationField) *appUserDo {
|
|
for _, _f := range fields {
|
|
a = *a.withDO(a.DO.Joins(_f))
|
|
}
|
|
return &a
|
|
}
|
|
|
|
func (a appUserDo) Preload(fields ...field.RelationField) *appUserDo {
|
|
for _, _f := range fields {
|
|
a = *a.withDO(a.DO.Preload(_f))
|
|
}
|
|
return &a
|
|
}
|
|
|
|
func (a appUserDo) FirstOrInit() (*model.AppUser, error) {
|
|
if result, err := a.DO.FirstOrInit(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.AppUser), nil
|
|
}
|
|
}
|
|
|
|
func (a appUserDo) FirstOrCreate() (*model.AppUser, error) {
|
|
if result, err := a.DO.FirstOrCreate(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.AppUser), nil
|
|
}
|
|
}
|
|
|
|
func (a appUserDo) FindByPage(offset int, limit int) (result []*model.AppUser, 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 appUserDo) 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 appUserDo) Scan(result interface{}) (err error) {
|
|
return a.DO.Scan(result)
|
|
}
|
|
|
|
func (a appUserDo) Delete(models ...*model.AppUser) (result gen.ResultInfo, err error) {
|
|
return a.DO.Delete(models)
|
|
}
|
|
|
|
func (a *appUserDo) withDO(do gen.Dao) *appUserDo {
|
|
a.DO = *do.(*gen.DO)
|
|
return a
|
|
}
|