123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359 |
- // 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"
- "git.rtzhtech.cn/iss/public-lib/model"
- )
- func newAlarmRelation(db *gorm.DB) alarmRelation {
- _alarmRelation := alarmRelation{}
- _alarmRelation.alarmRelationDo.UseDB(db)
- _alarmRelation.alarmRelationDo.UseModel(&model.AlarmRelation{})
- tableName := _alarmRelation.alarmRelationDo.TableName()
- _alarmRelation.ALL = field.NewField(tableName, "*")
- _alarmRelation.ID = field.NewInt32(tableName, "id")
- _alarmRelation.Strategyid = field.NewInt64(tableName, "strategyid")
- _alarmRelation.Mpid = field.NewInt64(tableName, "mpid")
- _alarmRelation.Alarmtype = field.NewInt32(tableName, "alarmtype")
- _alarmRelation.Uplimit = field.NewFloat64(tableName, "uplimit")
- _alarmRelation.Dnlimit = field.NewFloat64(tableName, "dnlimit")
- _alarmRelation.Dio = field.NewInt32(tableName, "dio")
- _alarmRelation.Diffvalue = field.NewFloat64(tableName, "diffvalue")
- _alarmRelation.Relation = field.NewInt32(tableName, "relation")
- _alarmRelation.CreateAt = field.NewTime(tableName, "create_at")
- _alarmRelation.UpdateAt = field.NewTime(tableName, "update_at")
- _alarmRelation.fillFieldMap()
- _alarmRelation.Base = newBase(tableName, db)
- return _alarmRelation
- }
- type alarmRelation struct {
- alarmRelationDo
- ALL field.Field
- ID field.Int32
- Strategyid field.Int64
- Mpid field.Int64
- Alarmtype field.Int32
- Uplimit field.Float64
- Dnlimit field.Float64
- Dio field.Int32
- Diffvalue field.Float64
- Relation field.Int32
- CreateAt field.Time
- UpdateAt field.Time
- fieldMap map[string]field.Expr
- }
- func (a alarmRelation) Table(newTableName string) *alarmRelation {
- a.alarmRelationDo.UseTable(newTableName)
- return a.updateTableName(newTableName)
- }
- func (a alarmRelation) As(alias string) *alarmRelation {
- a.alarmRelationDo.DO = *(a.alarmRelationDo.As(alias).(*gen.DO))
- return a.updateTableName(alias)
- }
- func (a *alarmRelation) updateTableName(table string) *alarmRelation {
- a.ALL = field.NewField(table, "*")
- a.ID = field.NewInt32(table, "id")
- a.Strategyid = field.NewInt64(table, "strategyid")
- a.Mpid = field.NewInt64(table, "mpid")
- a.Alarmtype = field.NewInt32(table, "alarmtype")
- a.Uplimit = field.NewFloat64(table, "uplimit")
- a.Dnlimit = field.NewFloat64(table, "dnlimit")
- a.Dio = field.NewInt32(table, "dio")
- a.Diffvalue = field.NewFloat64(table, "diffvalue")
- a.Relation = field.NewInt32(table, "relation")
- a.CreateAt = field.NewTime(table, "create_at")
- a.UpdateAt = field.NewTime(table, "update_at")
- a.fillFieldMap()
- return a
- }
- func (a *alarmRelation) 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 *alarmRelation) fillFieldMap() {
- a.fieldMap = make(map[string]field.Expr, 11)
- a.fieldMap["id"] = a.ID
- a.fieldMap["strategyid"] = a.Strategyid
- a.fieldMap["mpid"] = a.Mpid
- a.fieldMap["alarmtype"] = a.Alarmtype
- a.fieldMap["uplimit"] = a.Uplimit
- a.fieldMap["dnlimit"] = a.Dnlimit
- a.fieldMap["dio"] = a.Dio
- a.fieldMap["diffvalue"] = a.Diffvalue
- a.fieldMap["relation"] = a.Relation
- a.fieldMap["create_at"] = a.CreateAt
- a.fieldMap["update_at"] = a.UpdateAt
- }
- func (a alarmRelation) clone(db *gorm.DB) alarmRelation {
- a.alarmRelationDo.ReplaceDB(db)
- return a
- }
- type alarmRelationDo struct {
- gen.DO
- Base *Base
- }
- func (a alarmRelationDo) Debug() *alarmRelationDo {
- return a.withDO(a.DO.Debug())
- }
- func (a alarmRelationDo) WithContext(ctx context.Context) *alarmRelationDo {
- return a.withDO(a.DO.WithContext(ctx))
- }
- func (a alarmRelationDo) ReadDB() *alarmRelationDo {
- return a.Clauses(dbresolver.Read)
- }
- func (a alarmRelationDo) WriteDB() *alarmRelationDo {
- return a.Clauses(dbresolver.Write)
- }
- func (a alarmRelationDo) Clauses(conds ...clause.Expression) *alarmRelationDo {
- return a.withDO(a.DO.Clauses(conds...))
- }
- func (a alarmRelationDo) Returning(value interface{}, columns ...string) *alarmRelationDo {
- return a.withDO(a.DO.Returning(value, columns...))
- }
- func (a alarmRelationDo) Not(conds ...gen.Condition) *alarmRelationDo {
- return a.withDO(a.DO.Not(conds...))
- }
- func (a alarmRelationDo) Or(conds ...gen.Condition) *alarmRelationDo {
- return a.withDO(a.DO.Or(conds...))
- }
- func (a alarmRelationDo) Select(conds ...field.Expr) *alarmRelationDo {
- return a.withDO(a.DO.Select(conds...))
- }
- func (a alarmRelationDo) Where(conds ...gen.Condition) *alarmRelationDo {
- return a.withDO(a.DO.Where(conds...))
- }
- func (a alarmRelationDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *alarmRelationDo {
- return a.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
- }
- func (a alarmRelationDo) Order(conds ...field.Expr) *alarmRelationDo {
- return a.withDO(a.DO.Order(conds...))
- }
- func (a alarmRelationDo) Distinct(cols ...field.Expr) *alarmRelationDo {
- return a.withDO(a.DO.Distinct(cols...))
- }
- func (a alarmRelationDo) Omit(cols ...field.Expr) *alarmRelationDo {
- return a.withDO(a.DO.Omit(cols...))
- }
- func (a alarmRelationDo) Join(table schema.Tabler, on ...field.Expr) *alarmRelationDo {
- return a.withDO(a.DO.Join(table, on...))
- }
- func (a alarmRelationDo) LeftJoin(table schema.Tabler, on ...field.Expr) *alarmRelationDo {
- return a.withDO(a.DO.LeftJoin(table, on...))
- }
- func (a alarmRelationDo) RightJoin(table schema.Tabler, on ...field.Expr) *alarmRelationDo {
- return a.withDO(a.DO.RightJoin(table, on...))
- }
- func (a alarmRelationDo) Group(cols ...field.Expr) *alarmRelationDo {
- return a.withDO(a.DO.Group(cols...))
- }
- func (a alarmRelationDo) Having(conds ...gen.Condition) *alarmRelationDo {
- return a.withDO(a.DO.Having(conds...))
- }
- func (a alarmRelationDo) Limit(limit int) *alarmRelationDo {
- return a.withDO(a.DO.Limit(limit))
- }
- func (a alarmRelationDo) Offset(offset int) *alarmRelationDo {
- return a.withDO(a.DO.Offset(offset))
- }
- func (a alarmRelationDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *alarmRelationDo {
- return a.withDO(a.DO.Scopes(funcs...))
- }
- func (a alarmRelationDo) Unscoped() *alarmRelationDo {
- return a.withDO(a.DO.Unscoped())
- }
- func (a alarmRelationDo) Create(values ...*model.AlarmRelation) error {
- if len(values) == 0 {
- return nil
- }
- return a.DO.Create(values)
- }
- func (a alarmRelationDo) CreateInBatches(values []*model.AlarmRelation, 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 alarmRelationDo) Save(values ...*model.AlarmRelation) error {
- if len(values) == 0 {
- return nil
- }
- return a.DO.Save(values)
- }
- func (a alarmRelationDo) First() (*model.AlarmRelation, error) {
- if result, err := a.DO.First(); err != nil {
- return nil, err
- } else {
- return result.(*model.AlarmRelation), nil
- }
- }
- func (a alarmRelationDo) Take() (*model.AlarmRelation, error) {
- if result, err := a.DO.Take(); err != nil {
- return nil, err
- } else {
- return result.(*model.AlarmRelation), nil
- }
- }
- func (a alarmRelationDo) Last() (*model.AlarmRelation, error) {
- if result, err := a.DO.Last(); err != nil {
- return nil, err
- } else {
- return result.(*model.AlarmRelation), nil
- }
- }
- func (a alarmRelationDo) Find() ([]*model.AlarmRelation, error) {
- result, err := a.DO.Find()
- return result.([]*model.AlarmRelation), err
- }
- func (a alarmRelationDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AlarmRelation, err error) {
- buf := make([]*model.AlarmRelation, 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 alarmRelationDo) FindInBatches(result *[]*model.AlarmRelation, batchSize int, fc func(tx gen.Dao, batch int) error) error {
- return a.DO.FindInBatches(result, batchSize, fc)
- }
- func (a alarmRelationDo) Attrs(attrs ...field.AssignExpr) *alarmRelationDo {
- return a.withDO(a.DO.Attrs(attrs...))
- }
- func (a alarmRelationDo) Assign(attrs ...field.AssignExpr) *alarmRelationDo {
- return a.withDO(a.DO.Assign(attrs...))
- }
- func (a alarmRelationDo) Joins(fields ...field.RelationField) *alarmRelationDo {
- for _, _f := range fields {
- a = *a.withDO(a.DO.Joins(_f))
- }
- return &a
- }
- func (a alarmRelationDo) Preload(fields ...field.RelationField) *alarmRelationDo {
- for _, _f := range fields {
- a = *a.withDO(a.DO.Preload(_f))
- }
- return &a
- }
- func (a alarmRelationDo) FirstOrInit() (*model.AlarmRelation, error) {
- if result, err := a.DO.FirstOrInit(); err != nil {
- return nil, err
- } else {
- return result.(*model.AlarmRelation), nil
- }
- }
- func (a alarmRelationDo) FirstOrCreate() (*model.AlarmRelation, error) {
- if result, err := a.DO.FirstOrCreate(); err != nil {
- return nil, err
- } else {
- return result.(*model.AlarmRelation), nil
- }
- }
- func (a alarmRelationDo) FindByPage(offset int, limit int) (result []*model.AlarmRelation, 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 alarmRelationDo) 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 alarmRelationDo) Scan(result interface{}) (err error) {
- return a.DO.Scan(result)
- }
- func (a alarmRelationDo) Delete(models ...*model.AlarmRelation) (result gen.ResultInfo, err error) {
- return a.DO.Delete(models)
- }
- func (a *alarmRelationDo) withDO(do gen.Dao) *alarmRelationDo {
- a.DO = *do.(*gen.DO)
- return a
- }
|