任务三
This commit is contained in:
@@ -0,0 +1,425 @@
|
||||
// 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 newSysExportTemplateCondition(db *gorm.DB, opts ...gen.DOOption) sysExportTemplateCondition {
|
||||
_sysExportTemplateCondition := sysExportTemplateCondition{}
|
||||
|
||||
_sysExportTemplateCondition.sysExportTemplateConditionDo.UseDB(db, opts...)
|
||||
_sysExportTemplateCondition.sysExportTemplateConditionDo.UseModel(&model.SysExportTemplateCondition{})
|
||||
|
||||
tableName := _sysExportTemplateCondition.sysExportTemplateConditionDo.TableName()
|
||||
_sysExportTemplateCondition.ALL = field.NewAsterisk(tableName)
|
||||
_sysExportTemplateCondition.ID = field.NewInt64(tableName, "id")
|
||||
_sysExportTemplateCondition.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_sysExportTemplateCondition.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_sysExportTemplateCondition.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
_sysExportTemplateCondition.TemplateID = field.NewString(tableName, "template_id")
|
||||
_sysExportTemplateCondition.From = field.NewString(tableName, "from")
|
||||
_sysExportTemplateCondition.Column = field.NewString(tableName, "column")
|
||||
_sysExportTemplateCondition.Operator = field.NewString(tableName, "operator")
|
||||
|
||||
_sysExportTemplateCondition.fillFieldMap()
|
||||
|
||||
return _sysExportTemplateCondition
|
||||
}
|
||||
|
||||
type sysExportTemplateCondition struct {
|
||||
sysExportTemplateConditionDo sysExportTemplateConditionDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int64
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
TemplateID field.String // 模板标识
|
||||
From field.String // 条件取的key
|
||||
Column field.String // 作为查询条件的字段
|
||||
Operator field.String // 操作符
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (s sysExportTemplateCondition) Table(newTableName string) *sysExportTemplateCondition {
|
||||
s.sysExportTemplateConditionDo.UseTable(newTableName)
|
||||
return s.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (s sysExportTemplateCondition) As(alias string) *sysExportTemplateCondition {
|
||||
s.sysExportTemplateConditionDo.DO = *(s.sysExportTemplateConditionDo.As(alias).(*gen.DO))
|
||||
return s.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (s *sysExportTemplateCondition) updateTableName(table string) *sysExportTemplateCondition {
|
||||
s.ALL = field.NewAsterisk(table)
|
||||
s.ID = field.NewInt64(table, "id")
|
||||
s.CreatedAt = field.NewTime(table, "created_at")
|
||||
s.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
s.DeletedAt = field.NewField(table, "deleted_at")
|
||||
s.TemplateID = field.NewString(table, "template_id")
|
||||
s.From = field.NewString(table, "from")
|
||||
s.Column = field.NewString(table, "column")
|
||||
s.Operator = field.NewString(table, "operator")
|
||||
|
||||
s.fillFieldMap()
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *sysExportTemplateCondition) WithContext(ctx context.Context) ISysExportTemplateConditionDo {
|
||||
return s.sysExportTemplateConditionDo.WithContext(ctx)
|
||||
}
|
||||
|
||||
func (s sysExportTemplateCondition) TableName() string {
|
||||
return s.sysExportTemplateConditionDo.TableName()
|
||||
}
|
||||
|
||||
func (s sysExportTemplateCondition) Alias() string { return s.sysExportTemplateConditionDo.Alias() }
|
||||
|
||||
func (s sysExportTemplateCondition) Columns(cols ...field.Expr) gen.Columns {
|
||||
return s.sysExportTemplateConditionDo.Columns(cols...)
|
||||
}
|
||||
|
||||
func (s *sysExportTemplateCondition) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := s.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (s *sysExportTemplateCondition) fillFieldMap() {
|
||||
s.fieldMap = make(map[string]field.Expr, 8)
|
||||
s.fieldMap["id"] = s.ID
|
||||
s.fieldMap["created_at"] = s.CreatedAt
|
||||
s.fieldMap["updated_at"] = s.UpdatedAt
|
||||
s.fieldMap["deleted_at"] = s.DeletedAt
|
||||
s.fieldMap["template_id"] = s.TemplateID
|
||||
s.fieldMap["from"] = s.From
|
||||
s.fieldMap["column"] = s.Column
|
||||
s.fieldMap["operator"] = s.Operator
|
||||
}
|
||||
|
||||
func (s sysExportTemplateCondition) clone(db *gorm.DB) sysExportTemplateCondition {
|
||||
s.sysExportTemplateConditionDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return s
|
||||
}
|
||||
|
||||
func (s sysExportTemplateCondition) replaceDB(db *gorm.DB) sysExportTemplateCondition {
|
||||
s.sysExportTemplateConditionDo.ReplaceDB(db)
|
||||
return s
|
||||
}
|
||||
|
||||
type sysExportTemplateConditionDo struct{ gen.DO }
|
||||
|
||||
type ISysExportTemplateConditionDo interface {
|
||||
gen.SubQuery
|
||||
Debug() ISysExportTemplateConditionDo
|
||||
WithContext(ctx context.Context) ISysExportTemplateConditionDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() ISysExportTemplateConditionDo
|
||||
WriteDB() ISysExportTemplateConditionDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) ISysExportTemplateConditionDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) ISysExportTemplateConditionDo
|
||||
Not(conds ...gen.Condition) ISysExportTemplateConditionDo
|
||||
Or(conds ...gen.Condition) ISysExportTemplateConditionDo
|
||||
Select(conds ...field.Expr) ISysExportTemplateConditionDo
|
||||
Where(conds ...gen.Condition) ISysExportTemplateConditionDo
|
||||
Order(conds ...field.Expr) ISysExportTemplateConditionDo
|
||||
Distinct(cols ...field.Expr) ISysExportTemplateConditionDo
|
||||
Omit(cols ...field.Expr) ISysExportTemplateConditionDo
|
||||
Join(table schema.Tabler, on ...field.Expr) ISysExportTemplateConditionDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) ISysExportTemplateConditionDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) ISysExportTemplateConditionDo
|
||||
Group(cols ...field.Expr) ISysExportTemplateConditionDo
|
||||
Having(conds ...gen.Condition) ISysExportTemplateConditionDo
|
||||
Limit(limit int) ISysExportTemplateConditionDo
|
||||
Offset(offset int) ISysExportTemplateConditionDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) ISysExportTemplateConditionDo
|
||||
Unscoped() ISysExportTemplateConditionDo
|
||||
Create(values ...*model.SysExportTemplateCondition) error
|
||||
CreateInBatches(values []*model.SysExportTemplateCondition, batchSize int) error
|
||||
Save(values ...*model.SysExportTemplateCondition) error
|
||||
First() (*model.SysExportTemplateCondition, error)
|
||||
Take() (*model.SysExportTemplateCondition, error)
|
||||
Last() (*model.SysExportTemplateCondition, error)
|
||||
Find() ([]*model.SysExportTemplateCondition, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.SysExportTemplateCondition, err error)
|
||||
FindInBatches(result *[]*model.SysExportTemplateCondition, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*model.SysExportTemplateCondition) (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) ISysExportTemplateConditionDo
|
||||
Assign(attrs ...field.AssignExpr) ISysExportTemplateConditionDo
|
||||
Joins(fields ...field.RelationField) ISysExportTemplateConditionDo
|
||||
Preload(fields ...field.RelationField) ISysExportTemplateConditionDo
|
||||
FirstOrInit() (*model.SysExportTemplateCondition, error)
|
||||
FirstOrCreate() (*model.SysExportTemplateCondition, error)
|
||||
FindByPage(offset int, limit int) (result []*model.SysExportTemplateCondition, 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) ISysExportTemplateConditionDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) Debug() ISysExportTemplateConditionDo {
|
||||
return s.withDO(s.DO.Debug())
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) WithContext(ctx context.Context) ISysExportTemplateConditionDo {
|
||||
return s.withDO(s.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) ReadDB() ISysExportTemplateConditionDo {
|
||||
return s.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) WriteDB() ISysExportTemplateConditionDo {
|
||||
return s.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) Session(config *gorm.Session) ISysExportTemplateConditionDo {
|
||||
return s.withDO(s.DO.Session(config))
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) Clauses(conds ...clause.Expression) ISysExportTemplateConditionDo {
|
||||
return s.withDO(s.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) Returning(value interface{}, columns ...string) ISysExportTemplateConditionDo {
|
||||
return s.withDO(s.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) Not(conds ...gen.Condition) ISysExportTemplateConditionDo {
|
||||
return s.withDO(s.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) Or(conds ...gen.Condition) ISysExportTemplateConditionDo {
|
||||
return s.withDO(s.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) Select(conds ...field.Expr) ISysExportTemplateConditionDo {
|
||||
return s.withDO(s.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) Where(conds ...gen.Condition) ISysExportTemplateConditionDo {
|
||||
return s.withDO(s.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) Order(conds ...field.Expr) ISysExportTemplateConditionDo {
|
||||
return s.withDO(s.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) Distinct(cols ...field.Expr) ISysExportTemplateConditionDo {
|
||||
return s.withDO(s.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) Omit(cols ...field.Expr) ISysExportTemplateConditionDo {
|
||||
return s.withDO(s.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) Join(table schema.Tabler, on ...field.Expr) ISysExportTemplateConditionDo {
|
||||
return s.withDO(s.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) LeftJoin(table schema.Tabler, on ...field.Expr) ISysExportTemplateConditionDo {
|
||||
return s.withDO(s.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) RightJoin(table schema.Tabler, on ...field.Expr) ISysExportTemplateConditionDo {
|
||||
return s.withDO(s.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) Group(cols ...field.Expr) ISysExportTemplateConditionDo {
|
||||
return s.withDO(s.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) Having(conds ...gen.Condition) ISysExportTemplateConditionDo {
|
||||
return s.withDO(s.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) Limit(limit int) ISysExportTemplateConditionDo {
|
||||
return s.withDO(s.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) Offset(offset int) ISysExportTemplateConditionDo {
|
||||
return s.withDO(s.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) Scopes(funcs ...func(gen.Dao) gen.Dao) ISysExportTemplateConditionDo {
|
||||
return s.withDO(s.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) Unscoped() ISysExportTemplateConditionDo {
|
||||
return s.withDO(s.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) Create(values ...*model.SysExportTemplateCondition) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return s.DO.Create(values)
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) CreateInBatches(values []*model.SysExportTemplateCondition, batchSize int) error {
|
||||
return s.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 (s sysExportTemplateConditionDo) Save(values ...*model.SysExportTemplateCondition) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return s.DO.Save(values)
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) First() (*model.SysExportTemplateCondition, error) {
|
||||
if result, err := s.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.SysExportTemplateCondition), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) Take() (*model.SysExportTemplateCondition, error) {
|
||||
if result, err := s.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.SysExportTemplateCondition), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) Last() (*model.SysExportTemplateCondition, error) {
|
||||
if result, err := s.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.SysExportTemplateCondition), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) Find() ([]*model.SysExportTemplateCondition, error) {
|
||||
result, err := s.DO.Find()
|
||||
return result.([]*model.SysExportTemplateCondition), err
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.SysExportTemplateCondition, err error) {
|
||||
buf := make([]*model.SysExportTemplateCondition, 0, batchSize)
|
||||
err = s.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 (s sysExportTemplateConditionDo) FindInBatches(result *[]*model.SysExportTemplateCondition, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return s.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) Attrs(attrs ...field.AssignExpr) ISysExportTemplateConditionDo {
|
||||
return s.withDO(s.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) Assign(attrs ...field.AssignExpr) ISysExportTemplateConditionDo {
|
||||
return s.withDO(s.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) Joins(fields ...field.RelationField) ISysExportTemplateConditionDo {
|
||||
for _, _f := range fields {
|
||||
s = *s.withDO(s.DO.Joins(_f))
|
||||
}
|
||||
return &s
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) Preload(fields ...field.RelationField) ISysExportTemplateConditionDo {
|
||||
for _, _f := range fields {
|
||||
s = *s.withDO(s.DO.Preload(_f))
|
||||
}
|
||||
return &s
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) FirstOrInit() (*model.SysExportTemplateCondition, error) {
|
||||
if result, err := s.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.SysExportTemplateCondition), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) FirstOrCreate() (*model.SysExportTemplateCondition, error) {
|
||||
if result, err := s.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.SysExportTemplateCondition), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) FindByPage(offset int, limit int) (result []*model.SysExportTemplateCondition, count int64, err error) {
|
||||
result, err = s.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 = s.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = s.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = s.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) Scan(result interface{}) (err error) {
|
||||
return s.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (s sysExportTemplateConditionDo) Delete(models ...*model.SysExportTemplateCondition) (result gen.ResultInfo, err error) {
|
||||
return s.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (s *sysExportTemplateConditionDo) withDO(do gen.Dao) *sysExportTemplateConditionDo {
|
||||
s.DO = *do.(*gen.DO)
|
||||
return s
|
||||
}
|
||||
Reference in New Issue
Block a user