123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- // Code generated by goctl. DO NOT EDIT.
- package model
- import (
- "context"
- "database/sql"
- "fmt"
- "strings"
- "time"
- "github.com/zeromicro/go-zero/core/stores/builder"
- "github.com/zeromicro/go-zero/core/stores/sqlc"
- "github.com/zeromicro/go-zero/core/stores/sqlx"
- "github.com/zeromicro/go-zero/core/stringx"
- )
- var (
- dcWorkingMfFieldNames = builder.RawFieldNames(&DcWorkingMf{})
- dcWorkingMfRows = strings.Join(dcWorkingMfFieldNames, ",")
- dcWorkingMfRowsExpectAutoSet = strings.Join(stringx.Remove(dcWorkingMfFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
- dcWorkingMfRowsWithPlaceHolder = strings.Join(stringx.Remove(dcWorkingMfFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
- )
- type (
- dcWorkingMfModel interface {
- MultiInsert(ctx context.Context, datas []DcWorkingMf) (int64, error)
- Insert(ctx context.Context, data *DcWorkingMf) (sql.Result, error)
- FindOne(ctx context.Context, id int64) (*DcWorkingMf, error)
- Update(ctx context.Context, data *DcWorkingMf) error
- Delete(ctx context.Context, id int64) error
- }
- defaultDcWorkingMfModel struct {
- conn sqlx.SqlConn
- table string
- }
- DcWorkingMf struct {
- Id int64 `db:"id"`
- ProjectId int64 `db:"project_id"`
- DeviceCode string `db:"device_code"`
- WaterTemperature float64 `db:"water_temperature"` // 水温 摄氏度
- FeedFlow float64 `db:"feed_flow"` // 进水流量
- ConFlow float64 `db:"con_flow"` // 浓水流量
- ProductFlow float64 `db:"product_flow"` // 产水流量
- FeedPressure float64 `db:"feed_pressure"` // 进水压力
- ConPressure float64 `db:"con_pressure"` // 浓水压力
- ProductPressure float64 `db:"product_pressure"` // 产水压力
- Tmp float64 `db:"tmp"` // 跨膜压差
- Flux float64 `db:"flux"` // 膜通量
- FeedWqTurbidity float64 `db:"feed_wq_turbidity"` // 进水浊度
- FeedWqPh int64 `db:"feed_wq_ph"` // 进水 PH 值
- ProductWqPh int64 `db:"product_wq_ph"` // 产水 PH 值
- FeedWqAl float64 `db:"feed_wq_al"` // 进水水质:铝
- ProductWqAl float64 `db:"product_wq_al"` // 产水水质:铝
- FeedWqFe float64 `db:"feed_wq_fe"` // 进水水质:铁
- ProductWqFe float64 `db:"product_wq_fe"` // 产水水质:铁
- FeedWqMn float64 `db:"feed_wq_mn"` // 进水水质:锰
- ProductWqMn float64 `db:"product_wq_mn"` // 产水水质:锰
- FeedWqSio2 float64 `db:"feed_wq_sio2"` // 进水水质:二氧化硅
- ProductWqSio2 float64 `db:"product_wq_sio2"` // 产水水质:二氧化硅
- FeedWqCod float64 `db:"feed_wq_cod"` // 进水水质:COD
- ProductWqCod float64 `db:"product_wq_cod"` // 产水水质:COD
- FeedWqP float64 `db:"feed_wq_p"` // 进水水质:磷
- ProductWqP float64 `db:"product_wq_p"` // 产水水质:磷
- Step int64 `db:"step"` // 设备当前步序值
- FilterTime float64 `db:"filter_time"` // 过滤时间
- FilterCycle int64 `db:"filter_cycle"` // 当前过滤周期数
- CTime time.Time `db:"c_time"`
- }
- )
- func newDcWorkingMfModel(conn sqlx.SqlConn) *defaultDcWorkingMfModel {
- return &defaultDcWorkingMfModel{
- conn: conn,
- table: "`dc_working_mf`",
- }
- }
- func (m *defaultDcWorkingMfModel) withSession(session sqlx.Session) *defaultDcWorkingMfModel {
- return &defaultDcWorkingMfModel{
- conn: sqlx.NewSqlConnFromSession(session),
- table: "`dc_working_mf`",
- }
- }
- func (m *defaultDcWorkingMfModel) Delete(ctx context.Context, id int64) error {
- query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
- _, err := m.conn.ExecCtx(ctx, query, id)
- return err
- }
- func (m *defaultDcWorkingMfModel) FindOne(ctx context.Context, id int64) (*DcWorkingMf, error) {
- query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", dcWorkingMfRows, m.table)
- var resp DcWorkingMf
- err := m.conn.QueryRowCtx(ctx, &resp, query, id)
- switch err {
- case nil:
- return &resp, nil
- case sqlc.ErrNotFound:
- return nil, ErrNotFound
- default:
- return nil, err
- }
- }
- func (m *defaultDcWorkingMfModel) MultiInsert(ctx context.Context, datas []DcWorkingMf) (int64, error) {
- query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, dcWorkingMfRowsExpectAutoSet)
- if bulk, err := sqlx.NewBulkInserter(m.conn, query); err == nil {
- for _, data := range datas {
- if err = bulk.Insert(data.ProjectId, data.DeviceCode, data.WaterTemperature, data.FeedFlow, data.ConFlow, data.ProductFlow, data.FeedPressure, data.ConPressure, data.ProductPressure, data.Tmp, data.Flux, 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 {
- return 0, err
- }
- }
- bulk.Flush()
- return int64(len(datas)), nil
- } else {
- return 0, err
- }
- }
- func (m *defaultDcWorkingMfModel) Insert(ctx context.Context, data *DcWorkingMf) (sql.Result, error) {
- query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, dcWorkingMfRowsExpectAutoSet)
- ret, err := m.conn.ExecCtx(ctx, query, data.ProjectId, data.DeviceCode, data.WaterTemperature, data.FeedFlow, data.ConFlow, data.ProductFlow, data.FeedPressure, data.ConPressure, data.ProductPressure, data.Tmp, data.Flux, 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)
- return ret, err
- }
- func (m *defaultDcWorkingMfModel) Update(ctx context.Context, data *DcWorkingMf) error {
- query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, dcWorkingMfRowsWithPlaceHolder)
- _, err := m.conn.ExecCtx(ctx, query, data.ProjectId, data.DeviceCode, data.WaterTemperature, data.FeedFlow, data.ConFlow, data.ProductFlow, data.FeedPressure, data.ConPressure, data.ProductPressure, data.Tmp, data.Flux, 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)
- return err
- }
- func (m *defaultDcWorkingMfModel) tableName() string {
- return m.table
- }
|