youtu_server/gorm-gen/dao/query/app_account.gen.go
2025-01-25 18:19:07 +08:00

418 lines
12 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"
"strings"
"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 newAppAccount(db *gorm.DB, opts ...gen.DOOption) appAccount {
_appAccount := appAccount{}
_appAccount.appAccountDo.UseDB(db, opts...)
_appAccount.appAccountDo.UseModel(&model.AppAccount{})
tableName := _appAccount.appAccountDo.TableName()
_appAccount.ALL = field.NewAsterisk(tableName)
_appAccount.ID = field.NewUint32(tableName, "id")
_appAccount.Type = field.NewUint32(tableName, "type")
_appAccount.AppID = field.NewString(tableName, "app_id")
_appAccount.Secret = field.NewString(tableName, "secret")
_appAccount.Remark = field.NewString(tableName, "remark")
_appAccount.DeletedAt = field.NewField(tableName, "deleted_at")
_appAccount.fillFieldMap()
return _appAccount
}
type appAccount struct {
appAccountDo
ALL field.Asterisk
ID field.Uint32
Type field.Uint32
AppID field.String
Secret field.String
Remark field.String
DeletedAt field.Field
fieldMap map[string]field.Expr
}
func (a appAccount) Table(newTableName string) *appAccount {
a.appAccountDo.UseTable(newTableName)
return a.updateTableName(newTableName)
}
func (a appAccount) As(alias string) *appAccount {
a.appAccountDo.DO = *(a.appAccountDo.As(alias).(*gen.DO))
return a.updateTableName(alias)
}
func (a *appAccount) updateTableName(table string) *appAccount {
a.ALL = field.NewAsterisk(table)
a.ID = field.NewUint32(table, "id")
a.Type = field.NewUint32(table, "type")
a.AppID = field.NewString(table, "app_id")
a.Secret = field.NewString(table, "secret")
a.Remark = field.NewString(table, "remark")
a.DeletedAt = field.NewField(table, "deleted_at")
a.fillFieldMap()
return a
}
func (a *appAccount) 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 *appAccount) fillFieldMap() {
a.fieldMap = make(map[string]field.Expr, 6)
a.fieldMap["id"] = a.ID
a.fieldMap["type"] = a.Type
a.fieldMap["app_id"] = a.AppID
a.fieldMap["secret"] = a.Secret
a.fieldMap["remark"] = a.Remark
a.fieldMap["deleted_at"] = a.DeletedAt
}
func (a appAccount) clone(db *gorm.DB) appAccount {
a.appAccountDo.ReplaceConnPool(db.Statement.ConnPool)
return a
}
func (a appAccount) replaceDB(db *gorm.DB) appAccount {
a.appAccountDo.ReplaceDB(db)
return a
}
type appAccountDo struct{ gen.DO }
type IAppAccountDo interface {
gen.SubQuery
Debug() IAppAccountDo
WithContext(ctx context.Context) IAppAccountDo
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
ReplaceDB(db *gorm.DB)
ReadDB() IAppAccountDo
WriteDB() IAppAccountDo
As(alias string) gen.Dao
Session(config *gorm.Session) IAppAccountDo
Columns(cols ...field.Expr) gen.Columns
Clauses(conds ...clause.Expression) IAppAccountDo
Not(conds ...gen.Condition) IAppAccountDo
Or(conds ...gen.Condition) IAppAccountDo
Select(conds ...field.Expr) IAppAccountDo
Where(conds ...gen.Condition) IAppAccountDo
Order(conds ...field.Expr) IAppAccountDo
Distinct(cols ...field.Expr) IAppAccountDo
Omit(cols ...field.Expr) IAppAccountDo
Join(table schema.Tabler, on ...field.Expr) IAppAccountDo
LeftJoin(table schema.Tabler, on ...field.Expr) IAppAccountDo
RightJoin(table schema.Tabler, on ...field.Expr) IAppAccountDo
Group(cols ...field.Expr) IAppAccountDo
Having(conds ...gen.Condition) IAppAccountDo
Limit(limit int) IAppAccountDo
Offset(offset int) IAppAccountDo
Count() (count int64, err error)
Scopes(funcs ...func(gen.Dao) gen.Dao) IAppAccountDo
Unscoped() IAppAccountDo
Create(values ...*model.AppAccount) error
CreateInBatches(values []*model.AppAccount, batchSize int) error
Save(values ...*model.AppAccount) error
First() (*model.AppAccount, error)
Take() (*model.AppAccount, error)
Last() (*model.AppAccount, error)
Find() ([]*model.AppAccount, error)
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AppAccount, err error)
FindInBatches(result *[]*model.AppAccount, batchSize int, fc func(tx gen.Dao, batch int) error) error
Pluck(column field.Expr, dest interface{}) error
Delete(...*model.AppAccount) (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) IAppAccountDo
Assign(attrs ...field.AssignExpr) IAppAccountDo
Joins(fields ...field.RelationField) IAppAccountDo
Preload(fields ...field.RelationField) IAppAccountDo
FirstOrInit() (*model.AppAccount, error)
FirstOrCreate() (*model.AppAccount, error)
FindByPage(offset int, limit int) (result []*model.AppAccount, 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) IAppAccountDo
UnderlyingDB() *gorm.DB
schema.Tabler
GetAppConfig() (result []*model.AppAccount, err error)
}
// GetAppConfig 获取所有小游戏配置
//
// select `app_id`,`secret`,`ecpm_value`,`ecpm_view`,`type` from `app_account` left join douyin_ecpm_config on app_account.id = douyin_ecpm_config.app_account_id
func (a appAccountDo) GetAppConfig() (result []*model.AppAccount, err error) {
var generateSQL strings.Builder
generateSQL.WriteString("select `app_id`,`secret`,`ecpm_value`,`ecpm_view`,`type` from `app_account` left join douyin_ecpm_config on app_account.id = douyin_ecpm_config.app_account_id ")
var executeSQL *gorm.DB
executeSQL = a.UnderlyingDB().Raw(generateSQL.String()).Find(&result) // ignore_security_alert
err = executeSQL.Error
return
}
func (a appAccountDo) Debug() IAppAccountDo {
return a.withDO(a.DO.Debug())
}
func (a appAccountDo) WithContext(ctx context.Context) IAppAccountDo {
return a.withDO(a.DO.WithContext(ctx))
}
func (a appAccountDo) ReadDB() IAppAccountDo {
return a.Clauses(dbresolver.Read)
}
func (a appAccountDo) WriteDB() IAppAccountDo {
return a.Clauses(dbresolver.Write)
}
func (a appAccountDo) Session(config *gorm.Session) IAppAccountDo {
return a.withDO(a.DO.Session(config))
}
func (a appAccountDo) Clauses(conds ...clause.Expression) IAppAccountDo {
return a.withDO(a.DO.Clauses(conds...))
}
func (a appAccountDo) Returning(value interface{}, columns ...string) IAppAccountDo {
return a.withDO(a.DO.Returning(value, columns...))
}
func (a appAccountDo) Not(conds ...gen.Condition) IAppAccountDo {
return a.withDO(a.DO.Not(conds...))
}
func (a appAccountDo) Or(conds ...gen.Condition) IAppAccountDo {
return a.withDO(a.DO.Or(conds...))
}
func (a appAccountDo) Select(conds ...field.Expr) IAppAccountDo {
return a.withDO(a.DO.Select(conds...))
}
func (a appAccountDo) Where(conds ...gen.Condition) IAppAccountDo {
return a.withDO(a.DO.Where(conds...))
}
func (a appAccountDo) Order(conds ...field.Expr) IAppAccountDo {
return a.withDO(a.DO.Order(conds...))
}
func (a appAccountDo) Distinct(cols ...field.Expr) IAppAccountDo {
return a.withDO(a.DO.Distinct(cols...))
}
func (a appAccountDo) Omit(cols ...field.Expr) IAppAccountDo {
return a.withDO(a.DO.Omit(cols...))
}
func (a appAccountDo) Join(table schema.Tabler, on ...field.Expr) IAppAccountDo {
return a.withDO(a.DO.Join(table, on...))
}
func (a appAccountDo) LeftJoin(table schema.Tabler, on ...field.Expr) IAppAccountDo {
return a.withDO(a.DO.LeftJoin(table, on...))
}
func (a appAccountDo) RightJoin(table schema.Tabler, on ...field.Expr) IAppAccountDo {
return a.withDO(a.DO.RightJoin(table, on...))
}
func (a appAccountDo) Group(cols ...field.Expr) IAppAccountDo {
return a.withDO(a.DO.Group(cols...))
}
func (a appAccountDo) Having(conds ...gen.Condition) IAppAccountDo {
return a.withDO(a.DO.Having(conds...))
}
func (a appAccountDo) Limit(limit int) IAppAccountDo {
return a.withDO(a.DO.Limit(limit))
}
func (a appAccountDo) Offset(offset int) IAppAccountDo {
return a.withDO(a.DO.Offset(offset))
}
func (a appAccountDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IAppAccountDo {
return a.withDO(a.DO.Scopes(funcs...))
}
func (a appAccountDo) Unscoped() IAppAccountDo {
return a.withDO(a.DO.Unscoped())
}
func (a appAccountDo) Create(values ...*model.AppAccount) error {
if len(values) == 0 {
return nil
}
return a.DO.Create(values)
}
func (a appAccountDo) CreateInBatches(values []*model.AppAccount, 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 appAccountDo) Save(values ...*model.AppAccount) error {
if len(values) == 0 {
return nil
}
return a.DO.Save(values)
}
func (a appAccountDo) First() (*model.AppAccount, error) {
if result, err := a.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.AppAccount), nil
}
}
func (a appAccountDo) Take() (*model.AppAccount, error) {
if result, err := a.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.AppAccount), nil
}
}
func (a appAccountDo) Last() (*model.AppAccount, error) {
if result, err := a.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.AppAccount), nil
}
}
func (a appAccountDo) Find() ([]*model.AppAccount, error) {
result, err := a.DO.Find()
return result.([]*model.AppAccount), err
}
func (a appAccountDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AppAccount, err error) {
buf := make([]*model.AppAccount, 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 appAccountDo) FindInBatches(result *[]*model.AppAccount, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return a.DO.FindInBatches(result, batchSize, fc)
}
func (a appAccountDo) Attrs(attrs ...field.AssignExpr) IAppAccountDo {
return a.withDO(a.DO.Attrs(attrs...))
}
func (a appAccountDo) Assign(attrs ...field.AssignExpr) IAppAccountDo {
return a.withDO(a.DO.Assign(attrs...))
}
func (a appAccountDo) Joins(fields ...field.RelationField) IAppAccountDo {
for _, _f := range fields {
a = *a.withDO(a.DO.Joins(_f))
}
return &a
}
func (a appAccountDo) Preload(fields ...field.RelationField) IAppAccountDo {
for _, _f := range fields {
a = *a.withDO(a.DO.Preload(_f))
}
return &a
}
func (a appAccountDo) FirstOrInit() (*model.AppAccount, error) {
if result, err := a.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.AppAccount), nil
}
}
func (a appAccountDo) FirstOrCreate() (*model.AppAccount, error) {
if result, err := a.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.AppAccount), nil
}
}
func (a appAccountDo) FindByPage(offset int, limit int) (result []*model.AppAccount, 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 appAccountDo) 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 appAccountDo) Scan(result interface{}) (err error) {
return a.DO.Scan(result)
}
func (a appAccountDo) Delete(models ...*model.AppAccount) (result gen.ResultInfo, err error) {
return a.DO.Delete(models)
}
func (a *appAccountDo) withDO(do gen.Dao) *appAccountDo {
a.DO = *do.(*gen.DO)
return a
}