任务三
This commit is contained in:
@@ -0,0 +1,415 @@
|
||||
// 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"
|
||||
"database/sql"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"kra/internal/data/model"
|
||||
)
|
||||
|
||||
func newExaAttachmentCategory(db *gorm.DB, opts ...gen.DOOption) exaAttachmentCategory {
|
||||
_exaAttachmentCategory := exaAttachmentCategory{}
|
||||
|
||||
_exaAttachmentCategory.exaAttachmentCategoryDo.UseDB(db, opts...)
|
||||
_exaAttachmentCategory.exaAttachmentCategoryDo.UseModel(&model.ExaAttachmentCategory{})
|
||||
|
||||
tableName := _exaAttachmentCategory.exaAttachmentCategoryDo.TableName()
|
||||
_exaAttachmentCategory.ALL = field.NewAsterisk(tableName)
|
||||
_exaAttachmentCategory.ID = field.NewInt64(tableName, "id")
|
||||
_exaAttachmentCategory.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_exaAttachmentCategory.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_exaAttachmentCategory.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
_exaAttachmentCategory.Name = field.NewString(tableName, "name")
|
||||
_exaAttachmentCategory.Pid = field.NewInt64(tableName, "pid")
|
||||
|
||||
_exaAttachmentCategory.fillFieldMap()
|
||||
|
||||
return _exaAttachmentCategory
|
||||
}
|
||||
|
||||
type exaAttachmentCategory struct {
|
||||
exaAttachmentCategoryDo exaAttachmentCategoryDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int64
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
Name field.String // 分类名称
|
||||
Pid field.Int64 // 父节点ID
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategory) Table(newTableName string) *exaAttachmentCategory {
|
||||
e.exaAttachmentCategoryDo.UseTable(newTableName)
|
||||
return e.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategory) As(alias string) *exaAttachmentCategory {
|
||||
e.exaAttachmentCategoryDo.DO = *(e.exaAttachmentCategoryDo.As(alias).(*gen.DO))
|
||||
return e.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (e *exaAttachmentCategory) updateTableName(table string) *exaAttachmentCategory {
|
||||
e.ALL = field.NewAsterisk(table)
|
||||
e.ID = field.NewInt64(table, "id")
|
||||
e.CreatedAt = field.NewTime(table, "created_at")
|
||||
e.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
e.DeletedAt = field.NewField(table, "deleted_at")
|
||||
e.Name = field.NewString(table, "name")
|
||||
e.Pid = field.NewInt64(table, "pid")
|
||||
|
||||
e.fillFieldMap()
|
||||
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *exaAttachmentCategory) WithContext(ctx context.Context) IExaAttachmentCategoryDo {
|
||||
return e.exaAttachmentCategoryDo.WithContext(ctx)
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategory) TableName() string { return e.exaAttachmentCategoryDo.TableName() }
|
||||
|
||||
func (e exaAttachmentCategory) Alias() string { return e.exaAttachmentCategoryDo.Alias() }
|
||||
|
||||
func (e exaAttachmentCategory) Columns(cols ...field.Expr) gen.Columns {
|
||||
return e.exaAttachmentCategoryDo.Columns(cols...)
|
||||
}
|
||||
|
||||
func (e *exaAttachmentCategory) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := e.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (e *exaAttachmentCategory) fillFieldMap() {
|
||||
e.fieldMap = make(map[string]field.Expr, 6)
|
||||
e.fieldMap["id"] = e.ID
|
||||
e.fieldMap["created_at"] = e.CreatedAt
|
||||
e.fieldMap["updated_at"] = e.UpdatedAt
|
||||
e.fieldMap["deleted_at"] = e.DeletedAt
|
||||
e.fieldMap["name"] = e.Name
|
||||
e.fieldMap["pid"] = e.Pid
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategory) clone(db *gorm.DB) exaAttachmentCategory {
|
||||
e.exaAttachmentCategoryDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return e
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategory) replaceDB(db *gorm.DB) exaAttachmentCategory {
|
||||
e.exaAttachmentCategoryDo.ReplaceDB(db)
|
||||
return e
|
||||
}
|
||||
|
||||
type exaAttachmentCategoryDo struct{ gen.DO }
|
||||
|
||||
type IExaAttachmentCategoryDo interface {
|
||||
gen.SubQuery
|
||||
Debug() IExaAttachmentCategoryDo
|
||||
WithContext(ctx context.Context) IExaAttachmentCategoryDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() IExaAttachmentCategoryDo
|
||||
WriteDB() IExaAttachmentCategoryDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) IExaAttachmentCategoryDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) IExaAttachmentCategoryDo
|
||||
Not(conds ...gen.Condition) IExaAttachmentCategoryDo
|
||||
Or(conds ...gen.Condition) IExaAttachmentCategoryDo
|
||||
Select(conds ...field.Expr) IExaAttachmentCategoryDo
|
||||
Where(conds ...gen.Condition) IExaAttachmentCategoryDo
|
||||
Order(conds ...field.Expr) IExaAttachmentCategoryDo
|
||||
Distinct(cols ...field.Expr) IExaAttachmentCategoryDo
|
||||
Omit(cols ...field.Expr) IExaAttachmentCategoryDo
|
||||
Join(table schema.Tabler, on ...field.Expr) IExaAttachmentCategoryDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) IExaAttachmentCategoryDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) IExaAttachmentCategoryDo
|
||||
Group(cols ...field.Expr) IExaAttachmentCategoryDo
|
||||
Having(conds ...gen.Condition) IExaAttachmentCategoryDo
|
||||
Limit(limit int) IExaAttachmentCategoryDo
|
||||
Offset(offset int) IExaAttachmentCategoryDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) IExaAttachmentCategoryDo
|
||||
Unscoped() IExaAttachmentCategoryDo
|
||||
Create(values ...*model.ExaAttachmentCategory) error
|
||||
CreateInBatches(values []*model.ExaAttachmentCategory, batchSize int) error
|
||||
Save(values ...*model.ExaAttachmentCategory) error
|
||||
First() (*model.ExaAttachmentCategory, error)
|
||||
Take() (*model.ExaAttachmentCategory, error)
|
||||
Last() (*model.ExaAttachmentCategory, error)
|
||||
Find() ([]*model.ExaAttachmentCategory, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ExaAttachmentCategory, err error)
|
||||
FindInBatches(result *[]*model.ExaAttachmentCategory, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*model.ExaAttachmentCategory) (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) IExaAttachmentCategoryDo
|
||||
Assign(attrs ...field.AssignExpr) IExaAttachmentCategoryDo
|
||||
Joins(fields ...field.RelationField) IExaAttachmentCategoryDo
|
||||
Preload(fields ...field.RelationField) IExaAttachmentCategoryDo
|
||||
FirstOrInit() (*model.ExaAttachmentCategory, error)
|
||||
FirstOrCreate() (*model.ExaAttachmentCategory, error)
|
||||
FindByPage(offset int, limit int) (result []*model.ExaAttachmentCategory, count int64, err error)
|
||||
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
|
||||
Rows() (*sql.Rows, error)
|
||||
Row() *sql.Row
|
||||
Scan(result interface{}) (err error)
|
||||
Returning(value interface{}, columns ...string) IExaAttachmentCategoryDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) Debug() IExaAttachmentCategoryDo {
|
||||
return e.withDO(e.DO.Debug())
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) WithContext(ctx context.Context) IExaAttachmentCategoryDo {
|
||||
return e.withDO(e.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) ReadDB() IExaAttachmentCategoryDo {
|
||||
return e.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) WriteDB() IExaAttachmentCategoryDo {
|
||||
return e.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) Session(config *gorm.Session) IExaAttachmentCategoryDo {
|
||||
return e.withDO(e.DO.Session(config))
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) Clauses(conds ...clause.Expression) IExaAttachmentCategoryDo {
|
||||
return e.withDO(e.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) Returning(value interface{}, columns ...string) IExaAttachmentCategoryDo {
|
||||
return e.withDO(e.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) Not(conds ...gen.Condition) IExaAttachmentCategoryDo {
|
||||
return e.withDO(e.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) Or(conds ...gen.Condition) IExaAttachmentCategoryDo {
|
||||
return e.withDO(e.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) Select(conds ...field.Expr) IExaAttachmentCategoryDo {
|
||||
return e.withDO(e.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) Where(conds ...gen.Condition) IExaAttachmentCategoryDo {
|
||||
return e.withDO(e.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) Order(conds ...field.Expr) IExaAttachmentCategoryDo {
|
||||
return e.withDO(e.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) Distinct(cols ...field.Expr) IExaAttachmentCategoryDo {
|
||||
return e.withDO(e.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) Omit(cols ...field.Expr) IExaAttachmentCategoryDo {
|
||||
return e.withDO(e.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) Join(table schema.Tabler, on ...field.Expr) IExaAttachmentCategoryDo {
|
||||
return e.withDO(e.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) LeftJoin(table schema.Tabler, on ...field.Expr) IExaAttachmentCategoryDo {
|
||||
return e.withDO(e.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) RightJoin(table schema.Tabler, on ...field.Expr) IExaAttachmentCategoryDo {
|
||||
return e.withDO(e.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) Group(cols ...field.Expr) IExaAttachmentCategoryDo {
|
||||
return e.withDO(e.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) Having(conds ...gen.Condition) IExaAttachmentCategoryDo {
|
||||
return e.withDO(e.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) Limit(limit int) IExaAttachmentCategoryDo {
|
||||
return e.withDO(e.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) Offset(offset int) IExaAttachmentCategoryDo {
|
||||
return e.withDO(e.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IExaAttachmentCategoryDo {
|
||||
return e.withDO(e.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) Unscoped() IExaAttachmentCategoryDo {
|
||||
return e.withDO(e.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) Create(values ...*model.ExaAttachmentCategory) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return e.DO.Create(values)
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) CreateInBatches(values []*model.ExaAttachmentCategory, batchSize int) error {
|
||||
return e.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 (e exaAttachmentCategoryDo) Save(values ...*model.ExaAttachmentCategory) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return e.DO.Save(values)
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) First() (*model.ExaAttachmentCategory, error) {
|
||||
if result, err := e.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.ExaAttachmentCategory), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) Take() (*model.ExaAttachmentCategory, error) {
|
||||
if result, err := e.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.ExaAttachmentCategory), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) Last() (*model.ExaAttachmentCategory, error) {
|
||||
if result, err := e.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.ExaAttachmentCategory), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) Find() ([]*model.ExaAttachmentCategory, error) {
|
||||
result, err := e.DO.Find()
|
||||
return result.([]*model.ExaAttachmentCategory), err
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ExaAttachmentCategory, err error) {
|
||||
buf := make([]*model.ExaAttachmentCategory, 0, batchSize)
|
||||
err = e.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 (e exaAttachmentCategoryDo) FindInBatches(result *[]*model.ExaAttachmentCategory, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return e.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) Attrs(attrs ...field.AssignExpr) IExaAttachmentCategoryDo {
|
||||
return e.withDO(e.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) Assign(attrs ...field.AssignExpr) IExaAttachmentCategoryDo {
|
||||
return e.withDO(e.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) Joins(fields ...field.RelationField) IExaAttachmentCategoryDo {
|
||||
for _, _f := range fields {
|
||||
e = *e.withDO(e.DO.Joins(_f))
|
||||
}
|
||||
return &e
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) Preload(fields ...field.RelationField) IExaAttachmentCategoryDo {
|
||||
for _, _f := range fields {
|
||||
e = *e.withDO(e.DO.Preload(_f))
|
||||
}
|
||||
return &e
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) FirstOrInit() (*model.ExaAttachmentCategory, error) {
|
||||
if result, err := e.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.ExaAttachmentCategory), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) FirstOrCreate() (*model.ExaAttachmentCategory, error) {
|
||||
if result, err := e.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.ExaAttachmentCategory), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) FindByPage(offset int, limit int) (result []*model.ExaAttachmentCategory, count int64, err error) {
|
||||
result, err = e.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 = e.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = e.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = e.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) Scan(result interface{}) (err error) {
|
||||
return e.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (e exaAttachmentCategoryDo) Delete(models ...*model.ExaAttachmentCategory) (result gen.ResultInfo, err error) {
|
||||
return e.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (e *exaAttachmentCategoryDo) withDO(do gen.Dao) *exaAttachmentCategoryDo {
|
||||
e.DO = *do.(*gen.DO)
|
||||
return e
|
||||
}
|
||||
Reference in New Issue
Block a user