|
@@ -0,0 +1,370 @@
|
|
|
+// 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"
|
|
|
+
|
|
|
+ "github.com/0xJacky/Nginx-UI/model"
|
|
|
+)
|
|
|
+
|
|
|
+func newSiteCategory(db *gorm.DB, opts ...gen.DOOption) siteCategory {
|
|
|
+ _siteCategory := siteCategory{}
|
|
|
+
|
|
|
+ _siteCategory.siteCategoryDo.UseDB(db, opts...)
|
|
|
+ _siteCategory.siteCategoryDo.UseModel(&model.SiteCategory{})
|
|
|
+
|
|
|
+ tableName := _siteCategory.siteCategoryDo.TableName()
|
|
|
+ _siteCategory.ALL = field.NewAsterisk(tableName)
|
|
|
+ _siteCategory.ID = field.NewUint64(tableName, "id")
|
|
|
+ _siteCategory.CreatedAt = field.NewTime(tableName, "created_at")
|
|
|
+ _siteCategory.UpdatedAt = field.NewTime(tableName, "updated_at")
|
|
|
+ _siteCategory.DeletedAt = field.NewField(tableName, "deleted_at")
|
|
|
+ _siteCategory.Name = field.NewString(tableName, "name")
|
|
|
+ _siteCategory.SyncNodeIds = field.NewField(tableName, "sync_node_ids")
|
|
|
+
|
|
|
+ _siteCategory.fillFieldMap()
|
|
|
+
|
|
|
+ return _siteCategory
|
|
|
+}
|
|
|
+
|
|
|
+type siteCategory struct {
|
|
|
+ siteCategoryDo
|
|
|
+
|
|
|
+ ALL field.Asterisk
|
|
|
+ ID field.Uint64
|
|
|
+ CreatedAt field.Time
|
|
|
+ UpdatedAt field.Time
|
|
|
+ DeletedAt field.Field
|
|
|
+ Name field.String
|
|
|
+ SyncNodeIds field.Field
|
|
|
+
|
|
|
+ fieldMap map[string]field.Expr
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategory) Table(newTableName string) *siteCategory {
|
|
|
+ s.siteCategoryDo.UseTable(newTableName)
|
|
|
+ return s.updateTableName(newTableName)
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategory) As(alias string) *siteCategory {
|
|
|
+ s.siteCategoryDo.DO = *(s.siteCategoryDo.As(alias).(*gen.DO))
|
|
|
+ return s.updateTableName(alias)
|
|
|
+}
|
|
|
+
|
|
|
+func (s *siteCategory) updateTableName(table string) *siteCategory {
|
|
|
+ s.ALL = field.NewAsterisk(table)
|
|
|
+ s.ID = field.NewUint64(table, "id")
|
|
|
+ s.CreatedAt = field.NewTime(table, "created_at")
|
|
|
+ s.UpdatedAt = field.NewTime(table, "updated_at")
|
|
|
+ s.DeletedAt = field.NewField(table, "deleted_at")
|
|
|
+ s.Name = field.NewString(table, "name")
|
|
|
+ s.SyncNodeIds = field.NewField(table, "sync_node_ids")
|
|
|
+
|
|
|
+ s.fillFieldMap()
|
|
|
+
|
|
|
+ return s
|
|
|
+}
|
|
|
+
|
|
|
+func (s *siteCategory) 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 *siteCategory) fillFieldMap() {
|
|
|
+ s.fieldMap = make(map[string]field.Expr, 6)
|
|
|
+ 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["name"] = s.Name
|
|
|
+ s.fieldMap["sync_node_ids"] = s.SyncNodeIds
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategory) clone(db *gorm.DB) siteCategory {
|
|
|
+ s.siteCategoryDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
|
+ return s
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategory) replaceDB(db *gorm.DB) siteCategory {
|
|
|
+ s.siteCategoryDo.ReplaceDB(db)
|
|
|
+ return s
|
|
|
+}
|
|
|
+
|
|
|
+type siteCategoryDo struct{ gen.DO }
|
|
|
+
|
|
|
+// FirstByID Where("id=@id")
|
|
|
+func (s siteCategoryDo) FirstByID(id uint64) (result *model.SiteCategory, err error) {
|
|
|
+ var params []interface{}
|
|
|
+
|
|
|
+ var generateSQL strings.Builder
|
|
|
+ params = append(params, id)
|
|
|
+ generateSQL.WriteString("id=? ")
|
|
|
+
|
|
|
+ var executeSQL *gorm.DB
|
|
|
+ executeSQL = s.UnderlyingDB().Where(generateSQL.String(), params...).Take(&result) // ignore_security_alert
|
|
|
+ err = executeSQL.Error
|
|
|
+
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// DeleteByID update @@table set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=@id
|
|
|
+func (s siteCategoryDo) DeleteByID(id uint64) (err error) {
|
|
|
+ var params []interface{}
|
|
|
+
|
|
|
+ var generateSQL strings.Builder
|
|
|
+ params = append(params, id)
|
|
|
+ generateSQL.WriteString("update site_categories set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=? ")
|
|
|
+
|
|
|
+ var executeSQL *gorm.DB
|
|
|
+ executeSQL = s.UnderlyingDB().Exec(generateSQL.String(), params...) // ignore_security_alert
|
|
|
+ err = executeSQL.Error
|
|
|
+
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) Debug() *siteCategoryDo {
|
|
|
+ return s.withDO(s.DO.Debug())
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) WithContext(ctx context.Context) *siteCategoryDo {
|
|
|
+ return s.withDO(s.DO.WithContext(ctx))
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) ReadDB() *siteCategoryDo {
|
|
|
+ return s.Clauses(dbresolver.Read)
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) WriteDB() *siteCategoryDo {
|
|
|
+ return s.Clauses(dbresolver.Write)
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) Session(config *gorm.Session) *siteCategoryDo {
|
|
|
+ return s.withDO(s.DO.Session(config))
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) Clauses(conds ...clause.Expression) *siteCategoryDo {
|
|
|
+ return s.withDO(s.DO.Clauses(conds...))
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) Returning(value interface{}, columns ...string) *siteCategoryDo {
|
|
|
+ return s.withDO(s.DO.Returning(value, columns...))
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) Not(conds ...gen.Condition) *siteCategoryDo {
|
|
|
+ return s.withDO(s.DO.Not(conds...))
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) Or(conds ...gen.Condition) *siteCategoryDo {
|
|
|
+ return s.withDO(s.DO.Or(conds...))
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) Select(conds ...field.Expr) *siteCategoryDo {
|
|
|
+ return s.withDO(s.DO.Select(conds...))
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) Where(conds ...gen.Condition) *siteCategoryDo {
|
|
|
+ return s.withDO(s.DO.Where(conds...))
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) Order(conds ...field.Expr) *siteCategoryDo {
|
|
|
+ return s.withDO(s.DO.Order(conds...))
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) Distinct(cols ...field.Expr) *siteCategoryDo {
|
|
|
+ return s.withDO(s.DO.Distinct(cols...))
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) Omit(cols ...field.Expr) *siteCategoryDo {
|
|
|
+ return s.withDO(s.DO.Omit(cols...))
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) Join(table schema.Tabler, on ...field.Expr) *siteCategoryDo {
|
|
|
+ return s.withDO(s.DO.Join(table, on...))
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) LeftJoin(table schema.Tabler, on ...field.Expr) *siteCategoryDo {
|
|
|
+ return s.withDO(s.DO.LeftJoin(table, on...))
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) RightJoin(table schema.Tabler, on ...field.Expr) *siteCategoryDo {
|
|
|
+ return s.withDO(s.DO.RightJoin(table, on...))
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) Group(cols ...field.Expr) *siteCategoryDo {
|
|
|
+ return s.withDO(s.DO.Group(cols...))
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) Having(conds ...gen.Condition) *siteCategoryDo {
|
|
|
+ return s.withDO(s.DO.Having(conds...))
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) Limit(limit int) *siteCategoryDo {
|
|
|
+ return s.withDO(s.DO.Limit(limit))
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) Offset(offset int) *siteCategoryDo {
|
|
|
+ return s.withDO(s.DO.Offset(offset))
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *siteCategoryDo {
|
|
|
+ return s.withDO(s.DO.Scopes(funcs...))
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) Unscoped() *siteCategoryDo {
|
|
|
+ return s.withDO(s.DO.Unscoped())
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) Create(values ...*model.SiteCategory) error {
|
|
|
+ if len(values) == 0 {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return s.DO.Create(values)
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) CreateInBatches(values []*model.SiteCategory, 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 siteCategoryDo) Save(values ...*model.SiteCategory) error {
|
|
|
+ if len(values) == 0 {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return s.DO.Save(values)
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) First() (*model.SiteCategory, error) {
|
|
|
+ if result, err := s.DO.First(); err != nil {
|
|
|
+ return nil, err
|
|
|
+ } else {
|
|
|
+ return result.(*model.SiteCategory), nil
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) Take() (*model.SiteCategory, error) {
|
|
|
+ if result, err := s.DO.Take(); err != nil {
|
|
|
+ return nil, err
|
|
|
+ } else {
|
|
|
+ return result.(*model.SiteCategory), nil
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) Last() (*model.SiteCategory, error) {
|
|
|
+ if result, err := s.DO.Last(); err != nil {
|
|
|
+ return nil, err
|
|
|
+ } else {
|
|
|
+ return result.(*model.SiteCategory), nil
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) Find() ([]*model.SiteCategory, error) {
|
|
|
+ result, err := s.DO.Find()
|
|
|
+ return result.([]*model.SiteCategory), err
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.SiteCategory, err error) {
|
|
|
+ buf := make([]*model.SiteCategory, 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 siteCategoryDo) FindInBatches(result *[]*model.SiteCategory, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
|
+ return s.DO.FindInBatches(result, batchSize, fc)
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) Attrs(attrs ...field.AssignExpr) *siteCategoryDo {
|
|
|
+ return s.withDO(s.DO.Attrs(attrs...))
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) Assign(attrs ...field.AssignExpr) *siteCategoryDo {
|
|
|
+ return s.withDO(s.DO.Assign(attrs...))
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) Joins(fields ...field.RelationField) *siteCategoryDo {
|
|
|
+ for _, _f := range fields {
|
|
|
+ s = *s.withDO(s.DO.Joins(_f))
|
|
|
+ }
|
|
|
+ return &s
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) Preload(fields ...field.RelationField) *siteCategoryDo {
|
|
|
+ for _, _f := range fields {
|
|
|
+ s = *s.withDO(s.DO.Preload(_f))
|
|
|
+ }
|
|
|
+ return &s
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) FirstOrInit() (*model.SiteCategory, error) {
|
|
|
+ if result, err := s.DO.FirstOrInit(); err != nil {
|
|
|
+ return nil, err
|
|
|
+ } else {
|
|
|
+ return result.(*model.SiteCategory), nil
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) FirstOrCreate() (*model.SiteCategory, error) {
|
|
|
+ if result, err := s.DO.FirstOrCreate(); err != nil {
|
|
|
+ return nil, err
|
|
|
+ } else {
|
|
|
+ return result.(*model.SiteCategory), nil
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) FindByPage(offset int, limit int) (result []*model.SiteCategory, 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 siteCategoryDo) 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 siteCategoryDo) Scan(result interface{}) (err error) {
|
|
|
+ return s.DO.Scan(result)
|
|
|
+}
|
|
|
+
|
|
|
+func (s siteCategoryDo) Delete(models ...*model.SiteCategory) (result gen.ResultInfo, err error) {
|
|
|
+ return s.DO.Delete(models)
|
|
|
+}
|
|
|
+
|
|
|
+func (s *siteCategoryDo) withDO(do gen.Dao) *siteCategoryDo {
|
|
|
+ s.DO = *do.(*gen.DO)
|
|
|
+ return s
|
|
|
+}
|