|
@@ -0,0 +1,408 @@
|
|
|
+// 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"
|
|
|
+
|
|
|
+ "gorm.io/gorm"
|
|
|
+ "gorm.io/gorm/clause"
|
|
|
+ "gorm.io/gorm/schema"
|
|
|
+
|
|
|
+ "gorm.io/gen"
|
|
|
+ "gorm.io/gen/field"
|
|
|
+
|
|
|
+ "gorm.io/plugin/dbresolver"
|
|
|
+
|
|
|
+ "pji_desktop_http/biz/model"
|
|
|
+)
|
|
|
+
|
|
|
+func newDevice(db *gorm.DB, opts ...gen.DOOption) device {
|
|
|
+ _device := device{}
|
|
|
+
|
|
|
+ _device.deviceDo.UseDB(db, opts...)
|
|
|
+ _device.deviceDo.UseModel(&model.Device{})
|
|
|
+
|
|
|
+ tableName := _device.deviceDo.TableName()
|
|
|
+ _device.ALL = field.NewAsterisk(tableName)
|
|
|
+ _device.DeviceNo = field.NewString(tableName, "device_no")
|
|
|
+ _device.DeviceName = field.NewString(tableName, "device_name")
|
|
|
+ _device.DeviceType = field.NewString(tableName, "device_type")
|
|
|
+ _device.CreatedAt = field.NewTime(tableName, "created_at")
|
|
|
+ _device.UpdatedAt = field.NewTime(tableName, "updated_at")
|
|
|
+ _device.DeletedAt = field.NewField(tableName, "deleted_at")
|
|
|
+
|
|
|
+ _device.fillFieldMap()
|
|
|
+
|
|
|
+ return _device
|
|
|
+}
|
|
|
+
|
|
|
+type device struct {
|
|
|
+ deviceDo deviceDo
|
|
|
+
|
|
|
+ ALL field.Asterisk
|
|
|
+ DeviceNo field.String
|
|
|
+ DeviceName field.String
|
|
|
+ DeviceType field.String
|
|
|
+ CreatedAt field.Time
|
|
|
+ UpdatedAt field.Time
|
|
|
+ DeletedAt field.Field
|
|
|
+
|
|
|
+ fieldMap map[string]field.Expr
|
|
|
+}
|
|
|
+
|
|
|
+func (d device) Table(newTableName string) *device {
|
|
|
+ d.deviceDo.UseTable(newTableName)
|
|
|
+ return d.updateTableName(newTableName)
|
|
|
+}
|
|
|
+
|
|
|
+func (d device) As(alias string) *device {
|
|
|
+ d.deviceDo.DO = *(d.deviceDo.As(alias).(*gen.DO))
|
|
|
+ return d.updateTableName(alias)
|
|
|
+}
|
|
|
+
|
|
|
+func (d *device) updateTableName(table string) *device {
|
|
|
+ d.ALL = field.NewAsterisk(table)
|
|
|
+ d.DeviceNo = field.NewString(table, "device_no")
|
|
|
+ d.DeviceName = field.NewString(table, "device_name")
|
|
|
+ d.DeviceType = field.NewString(table, "device_type")
|
|
|
+ d.CreatedAt = field.NewTime(table, "created_at")
|
|
|
+ d.UpdatedAt = field.NewTime(table, "updated_at")
|
|
|
+ d.DeletedAt = field.NewField(table, "deleted_at")
|
|
|
+
|
|
|
+ d.fillFieldMap()
|
|
|
+
|
|
|
+ return d
|
|
|
+}
|
|
|
+
|
|
|
+func (d *device) WithContext(ctx context.Context) IDeviceDo { return d.deviceDo.WithContext(ctx) }
|
|
|
+
|
|
|
+func (d device) TableName() string { return d.deviceDo.TableName() }
|
|
|
+
|
|
|
+func (d device) Alias() string { return d.deviceDo.Alias() }
|
|
|
+
|
|
|
+func (d device) Columns(cols ...field.Expr) gen.Columns { return d.deviceDo.Columns(cols...) }
|
|
|
+
|
|
|
+func (d *device) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
|
|
+ _f, ok := d.fieldMap[fieldName]
|
|
|
+ if !ok || _f == nil {
|
|
|
+ return nil, false
|
|
|
+ }
|
|
|
+ _oe, ok := _f.(field.OrderExpr)
|
|
|
+ return _oe, ok
|
|
|
+}
|
|
|
+
|
|
|
+func (d *device) fillFieldMap() {
|
|
|
+ d.fieldMap = make(map[string]field.Expr, 6)
|
|
|
+ d.fieldMap["device_no"] = d.DeviceNo
|
|
|
+ d.fieldMap["device_name"] = d.DeviceName
|
|
|
+ d.fieldMap["device_type"] = d.DeviceType
|
|
|
+ d.fieldMap["created_at"] = d.CreatedAt
|
|
|
+ d.fieldMap["updated_at"] = d.UpdatedAt
|
|
|
+ d.fieldMap["deleted_at"] = d.DeletedAt
|
|
|
+}
|
|
|
+
|
|
|
+func (d device) clone(db *gorm.DB) device {
|
|
|
+ d.deviceDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
|
+ return d
|
|
|
+}
|
|
|
+
|
|
|
+func (d device) replaceDB(db *gorm.DB) device {
|
|
|
+ d.deviceDo.ReplaceDB(db)
|
|
|
+ return d
|
|
|
+}
|
|
|
+
|
|
|
+type deviceDo struct{ gen.DO }
|
|
|
+
|
|
|
+type IDeviceDo interface {
|
|
|
+ gen.SubQuery
|
|
|
+ Debug() IDeviceDo
|
|
|
+ WithContext(ctx context.Context) IDeviceDo
|
|
|
+ WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
|
|
+ ReplaceDB(db *gorm.DB)
|
|
|
+ ReadDB() IDeviceDo
|
|
|
+ WriteDB() IDeviceDo
|
|
|
+ As(alias string) gen.Dao
|
|
|
+ Session(config *gorm.Session) IDeviceDo
|
|
|
+ Columns(cols ...field.Expr) gen.Columns
|
|
|
+ Clauses(conds ...clause.Expression) IDeviceDo
|
|
|
+ Not(conds ...gen.Condition) IDeviceDo
|
|
|
+ Or(conds ...gen.Condition) IDeviceDo
|
|
|
+ Select(conds ...field.Expr) IDeviceDo
|
|
|
+ Where(conds ...gen.Condition) IDeviceDo
|
|
|
+ Order(conds ...field.Expr) IDeviceDo
|
|
|
+ Distinct(cols ...field.Expr) IDeviceDo
|
|
|
+ Omit(cols ...field.Expr) IDeviceDo
|
|
|
+ Join(table schema.Tabler, on ...field.Expr) IDeviceDo
|
|
|
+ LeftJoin(table schema.Tabler, on ...field.Expr) IDeviceDo
|
|
|
+ RightJoin(table schema.Tabler, on ...field.Expr) IDeviceDo
|
|
|
+ Group(cols ...field.Expr) IDeviceDo
|
|
|
+ Having(conds ...gen.Condition) IDeviceDo
|
|
|
+ Limit(limit int) IDeviceDo
|
|
|
+ Offset(offset int) IDeviceDo
|
|
|
+ Count() (count int64, err error)
|
|
|
+ Scopes(funcs ...func(gen.Dao) gen.Dao) IDeviceDo
|
|
|
+ Unscoped() IDeviceDo
|
|
|
+ Create(values ...*model.Device) error
|
|
|
+ CreateInBatches(values []*model.Device, batchSize int) error
|
|
|
+ Save(values ...*model.Device) error
|
|
|
+ First() (*model.Device, error)
|
|
|
+ Take() (*model.Device, error)
|
|
|
+ Last() (*model.Device, error)
|
|
|
+ Find() ([]*model.Device, error)
|
|
|
+ FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Device, err error)
|
|
|
+ FindInBatches(result *[]*model.Device, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
|
|
+ Pluck(column field.Expr, dest interface{}) error
|
|
|
+ Delete(...*model.Device) (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) IDeviceDo
|
|
|
+ Assign(attrs ...field.AssignExpr) IDeviceDo
|
|
|
+ Joins(fields ...field.RelationField) IDeviceDo
|
|
|
+ Preload(fields ...field.RelationField) IDeviceDo
|
|
|
+ FirstOrInit() (*model.Device, error)
|
|
|
+ FirstOrCreate() (*model.Device, error)
|
|
|
+ FindByPage(offset int, limit int) (result []*model.Device, 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) IDeviceDo
|
|
|
+ UnderlyingDB() *gorm.DB
|
|
|
+ schema.Tabler
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) Debug() IDeviceDo {
|
|
|
+ return d.withDO(d.DO.Debug())
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) WithContext(ctx context.Context) IDeviceDo {
|
|
|
+ return d.withDO(d.DO.WithContext(ctx))
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) ReadDB() IDeviceDo {
|
|
|
+ return d.Clauses(dbresolver.Read)
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) WriteDB() IDeviceDo {
|
|
|
+ return d.Clauses(dbresolver.Write)
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) Session(config *gorm.Session) IDeviceDo {
|
|
|
+ return d.withDO(d.DO.Session(config))
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) Clauses(conds ...clause.Expression) IDeviceDo {
|
|
|
+ return d.withDO(d.DO.Clauses(conds...))
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) Returning(value interface{}, columns ...string) IDeviceDo {
|
|
|
+ return d.withDO(d.DO.Returning(value, columns...))
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) Not(conds ...gen.Condition) IDeviceDo {
|
|
|
+ return d.withDO(d.DO.Not(conds...))
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) Or(conds ...gen.Condition) IDeviceDo {
|
|
|
+ return d.withDO(d.DO.Or(conds...))
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) Select(conds ...field.Expr) IDeviceDo {
|
|
|
+ return d.withDO(d.DO.Select(conds...))
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) Where(conds ...gen.Condition) IDeviceDo {
|
|
|
+ return d.withDO(d.DO.Where(conds...))
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) Order(conds ...field.Expr) IDeviceDo {
|
|
|
+ return d.withDO(d.DO.Order(conds...))
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) Distinct(cols ...field.Expr) IDeviceDo {
|
|
|
+ return d.withDO(d.DO.Distinct(cols...))
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) Omit(cols ...field.Expr) IDeviceDo {
|
|
|
+ return d.withDO(d.DO.Omit(cols...))
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) Join(table schema.Tabler, on ...field.Expr) IDeviceDo {
|
|
|
+ return d.withDO(d.DO.Join(table, on...))
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) LeftJoin(table schema.Tabler, on ...field.Expr) IDeviceDo {
|
|
|
+ return d.withDO(d.DO.LeftJoin(table, on...))
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) RightJoin(table schema.Tabler, on ...field.Expr) IDeviceDo {
|
|
|
+ return d.withDO(d.DO.RightJoin(table, on...))
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) Group(cols ...field.Expr) IDeviceDo {
|
|
|
+ return d.withDO(d.DO.Group(cols...))
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) Having(conds ...gen.Condition) IDeviceDo {
|
|
|
+ return d.withDO(d.DO.Having(conds...))
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) Limit(limit int) IDeviceDo {
|
|
|
+ return d.withDO(d.DO.Limit(limit))
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) Offset(offset int) IDeviceDo {
|
|
|
+ return d.withDO(d.DO.Offset(offset))
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IDeviceDo {
|
|
|
+ return d.withDO(d.DO.Scopes(funcs...))
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) Unscoped() IDeviceDo {
|
|
|
+ return d.withDO(d.DO.Unscoped())
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) Create(values ...*model.Device) error {
|
|
|
+ if len(values) == 0 {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return d.DO.Create(values)
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) CreateInBatches(values []*model.Device, batchSize int) error {
|
|
|
+ return d.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 (d deviceDo) Save(values ...*model.Device) error {
|
|
|
+ if len(values) == 0 {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return d.DO.Save(values)
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) First() (*model.Device, error) {
|
|
|
+ if result, err := d.DO.First(); err != nil {
|
|
|
+ return nil, err
|
|
|
+ } else {
|
|
|
+ return result.(*model.Device), nil
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) Take() (*model.Device, error) {
|
|
|
+ if result, err := d.DO.Take(); err != nil {
|
|
|
+ return nil, err
|
|
|
+ } else {
|
|
|
+ return result.(*model.Device), nil
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) Last() (*model.Device, error) {
|
|
|
+ if result, err := d.DO.Last(); err != nil {
|
|
|
+ return nil, err
|
|
|
+ } else {
|
|
|
+ return result.(*model.Device), nil
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) Find() ([]*model.Device, error) {
|
|
|
+ result, err := d.DO.Find()
|
|
|
+ return result.([]*model.Device), err
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Device, err error) {
|
|
|
+ buf := make([]*model.Device, 0, batchSize)
|
|
|
+ err = d.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 (d deviceDo) FindInBatches(result *[]*model.Device, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
|
+ return d.DO.FindInBatches(result, batchSize, fc)
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) Attrs(attrs ...field.AssignExpr) IDeviceDo {
|
|
|
+ return d.withDO(d.DO.Attrs(attrs...))
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) Assign(attrs ...field.AssignExpr) IDeviceDo {
|
|
|
+ return d.withDO(d.DO.Assign(attrs...))
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) Joins(fields ...field.RelationField) IDeviceDo {
|
|
|
+ for _, _f := range fields {
|
|
|
+ d = *d.withDO(d.DO.Joins(_f))
|
|
|
+ }
|
|
|
+ return &d
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) Preload(fields ...field.RelationField) IDeviceDo {
|
|
|
+ for _, _f := range fields {
|
|
|
+ d = *d.withDO(d.DO.Preload(_f))
|
|
|
+ }
|
|
|
+ return &d
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) FirstOrInit() (*model.Device, error) {
|
|
|
+ if result, err := d.DO.FirstOrInit(); err != nil {
|
|
|
+ return nil, err
|
|
|
+ } else {
|
|
|
+ return result.(*model.Device), nil
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) FirstOrCreate() (*model.Device, error) {
|
|
|
+ if result, err := d.DO.FirstOrCreate(); err != nil {
|
|
|
+ return nil, err
|
|
|
+ } else {
|
|
|
+ return result.(*model.Device), nil
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) FindByPage(offset int, limit int) (result []*model.Device, count int64, err error) {
|
|
|
+ result, err = d.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 = d.Offset(-1).Limit(-1).Count()
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
|
|
+ count, err = d.Count()
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ err = d.Offset(offset).Limit(limit).Scan(result)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) Scan(result interface{}) (err error) {
|
|
|
+ return d.DO.Scan(result)
|
|
|
+}
|
|
|
+
|
|
|
+func (d deviceDo) Delete(models ...*model.Device) (result gen.ResultInfo, err error) {
|
|
|
+ return d.DO.Delete(models)
|
|
|
+}
|
|
|
+
|
|
|
+func (d *deviceDo) withDO(do gen.Dao) *deviceDo {
|
|
|
+ d.DO = *do.(*gen.DO)
|
|
|
+ return d
|
|
|
+}
|