dcWorkingRoModel_gen.go 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. // Code generated by goctl. DO NOT EDIT.
  2. package model
  3. import (
  4. "context"
  5. "database/sql"
  6. "fmt"
  7. "strings"
  8. "time"
  9. "github.com/zeromicro/go-zero/core/stores/builder"
  10. "github.com/zeromicro/go-zero/core/stores/sqlc"
  11. "github.com/zeromicro/go-zero/core/stores/sqlx"
  12. "github.com/zeromicro/go-zero/core/stringx"
  13. )
  14. var (
  15. dcWorkingRoFieldNames = builder.RawFieldNames(&DcWorkingRo{})
  16. dcWorkingRoRows = strings.Join(dcWorkingRoFieldNames, ",")
  17. dcWorkingRoRowsExpectAutoSet = strings.Join(stringx.Remove(dcWorkingRoFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
  18. dcWorkingRoRowsWithPlaceHolder = strings.Join(stringx.Remove(dcWorkingRoFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
  19. )
  20. type (
  21. dcWorkingRoModel interface {
  22. MultiInsert(ctx context.Context, datas []DcWorkingRo) (int64, error)
  23. Insert(ctx context.Context, data *DcWorkingRo) (sql.Result, error)
  24. FindOne(ctx context.Context, id int64) (*DcWorkingRo, error)
  25. Update(ctx context.Context, data *DcWorkingRo) error
  26. Delete(ctx context.Context, id int64) error
  27. }
  28. defaultDcWorkingRoModel struct {
  29. conn sqlx.SqlConn
  30. table string
  31. }
  32. DcWorkingRo struct {
  33. Id int64 `db:"id"`
  34. ProjectId int64 `db:"project_id"`
  35. DeviceCode string `db:"device_code"`
  36. WaterTemperature float64 `db:"water_temperature"` // 水温 摄氏度
  37. FeedFlow1St float64 `db:"feed_flow_1st"` // 一段进水流量
  38. ConFlow1St float64 `db:"con_flow_1st"` // 一段浓水流量
  39. ProductFlow1St float64 `db:"product_flow_1st"` // 一段产水流量
  40. FeedPressure1St float64 `db:"feed_pressure_1st"` // 一段进水压力
  41. ConPressure1St float64 `db:"con_pressure_1st"` // 一段浓水压力
  42. ProductPressure1St float64 `db:"product_pressure_1st"` // 一段产水压力
  43. Tmp1St float64 `db:"tmp_1st"` // 一段跨膜压差
  44. Flux1St float64 `db:"flux_1st"` // 一段膜通量
  45. Permeability1St float64 `db:"permeability_1st"` // 一段渗透率
  46. FeedFlow2Nd float64 `db:"feed_flow_2nd"` // 二段进水流量
  47. ConFlow2Nd float64 `db:"con_flow_2nd"` // 二段浓水流量
  48. ProductFlow2Nd float64 `db:"product_flow_2nd"` // 二段产水流量
  49. FeedPressure2Nd float64 `db:"feed_pressure_2nd"` // 二段进水压力
  50. ConPressure2Nd float64 `db:"con_pressure_2nd"` // 二段浓水压力
  51. ProductPressure2Nd float64 `db:"product_pressure_2nd"` // 二段产水压力
  52. Tmp2Nd float64 `db:"tmp_2nd"` // 二段压差
  53. Flux2Nd float64 `db:"flux_2nd"` // 二段通量
  54. Permeability2Nd float64 `db:"permeability_2nd"` // 二段渗透率
  55. FeedFlow3Th float64 `db:"feed_flow_3th"` // 三段进水流量
  56. ConFlow3Th float64 `db:"con_flow_3th"` // 三段浓水流量
  57. ProductFlow3Th float64 `db:"product_flow_3th"` // 三段产水流量
  58. FeedPressure3Th float64 `db:"feed_pressure_3th"` // 三段进水压力
  59. ConPressure3Th float64 `db:"con_pressure_3th"` // 三段浓水压力
  60. ProductPressure3Th float64 `db:"product_pressure_3th"` // 三段产水压力
  61. Tmp3Th float64 `db:"tmp_3th"` // 三段压差
  62. Flux3Th float64 `db:"flux_3th"` // 三段通量
  63. Permeability3Th float64 `db:"permeability_3th"` // 三段渗透率
  64. FeedWqTurbidity float64 `db:"feed_wq_turbidity"` // 进水浊度
  65. FeedWqPh int64 `db:"feed_wq_ph"` // 进水 PH 值
  66. ProductWqPh int64 `db:"product_wq_ph"` // 产水 PH 值
  67. FeedWqAl float64 `db:"feed_wq_al"` // 进水水质:铝
  68. ProductWqAl float64 `db:"product_wq_al"` // 产水水质:铝
  69. FeedWqFe float64 `db:"feed_wq_fe"` // 进水水质:铁
  70. ProductWqFe float64 `db:"product_wq_fe"` // 产水水质:铁
  71. FeedWqMn float64 `db:"feed_wq_mn"` // 进水水质:锰
  72. ProductWqMn float64 `db:"product_wq_mn"` // 产水水质:锰
  73. FeedWqSio2 float64 `db:"feed_wq_sio2"` // 进水水质:二氧化硅
  74. ProductWqSio2 float64 `db:"product_wq_sio2"` // 产水水质:二氧化硅
  75. FeedWqCod float64 `db:"feed_wq_cod"` // 进水水质:COD
  76. ProductWqCod float64 `db:"product_wq_cod"` // 产水水质:COD
  77. FeedWqP float64 `db:"feed_wq_p"` // 进水水质:磷
  78. ProductWqP float64 `db:"product_wq_p"` // 产水水质:磷
  79. Step int64 `db:"step"` // 设备当前步序值
  80. FilterTime float64 `db:"filter_time"` // 过滤时间
  81. FilterCycle int64 `db:"filter_cycle"` // 当前过滤周期数
  82. CTime time.Time `db:"c_time"`
  83. }
  84. )
  85. func newDcWorkingRoModel(conn sqlx.SqlConn) *defaultDcWorkingRoModel {
  86. return &defaultDcWorkingRoModel{
  87. conn: conn,
  88. table: "`dc_working_ro`",
  89. }
  90. }
  91. func (m *defaultDcWorkingRoModel) withSession(session sqlx.Session) *defaultDcWorkingRoModel {
  92. return &defaultDcWorkingRoModel{
  93. conn: sqlx.NewSqlConnFromSession(session),
  94. table: "`dc_working_ro`",
  95. }
  96. }
  97. func (m *defaultDcWorkingRoModel) Delete(ctx context.Context, id int64) error {
  98. query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
  99. _, err := m.conn.ExecCtx(ctx, query, id)
  100. return err
  101. }
  102. func (m *defaultDcWorkingRoModel) FindOne(ctx context.Context, id int64) (*DcWorkingRo, error) {
  103. query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", dcWorkingRoRows, m.table)
  104. var resp DcWorkingRo
  105. err := m.conn.QueryRowCtx(ctx, &resp, query, id)
  106. switch err {
  107. case nil:
  108. return &resp, nil
  109. case sqlc.ErrNotFound:
  110. return nil, ErrNotFound
  111. default:
  112. return nil, err
  113. }
  114. }
  115. func (m *defaultDcWorkingRoModel) MultiInsert(ctx context.Context, datas []DcWorkingRo) (int64, error) {
  116. query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, dcWorkingRoRowsExpectAutoSet)
  117. if bulk, err := sqlx.NewBulkInserter(m.conn, query); err == nil {
  118. for _, data := range datas {
  119. if err = bulk.Insert(data.ProjectId, data.DeviceCode, data.WaterTemperature, data.FeedFlow1St, data.ConFlow1St, data.ProductFlow1St, data.FeedPressure1St, data.ConPressure1St, data.ProductPressure1St, data.Tmp1St, data.Flux1St, data.Permeability1St, data.FeedFlow2Nd, data.ConFlow2Nd, data.ProductFlow2Nd, data.FeedPressure2Nd, data.ConPressure2Nd, data.ProductPressure2Nd, data.Tmp2Nd, data.Flux2Nd, data.Permeability2Nd, data.FeedFlow3Th, data.ConFlow3Th, data.ProductFlow3Th, data.FeedPressure3Th, data.ConPressure3Th, data.ProductPressure3Th, data.Tmp3Th, data.Flux3Th, data.Permeability3Th, data.FeedWqTurbidity, data.FeedWqPh, data.ProductWqPh, data.FeedWqAl, data.ProductWqAl, data.FeedWqFe, data.ProductWqFe, data.FeedWqMn, data.ProductWqMn, data.FeedWqSio2, data.ProductWqSio2, data.FeedWqCod, data.ProductWqCod, data.FeedWqP, data.ProductWqP, data.Step, data.FilterTime, data.FilterCycle, data.CTime); err != nil {
  120. return 0, err
  121. }
  122. }
  123. bulk.Flush()
  124. return int64(len(datas)), nil
  125. } else {
  126. return 0, err
  127. }
  128. }
  129. func (m *defaultDcWorkingRoModel) Insert(ctx context.Context, data *DcWorkingRo) (sql.Result, error) {
  130. query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, dcWorkingRoRowsExpectAutoSet)
  131. ret, err := m.conn.ExecCtx(ctx, query, data.ProjectId, data.DeviceCode, data.WaterTemperature, data.FeedFlow1St, data.ConFlow1St, data.ProductFlow1St, data.FeedPressure1St, data.ConPressure1St, data.ProductPressure1St, data.Tmp1St, data.Flux1St, data.Permeability1St, data.FeedFlow2Nd, data.ConFlow2Nd, data.ProductFlow2Nd, data.FeedPressure2Nd, data.ConPressure2Nd, data.ProductPressure2Nd, data.Tmp2Nd, data.Flux2Nd, data.Permeability2Nd, data.FeedFlow3Th, data.ConFlow3Th, data.ProductFlow3Th, data.FeedPressure3Th, data.ConPressure3Th, data.ProductPressure3Th, data.Tmp3Th, data.Flux3Th, data.Permeability3Th, data.FeedWqTurbidity, data.FeedWqPh, data.ProductWqPh, data.FeedWqAl, data.ProductWqAl, data.FeedWqFe, data.ProductWqFe, data.FeedWqMn, data.ProductWqMn, data.FeedWqSio2, data.ProductWqSio2, data.FeedWqCod, data.ProductWqCod, data.FeedWqP, data.ProductWqP, data.Step, data.FilterTime, data.FilterCycle, data.CTime)
  132. return ret, err
  133. }
  134. func (m *defaultDcWorkingRoModel) Update(ctx context.Context, data *DcWorkingRo) error {
  135. query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, dcWorkingRoRowsWithPlaceHolder)
  136. _, err := m.conn.ExecCtx(ctx, query, data.ProjectId, data.DeviceCode, data.WaterTemperature, data.FeedFlow1St, data.ConFlow1St, data.ProductFlow1St, data.FeedPressure1St, data.ConPressure1St, data.ProductPressure1St, data.Tmp1St, data.Flux1St, data.Permeability1St, data.FeedFlow2Nd, data.ConFlow2Nd, data.ProductFlow2Nd, data.FeedPressure2Nd, data.ConPressure2Nd, data.ProductPressure2Nd, data.Tmp2Nd, data.Flux2Nd, data.Permeability2Nd, data.FeedFlow3Th, data.ConFlow3Th, data.ProductFlow3Th, data.FeedPressure3Th, data.ConPressure3Th, data.ProductPressure3Th, data.Tmp3Th, data.Flux3Th, data.Permeability3Th, data.FeedWqTurbidity, data.FeedWqPh, data.ProductWqPh, data.FeedWqAl, data.ProductWqAl, data.FeedWqFe, data.ProductWqFe, data.FeedWqMn, data.ProductWqMn, data.FeedWqSio2, data.ProductWqSio2, data.FeedWqCod, data.ProductWqCod, data.FeedWqP, data.ProductWqP, data.Step, data.FilterTime, data.FilterCycle, data.CTime, data.Id)
  137. return err
  138. }
  139. func (m *defaultDcWorkingRoModel) tableName() string {
  140. return m.table
  141. }