345 lines
9.0 KiB
Go
345 lines
9.0 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 dao
|
|
|
|
import (
|
|
"context"
|
|
|
|
"gorm.io/gorm"
|
|
"gorm.io/gorm/clause"
|
|
"gorm.io/gorm/schema"
|
|
|
|
"gorm.io/gen"
|
|
"gorm.io/gen/field"
|
|
|
|
"gorm.io/plugin/dbresolver"
|
|
|
|
"mini-chat/internal/repository/mysql/model"
|
|
)
|
|
|
|
func newAppKeyword(db *gorm.DB, opts ...gen.DOOption) appKeyword {
|
|
_appKeyword := appKeyword{}
|
|
|
|
_appKeyword.appKeywordDo.UseDB(db, opts...)
|
|
_appKeyword.appKeywordDo.UseModel(&model.AppKeyword{})
|
|
|
|
tableName := _appKeyword.appKeywordDo.TableName()
|
|
_appKeyword.ALL = field.NewAsterisk(tableName)
|
|
_appKeyword.ID = field.NewInt32(tableName, "id")
|
|
_appKeyword.AppID = field.NewString(tableName, "app_id")
|
|
_appKeyword.Keyword = field.NewString(tableName, "keyword")
|
|
_appKeyword.CreatedUser = field.NewString(tableName, "created_user")
|
|
_appKeyword.CreatedAt = field.NewTime(tableName, "created_at")
|
|
_appKeyword.UpdatedUser = field.NewString(tableName, "updated_user")
|
|
_appKeyword.UpdatedAt = field.NewTime(tableName, "updated_at")
|
|
|
|
_appKeyword.fillFieldMap()
|
|
|
|
return _appKeyword
|
|
}
|
|
|
|
// appKeyword 关键字表
|
|
type appKeyword struct {
|
|
appKeywordDo
|
|
|
|
ALL field.Asterisk
|
|
ID field.Int32 // 主键ID
|
|
AppID field.String // 小程序ID
|
|
Keyword field.String // 关键字
|
|
CreatedUser field.String // 创建人
|
|
CreatedAt field.Time // 创建时间
|
|
UpdatedUser field.String // 更新人
|
|
UpdatedAt field.Time // 更新时间
|
|
|
|
fieldMap map[string]field.Expr
|
|
}
|
|
|
|
func (a appKeyword) Table(newTableName string) *appKeyword {
|
|
a.appKeywordDo.UseTable(newTableName)
|
|
return a.updateTableName(newTableName)
|
|
}
|
|
|
|
func (a appKeyword) As(alias string) *appKeyword {
|
|
a.appKeywordDo.DO = *(a.appKeywordDo.As(alias).(*gen.DO))
|
|
return a.updateTableName(alias)
|
|
}
|
|
|
|
func (a *appKeyword) updateTableName(table string) *appKeyword {
|
|
a.ALL = field.NewAsterisk(table)
|
|
a.ID = field.NewInt32(table, "id")
|
|
a.AppID = field.NewString(table, "app_id")
|
|
a.Keyword = field.NewString(table, "keyword")
|
|
a.CreatedUser = field.NewString(table, "created_user")
|
|
a.CreatedAt = field.NewTime(table, "created_at")
|
|
a.UpdatedUser = field.NewString(table, "updated_user")
|
|
a.UpdatedAt = field.NewTime(table, "updated_at")
|
|
|
|
a.fillFieldMap()
|
|
|
|
return a
|
|
}
|
|
|
|
func (a *appKeyword) 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 *appKeyword) fillFieldMap() {
|
|
a.fieldMap = make(map[string]field.Expr, 7)
|
|
a.fieldMap["id"] = a.ID
|
|
a.fieldMap["app_id"] = a.AppID
|
|
a.fieldMap["keyword"] = a.Keyword
|
|
a.fieldMap["created_user"] = a.CreatedUser
|
|
a.fieldMap["created_at"] = a.CreatedAt
|
|
a.fieldMap["updated_user"] = a.UpdatedUser
|
|
a.fieldMap["updated_at"] = a.UpdatedAt
|
|
}
|
|
|
|
func (a appKeyword) clone(db *gorm.DB) appKeyword {
|
|
a.appKeywordDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
return a
|
|
}
|
|
|
|
func (a appKeyword) replaceDB(db *gorm.DB) appKeyword {
|
|
a.appKeywordDo.ReplaceDB(db)
|
|
return a
|
|
}
|
|
|
|
type appKeywordDo struct{ gen.DO }
|
|
|
|
func (a appKeywordDo) Debug() *appKeywordDo {
|
|
return a.withDO(a.DO.Debug())
|
|
}
|
|
|
|
func (a appKeywordDo) WithContext(ctx context.Context) *appKeywordDo {
|
|
return a.withDO(a.DO.WithContext(ctx))
|
|
}
|
|
|
|
func (a appKeywordDo) ReadDB() *appKeywordDo {
|
|
return a.Clauses(dbresolver.Read)
|
|
}
|
|
|
|
func (a appKeywordDo) WriteDB() *appKeywordDo {
|
|
return a.Clauses(dbresolver.Write)
|
|
}
|
|
|
|
func (a appKeywordDo) Session(config *gorm.Session) *appKeywordDo {
|
|
return a.withDO(a.DO.Session(config))
|
|
}
|
|
|
|
func (a appKeywordDo) Clauses(conds ...clause.Expression) *appKeywordDo {
|
|
return a.withDO(a.DO.Clauses(conds...))
|
|
}
|
|
|
|
func (a appKeywordDo) Returning(value interface{}, columns ...string) *appKeywordDo {
|
|
return a.withDO(a.DO.Returning(value, columns...))
|
|
}
|
|
|
|
func (a appKeywordDo) Not(conds ...gen.Condition) *appKeywordDo {
|
|
return a.withDO(a.DO.Not(conds...))
|
|
}
|
|
|
|
func (a appKeywordDo) Or(conds ...gen.Condition) *appKeywordDo {
|
|
return a.withDO(a.DO.Or(conds...))
|
|
}
|
|
|
|
func (a appKeywordDo) Select(conds ...field.Expr) *appKeywordDo {
|
|
return a.withDO(a.DO.Select(conds...))
|
|
}
|
|
|
|
func (a appKeywordDo) Where(conds ...gen.Condition) *appKeywordDo {
|
|
return a.withDO(a.DO.Where(conds...))
|
|
}
|
|
|
|
func (a appKeywordDo) Order(conds ...field.Expr) *appKeywordDo {
|
|
return a.withDO(a.DO.Order(conds...))
|
|
}
|
|
|
|
func (a appKeywordDo) Distinct(cols ...field.Expr) *appKeywordDo {
|
|
return a.withDO(a.DO.Distinct(cols...))
|
|
}
|
|
|
|
func (a appKeywordDo) Omit(cols ...field.Expr) *appKeywordDo {
|
|
return a.withDO(a.DO.Omit(cols...))
|
|
}
|
|
|
|
func (a appKeywordDo) Join(table schema.Tabler, on ...field.Expr) *appKeywordDo {
|
|
return a.withDO(a.DO.Join(table, on...))
|
|
}
|
|
|
|
func (a appKeywordDo) LeftJoin(table schema.Tabler, on ...field.Expr) *appKeywordDo {
|
|
return a.withDO(a.DO.LeftJoin(table, on...))
|
|
}
|
|
|
|
func (a appKeywordDo) RightJoin(table schema.Tabler, on ...field.Expr) *appKeywordDo {
|
|
return a.withDO(a.DO.RightJoin(table, on...))
|
|
}
|
|
|
|
func (a appKeywordDo) Group(cols ...field.Expr) *appKeywordDo {
|
|
return a.withDO(a.DO.Group(cols...))
|
|
}
|
|
|
|
func (a appKeywordDo) Having(conds ...gen.Condition) *appKeywordDo {
|
|
return a.withDO(a.DO.Having(conds...))
|
|
}
|
|
|
|
func (a appKeywordDo) Limit(limit int) *appKeywordDo {
|
|
return a.withDO(a.DO.Limit(limit))
|
|
}
|
|
|
|
func (a appKeywordDo) Offset(offset int) *appKeywordDo {
|
|
return a.withDO(a.DO.Offset(offset))
|
|
}
|
|
|
|
func (a appKeywordDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *appKeywordDo {
|
|
return a.withDO(a.DO.Scopes(funcs...))
|
|
}
|
|
|
|
func (a appKeywordDo) Unscoped() *appKeywordDo {
|
|
return a.withDO(a.DO.Unscoped())
|
|
}
|
|
|
|
func (a appKeywordDo) Create(values ...*model.AppKeyword) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return a.DO.Create(values)
|
|
}
|
|
|
|
func (a appKeywordDo) CreateInBatches(values []*model.AppKeyword, 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 appKeywordDo) Save(values ...*model.AppKeyword) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return a.DO.Save(values)
|
|
}
|
|
|
|
func (a appKeywordDo) First() (*model.AppKeyword, error) {
|
|
if result, err := a.DO.First(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.AppKeyword), nil
|
|
}
|
|
}
|
|
|
|
func (a appKeywordDo) Take() (*model.AppKeyword, error) {
|
|
if result, err := a.DO.Take(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.AppKeyword), nil
|
|
}
|
|
}
|
|
|
|
func (a appKeywordDo) Last() (*model.AppKeyword, error) {
|
|
if result, err := a.DO.Last(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.AppKeyword), nil
|
|
}
|
|
}
|
|
|
|
func (a appKeywordDo) Find() ([]*model.AppKeyword, error) {
|
|
result, err := a.DO.Find()
|
|
return result.([]*model.AppKeyword), err
|
|
}
|
|
|
|
func (a appKeywordDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AppKeyword, err error) {
|
|
buf := make([]*model.AppKeyword, 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 appKeywordDo) FindInBatches(result *[]*model.AppKeyword, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
return a.DO.FindInBatches(result, batchSize, fc)
|
|
}
|
|
|
|
func (a appKeywordDo) Attrs(attrs ...field.AssignExpr) *appKeywordDo {
|
|
return a.withDO(a.DO.Attrs(attrs...))
|
|
}
|
|
|
|
func (a appKeywordDo) Assign(attrs ...field.AssignExpr) *appKeywordDo {
|
|
return a.withDO(a.DO.Assign(attrs...))
|
|
}
|
|
|
|
func (a appKeywordDo) Joins(fields ...field.RelationField) *appKeywordDo {
|
|
for _, _f := range fields {
|
|
a = *a.withDO(a.DO.Joins(_f))
|
|
}
|
|
return &a
|
|
}
|
|
|
|
func (a appKeywordDo) Preload(fields ...field.RelationField) *appKeywordDo {
|
|
for _, _f := range fields {
|
|
a = *a.withDO(a.DO.Preload(_f))
|
|
}
|
|
return &a
|
|
}
|
|
|
|
func (a appKeywordDo) FirstOrInit() (*model.AppKeyword, error) {
|
|
if result, err := a.DO.FirstOrInit(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.AppKeyword), nil
|
|
}
|
|
}
|
|
|
|
func (a appKeywordDo) FirstOrCreate() (*model.AppKeyword, error) {
|
|
if result, err := a.DO.FirstOrCreate(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.AppKeyword), nil
|
|
}
|
|
}
|
|
|
|
func (a appKeywordDo) FindByPage(offset int, limit int) (result []*model.AppKeyword, 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 appKeywordDo) 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 appKeywordDo) Scan(result interface{}) (err error) {
|
|
return a.DO.Scan(result)
|
|
}
|
|
|
|
func (a appKeywordDo) Delete(models ...*model.AppKeyword) (result gen.ResultInfo, err error) {
|
|
return a.DO.Delete(models)
|
|
}
|
|
|
|
func (a *appKeywordDo) withDO(do gen.Dao) *appKeywordDo {
|
|
a.DO = *do.(*gen.DO)
|
|
return a
|
|
}
|