alarm_relation.gen.go 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. // Code generated by gorm.io/gen. DO NOT EDIT.
  2. // Code generated by gorm.io/gen. DO NOT EDIT.
  3. // Code generated by gorm.io/gen. DO NOT EDIT.
  4. package dao
  5. import (
  6. "context"
  7. "gorm.io/gorm"
  8. "gorm.io/gorm/clause"
  9. "gorm.io/gorm/schema"
  10. "gorm.io/gen"
  11. "gorm.io/gen/field"
  12. "gorm.io/plugin/dbresolver"
  13. "git.rtzhtech.cn/iss/public-lib/model"
  14. )
  15. func newAlarmRelation(db *gorm.DB) alarmRelation {
  16. _alarmRelation := alarmRelation{}
  17. _alarmRelation.alarmRelationDo.UseDB(db)
  18. _alarmRelation.alarmRelationDo.UseModel(&model.AlarmRelation{})
  19. tableName := _alarmRelation.alarmRelationDo.TableName()
  20. _alarmRelation.ALL = field.NewField(tableName, "*")
  21. _alarmRelation.ID = field.NewInt32(tableName, "id")
  22. _alarmRelation.Strategyid = field.NewInt64(tableName, "strategyid")
  23. _alarmRelation.Mpid = field.NewInt64(tableName, "mpid")
  24. _alarmRelation.Alarmtype = field.NewInt32(tableName, "alarmtype")
  25. _alarmRelation.Uplimit = field.NewFloat64(tableName, "uplimit")
  26. _alarmRelation.Dnlimit = field.NewFloat64(tableName, "dnlimit")
  27. _alarmRelation.Dio = field.NewInt32(tableName, "dio")
  28. _alarmRelation.Diffvalue = field.NewFloat64(tableName, "diffvalue")
  29. _alarmRelation.Relation = field.NewInt32(tableName, "relation")
  30. _alarmRelation.CreateAt = field.NewTime(tableName, "create_at")
  31. _alarmRelation.UpdateAt = field.NewTime(tableName, "update_at")
  32. _alarmRelation.fillFieldMap()
  33. _alarmRelation.Base = newBase(tableName, db)
  34. return _alarmRelation
  35. }
  36. type alarmRelation struct {
  37. alarmRelationDo
  38. ALL field.Field
  39. ID field.Int32
  40. Strategyid field.Int64
  41. Mpid field.Int64
  42. Alarmtype field.Int32
  43. Uplimit field.Float64
  44. Dnlimit field.Float64
  45. Dio field.Int32
  46. Diffvalue field.Float64
  47. Relation field.Int32
  48. CreateAt field.Time
  49. UpdateAt field.Time
  50. fieldMap map[string]field.Expr
  51. }
  52. func (a alarmRelation) Table(newTableName string) *alarmRelation {
  53. a.alarmRelationDo.UseTable(newTableName)
  54. return a.updateTableName(newTableName)
  55. }
  56. func (a alarmRelation) As(alias string) *alarmRelation {
  57. a.alarmRelationDo.DO = *(a.alarmRelationDo.As(alias).(*gen.DO))
  58. return a.updateTableName(alias)
  59. }
  60. func (a *alarmRelation) updateTableName(table string) *alarmRelation {
  61. a.ALL = field.NewField(table, "*")
  62. a.ID = field.NewInt32(table, "id")
  63. a.Strategyid = field.NewInt64(table, "strategyid")
  64. a.Mpid = field.NewInt64(table, "mpid")
  65. a.Alarmtype = field.NewInt32(table, "alarmtype")
  66. a.Uplimit = field.NewFloat64(table, "uplimit")
  67. a.Dnlimit = field.NewFloat64(table, "dnlimit")
  68. a.Dio = field.NewInt32(table, "dio")
  69. a.Diffvalue = field.NewFloat64(table, "diffvalue")
  70. a.Relation = field.NewInt32(table, "relation")
  71. a.CreateAt = field.NewTime(table, "create_at")
  72. a.UpdateAt = field.NewTime(table, "update_at")
  73. a.fillFieldMap()
  74. return a
  75. }
  76. func (a *alarmRelation) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
  77. _f, ok := a.fieldMap[fieldName]
  78. if !ok || _f == nil {
  79. return nil, false
  80. }
  81. _oe, ok := _f.(field.OrderExpr)
  82. return _oe, ok
  83. }
  84. func (a *alarmRelation) fillFieldMap() {
  85. a.fieldMap = make(map[string]field.Expr, 11)
  86. a.fieldMap["id"] = a.ID
  87. a.fieldMap["strategyid"] = a.Strategyid
  88. a.fieldMap["mpid"] = a.Mpid
  89. a.fieldMap["alarmtype"] = a.Alarmtype
  90. a.fieldMap["uplimit"] = a.Uplimit
  91. a.fieldMap["dnlimit"] = a.Dnlimit
  92. a.fieldMap["dio"] = a.Dio
  93. a.fieldMap["diffvalue"] = a.Diffvalue
  94. a.fieldMap["relation"] = a.Relation
  95. a.fieldMap["create_at"] = a.CreateAt
  96. a.fieldMap["update_at"] = a.UpdateAt
  97. }
  98. func (a alarmRelation) clone(db *gorm.DB) alarmRelation {
  99. a.alarmRelationDo.ReplaceDB(db)
  100. return a
  101. }
  102. type alarmRelationDo struct {
  103. gen.DO
  104. Base *Base
  105. }
  106. func (a alarmRelationDo) Debug() *alarmRelationDo {
  107. return a.withDO(a.DO.Debug())
  108. }
  109. func (a alarmRelationDo) WithContext(ctx context.Context) *alarmRelationDo {
  110. return a.withDO(a.DO.WithContext(ctx))
  111. }
  112. func (a alarmRelationDo) ReadDB() *alarmRelationDo {
  113. return a.Clauses(dbresolver.Read)
  114. }
  115. func (a alarmRelationDo) WriteDB() *alarmRelationDo {
  116. return a.Clauses(dbresolver.Write)
  117. }
  118. func (a alarmRelationDo) Clauses(conds ...clause.Expression) *alarmRelationDo {
  119. return a.withDO(a.DO.Clauses(conds...))
  120. }
  121. func (a alarmRelationDo) Returning(value interface{}, columns ...string) *alarmRelationDo {
  122. return a.withDO(a.DO.Returning(value, columns...))
  123. }
  124. func (a alarmRelationDo) Not(conds ...gen.Condition) *alarmRelationDo {
  125. return a.withDO(a.DO.Not(conds...))
  126. }
  127. func (a alarmRelationDo) Or(conds ...gen.Condition) *alarmRelationDo {
  128. return a.withDO(a.DO.Or(conds...))
  129. }
  130. func (a alarmRelationDo) Select(conds ...field.Expr) *alarmRelationDo {
  131. return a.withDO(a.DO.Select(conds...))
  132. }
  133. func (a alarmRelationDo) Where(conds ...gen.Condition) *alarmRelationDo {
  134. return a.withDO(a.DO.Where(conds...))
  135. }
  136. func (a alarmRelationDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *alarmRelationDo {
  137. return a.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
  138. }
  139. func (a alarmRelationDo) Order(conds ...field.Expr) *alarmRelationDo {
  140. return a.withDO(a.DO.Order(conds...))
  141. }
  142. func (a alarmRelationDo) Distinct(cols ...field.Expr) *alarmRelationDo {
  143. return a.withDO(a.DO.Distinct(cols...))
  144. }
  145. func (a alarmRelationDo) Omit(cols ...field.Expr) *alarmRelationDo {
  146. return a.withDO(a.DO.Omit(cols...))
  147. }
  148. func (a alarmRelationDo) Join(table schema.Tabler, on ...field.Expr) *alarmRelationDo {
  149. return a.withDO(a.DO.Join(table, on...))
  150. }
  151. func (a alarmRelationDo) LeftJoin(table schema.Tabler, on ...field.Expr) *alarmRelationDo {
  152. return a.withDO(a.DO.LeftJoin(table, on...))
  153. }
  154. func (a alarmRelationDo) RightJoin(table schema.Tabler, on ...field.Expr) *alarmRelationDo {
  155. return a.withDO(a.DO.RightJoin(table, on...))
  156. }
  157. func (a alarmRelationDo) Group(cols ...field.Expr) *alarmRelationDo {
  158. return a.withDO(a.DO.Group(cols...))
  159. }
  160. func (a alarmRelationDo) Having(conds ...gen.Condition) *alarmRelationDo {
  161. return a.withDO(a.DO.Having(conds...))
  162. }
  163. func (a alarmRelationDo) Limit(limit int) *alarmRelationDo {
  164. return a.withDO(a.DO.Limit(limit))
  165. }
  166. func (a alarmRelationDo) Offset(offset int) *alarmRelationDo {
  167. return a.withDO(a.DO.Offset(offset))
  168. }
  169. func (a alarmRelationDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *alarmRelationDo {
  170. return a.withDO(a.DO.Scopes(funcs...))
  171. }
  172. func (a alarmRelationDo) Unscoped() *alarmRelationDo {
  173. return a.withDO(a.DO.Unscoped())
  174. }
  175. func (a alarmRelationDo) Create(values ...*model.AlarmRelation) error {
  176. if len(values) == 0 {
  177. return nil
  178. }
  179. return a.DO.Create(values)
  180. }
  181. func (a alarmRelationDo) CreateInBatches(values []*model.AlarmRelation, batchSize int) error {
  182. return a.DO.CreateInBatches(values, batchSize)
  183. }
  184. // Save : !!! underlying implementation is different with GORM
  185. // The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
  186. func (a alarmRelationDo) Save(values ...*model.AlarmRelation) error {
  187. if len(values) == 0 {
  188. return nil
  189. }
  190. return a.DO.Save(values)
  191. }
  192. func (a alarmRelationDo) First() (*model.AlarmRelation, error) {
  193. if result, err := a.DO.First(); err != nil {
  194. return nil, err
  195. } else {
  196. return result.(*model.AlarmRelation), nil
  197. }
  198. }
  199. func (a alarmRelationDo) Take() (*model.AlarmRelation, error) {
  200. if result, err := a.DO.Take(); err != nil {
  201. return nil, err
  202. } else {
  203. return result.(*model.AlarmRelation), nil
  204. }
  205. }
  206. func (a alarmRelationDo) Last() (*model.AlarmRelation, error) {
  207. if result, err := a.DO.Last(); err != nil {
  208. return nil, err
  209. } else {
  210. return result.(*model.AlarmRelation), nil
  211. }
  212. }
  213. func (a alarmRelationDo) Find() ([]*model.AlarmRelation, error) {
  214. result, err := a.DO.Find()
  215. return result.([]*model.AlarmRelation), err
  216. }
  217. func (a alarmRelationDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AlarmRelation, err error) {
  218. buf := make([]*model.AlarmRelation, 0, batchSize)
  219. err = a.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
  220. defer func() { results = append(results, buf...) }()
  221. return fc(tx, batch)
  222. })
  223. return results, err
  224. }
  225. func (a alarmRelationDo) FindInBatches(result *[]*model.AlarmRelation, batchSize int, fc func(tx gen.Dao, batch int) error) error {
  226. return a.DO.FindInBatches(result, batchSize, fc)
  227. }
  228. func (a alarmRelationDo) Attrs(attrs ...field.AssignExpr) *alarmRelationDo {
  229. return a.withDO(a.DO.Attrs(attrs...))
  230. }
  231. func (a alarmRelationDo) Assign(attrs ...field.AssignExpr) *alarmRelationDo {
  232. return a.withDO(a.DO.Assign(attrs...))
  233. }
  234. func (a alarmRelationDo) Joins(fields ...field.RelationField) *alarmRelationDo {
  235. for _, _f := range fields {
  236. a = *a.withDO(a.DO.Joins(_f))
  237. }
  238. return &a
  239. }
  240. func (a alarmRelationDo) Preload(fields ...field.RelationField) *alarmRelationDo {
  241. for _, _f := range fields {
  242. a = *a.withDO(a.DO.Preload(_f))
  243. }
  244. return &a
  245. }
  246. func (a alarmRelationDo) FirstOrInit() (*model.AlarmRelation, error) {
  247. if result, err := a.DO.FirstOrInit(); err != nil {
  248. return nil, err
  249. } else {
  250. return result.(*model.AlarmRelation), nil
  251. }
  252. }
  253. func (a alarmRelationDo) FirstOrCreate() (*model.AlarmRelation, error) {
  254. if result, err := a.DO.FirstOrCreate(); err != nil {
  255. return nil, err
  256. } else {
  257. return result.(*model.AlarmRelation), nil
  258. }
  259. }
  260. func (a alarmRelationDo) FindByPage(offset int, limit int) (result []*model.AlarmRelation, count int64, err error) {
  261. result, err = a.Offset(offset).Limit(limit).Find()
  262. if err != nil {
  263. return
  264. }
  265. if size := len(result); 0 < limit && 0 < size && size < limit {
  266. count = int64(size + offset)
  267. return
  268. }
  269. count, err = a.Offset(-1).Limit(-1).Count()
  270. return
  271. }
  272. func (a alarmRelationDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
  273. count, err = a.Count()
  274. if err != nil {
  275. return
  276. }
  277. err = a.Offset(offset).Limit(limit).Scan(result)
  278. return
  279. }
  280. func (a alarmRelationDo) Scan(result interface{}) (err error) {
  281. return a.DO.Scan(result)
  282. }
  283. func (a alarmRelationDo) Delete(models ...*model.AlarmRelation) (result gen.ResultInfo, err error) {
  284. return a.DO.Delete(models)
  285. }
  286. func (a *alarmRelationDo) withDO(do gen.Dao) *alarmRelationDo {
  287. a.DO = *do.(*gen.DO)
  288. return a
  289. }