354 lines
9.5 KiB
Go
354 lines
9.5 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"
|
|
|
|
"youtu_ecpm/dao/model"
|
|
)
|
|
|
|
func newAppUserInfo(db *gorm.DB, opts ...gen.DOOption) appUserInfo {
|
|
_appUserInfo := appUserInfo{}
|
|
|
|
_appUserInfo.appUserInfoDo.UseDB(db, opts...)
|
|
_appUserInfo.appUserInfoDo.UseModel(&model.AppUserInfo{})
|
|
|
|
tableName := _appUserInfo.appUserInfoDo.TableName()
|
|
_appUserInfo.ALL = field.NewAsterisk(tableName)
|
|
_appUserInfo.ID = field.NewUint64(tableName, "id")
|
|
_appUserInfo.AppAccountID = field.NewUint32(tableName, "app_account_id")
|
|
_appUserInfo.Openid = field.NewString(tableName, "openid")
|
|
_appUserInfo.Unionid = field.NewString(tableName, "unionid")
|
|
_appUserInfo.Nickname = field.NewString(tableName, "nickname")
|
|
_appUserInfo.Avatar = field.NewString(tableName, "avatar")
|
|
_appUserInfo.AnonymousOpenid = field.NewString(tableName, "anonymous_openid")
|
|
|
|
_appUserInfo.fillFieldMap()
|
|
|
|
return _appUserInfo
|
|
}
|
|
|
|
type appUserInfo struct {
|
|
appUserInfoDo appUserInfoDo
|
|
|
|
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
|
|
|
|
fieldMap map[string]field.Expr
|
|
}
|
|
|
|
func (a appUserInfo) Table(newTableName string) *appUserInfo {
|
|
a.appUserInfoDo.UseTable(newTableName)
|
|
return a.updateTableName(newTableName)
|
|
}
|
|
|
|
func (a appUserInfo) As(alias string) *appUserInfo {
|
|
a.appUserInfoDo.DO = *(a.appUserInfoDo.As(alias).(*gen.DO))
|
|
return a.updateTableName(alias)
|
|
}
|
|
|
|
func (a *appUserInfo) updateTableName(table string) *appUserInfo {
|
|
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.fillFieldMap()
|
|
|
|
return a
|
|
}
|
|
|
|
func (a *appUserInfo) WithContext(ctx context.Context) *appUserInfoDo {
|
|
return a.appUserInfoDo.WithContext(ctx)
|
|
}
|
|
|
|
func (a appUserInfo) TableName() string { return a.appUserInfoDo.TableName() }
|
|
|
|
func (a appUserInfo) Alias() string { return a.appUserInfoDo.Alias() }
|
|
|
|
func (a appUserInfo) Columns(cols ...field.Expr) gen.Columns { return a.appUserInfoDo.Columns(cols...) }
|
|
|
|
func (a *appUserInfo) 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 *appUserInfo) fillFieldMap() {
|
|
a.fieldMap = make(map[string]field.Expr, 7)
|
|
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
|
|
}
|
|
|
|
func (a appUserInfo) clone(db *gorm.DB) appUserInfo {
|
|
a.appUserInfoDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
return a
|
|
}
|
|
|
|
func (a appUserInfo) replaceDB(db *gorm.DB) appUserInfo {
|
|
a.appUserInfoDo.ReplaceDB(db)
|
|
return a
|
|
}
|
|
|
|
type appUserInfoDo struct{ gen.DO }
|
|
|
|
func (a appUserInfoDo) Debug() *appUserInfoDo {
|
|
return a.withDO(a.DO.Debug())
|
|
}
|
|
|
|
func (a appUserInfoDo) WithContext(ctx context.Context) *appUserInfoDo {
|
|
return a.withDO(a.DO.WithContext(ctx))
|
|
}
|
|
|
|
func (a appUserInfoDo) ReadDB() *appUserInfoDo {
|
|
return a.Clauses(dbresolver.Read)
|
|
}
|
|
|
|
func (a appUserInfoDo) WriteDB() *appUserInfoDo {
|
|
return a.Clauses(dbresolver.Write)
|
|
}
|
|
|
|
func (a appUserInfoDo) Session(config *gorm.Session) *appUserInfoDo {
|
|
return a.withDO(a.DO.Session(config))
|
|
}
|
|
|
|
func (a appUserInfoDo) Clauses(conds ...clause.Expression) *appUserInfoDo {
|
|
return a.withDO(a.DO.Clauses(conds...))
|
|
}
|
|
|
|
func (a appUserInfoDo) Returning(value interface{}, columns ...string) *appUserInfoDo {
|
|
return a.withDO(a.DO.Returning(value, columns...))
|
|
}
|
|
|
|
func (a appUserInfoDo) Not(conds ...gen.Condition) *appUserInfoDo {
|
|
return a.withDO(a.DO.Not(conds...))
|
|
}
|
|
|
|
func (a appUserInfoDo) Or(conds ...gen.Condition) *appUserInfoDo {
|
|
return a.withDO(a.DO.Or(conds...))
|
|
}
|
|
|
|
func (a appUserInfoDo) Select(conds ...field.Expr) *appUserInfoDo {
|
|
return a.withDO(a.DO.Select(conds...))
|
|
}
|
|
|
|
func (a appUserInfoDo) Where(conds ...gen.Condition) *appUserInfoDo {
|
|
return a.withDO(a.DO.Where(conds...))
|
|
}
|
|
|
|
func (a appUserInfoDo) Order(conds ...field.Expr) *appUserInfoDo {
|
|
return a.withDO(a.DO.Order(conds...))
|
|
}
|
|
|
|
func (a appUserInfoDo) Distinct(cols ...field.Expr) *appUserInfoDo {
|
|
return a.withDO(a.DO.Distinct(cols...))
|
|
}
|
|
|
|
func (a appUserInfoDo) Omit(cols ...field.Expr) *appUserInfoDo {
|
|
return a.withDO(a.DO.Omit(cols...))
|
|
}
|
|
|
|
func (a appUserInfoDo) Join(table schema.Tabler, on ...field.Expr) *appUserInfoDo {
|
|
return a.withDO(a.DO.Join(table, on...))
|
|
}
|
|
|
|
func (a appUserInfoDo) LeftJoin(table schema.Tabler, on ...field.Expr) *appUserInfoDo {
|
|
return a.withDO(a.DO.LeftJoin(table, on...))
|
|
}
|
|
|
|
func (a appUserInfoDo) RightJoin(table schema.Tabler, on ...field.Expr) *appUserInfoDo {
|
|
return a.withDO(a.DO.RightJoin(table, on...))
|
|
}
|
|
|
|
func (a appUserInfoDo) Group(cols ...field.Expr) *appUserInfoDo {
|
|
return a.withDO(a.DO.Group(cols...))
|
|
}
|
|
|
|
func (a appUserInfoDo) Having(conds ...gen.Condition) *appUserInfoDo {
|
|
return a.withDO(a.DO.Having(conds...))
|
|
}
|
|
|
|
func (a appUserInfoDo) Limit(limit int) *appUserInfoDo {
|
|
return a.withDO(a.DO.Limit(limit))
|
|
}
|
|
|
|
func (a appUserInfoDo) Offset(offset int) *appUserInfoDo {
|
|
return a.withDO(a.DO.Offset(offset))
|
|
}
|
|
|
|
func (a appUserInfoDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *appUserInfoDo {
|
|
return a.withDO(a.DO.Scopes(funcs...))
|
|
}
|
|
|
|
func (a appUserInfoDo) Unscoped() *appUserInfoDo {
|
|
return a.withDO(a.DO.Unscoped())
|
|
}
|
|
|
|
func (a appUserInfoDo) Create(values ...*model.AppUserInfo) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return a.DO.Create(values)
|
|
}
|
|
|
|
func (a appUserInfoDo) CreateInBatches(values []*model.AppUserInfo, 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 appUserInfoDo) Save(values ...*model.AppUserInfo) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return a.DO.Save(values)
|
|
}
|
|
|
|
func (a appUserInfoDo) First() (*model.AppUserInfo, error) {
|
|
if result, err := a.DO.First(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.AppUserInfo), nil
|
|
}
|
|
}
|
|
|
|
func (a appUserInfoDo) Take() (*model.AppUserInfo, error) {
|
|
if result, err := a.DO.Take(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.AppUserInfo), nil
|
|
}
|
|
}
|
|
|
|
func (a appUserInfoDo) Last() (*model.AppUserInfo, error) {
|
|
if result, err := a.DO.Last(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.AppUserInfo), nil
|
|
}
|
|
}
|
|
|
|
func (a appUserInfoDo) Find() ([]*model.AppUserInfo, error) {
|
|
result, err := a.DO.Find()
|
|
return result.([]*model.AppUserInfo), err
|
|
}
|
|
|
|
func (a appUserInfoDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AppUserInfo, err error) {
|
|
buf := make([]*model.AppUserInfo, 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 appUserInfoDo) FindInBatches(result *[]*model.AppUserInfo, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
return a.DO.FindInBatches(result, batchSize, fc)
|
|
}
|
|
|
|
func (a appUserInfoDo) Attrs(attrs ...field.AssignExpr) *appUserInfoDo {
|
|
return a.withDO(a.DO.Attrs(attrs...))
|
|
}
|
|
|
|
func (a appUserInfoDo) Assign(attrs ...field.AssignExpr) *appUserInfoDo {
|
|
return a.withDO(a.DO.Assign(attrs...))
|
|
}
|
|
|
|
func (a appUserInfoDo) Joins(fields ...field.RelationField) *appUserInfoDo {
|
|
for _, _f := range fields {
|
|
a = *a.withDO(a.DO.Joins(_f))
|
|
}
|
|
return &a
|
|
}
|
|
|
|
func (a appUserInfoDo) Preload(fields ...field.RelationField) *appUserInfoDo {
|
|
for _, _f := range fields {
|
|
a = *a.withDO(a.DO.Preload(_f))
|
|
}
|
|
return &a
|
|
}
|
|
|
|
func (a appUserInfoDo) FirstOrInit() (*model.AppUserInfo, error) {
|
|
if result, err := a.DO.FirstOrInit(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.AppUserInfo), nil
|
|
}
|
|
}
|
|
|
|
func (a appUserInfoDo) FirstOrCreate() (*model.AppUserInfo, error) {
|
|
if result, err := a.DO.FirstOrCreate(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.AppUserInfo), nil
|
|
}
|
|
}
|
|
|
|
func (a appUserInfoDo) FindByPage(offset int, limit int) (result []*model.AppUserInfo, 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 appUserInfoDo) 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 appUserInfoDo) Scan(result interface{}) (err error) {
|
|
return a.DO.Scan(result)
|
|
}
|
|
|
|
func (a appUserInfoDo) Delete(models ...*model.AppUserInfo) (result gen.ResultInfo, err error) {
|
|
return a.DO.Delete(models)
|
|
}
|
|
|
|
func (a *appUserInfoDo) withDO(do gen.Dao) *appUserInfoDo {
|
|
a.DO = *do.(*gen.DO)
|
|
return a
|
|
}
|