muyu-apiserver/model/proinboundrecordmodel_gen.go

58 lines
2.0 KiB
Go
Raw Normal View History

package model
import (
"context"
"database/sql"
"fmt"
"strings"
"time"
"github.com/zeromicro/go-zero/core/stores/builder"
"github.com/zeromicro/go-zero/core/stores/sqlx"
"github.com/zeromicro/go-zero/core/stringx"
)
var (
proInboundRecordFieldNames = builder.RawFieldNames(&ProInboundRecord{})
proInboundRecordRows = strings.Join(proInboundRecordFieldNames, ",")
proInboundRecordRowsExpectAutoSet = strings.Join(stringx.Remove(proInboundRecordFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
)
type (
proInboundRecordModel interface {
Insert(ctx context.Context, data *ProInboundRecord) (sql.Result, error)
}
defaultProInboundRecordModel struct {
conn sqlx.SqlConn
table string
}
ProInboundRecord struct {
Id int64 `db:"id"`
RecordId string `db:"record_id"`
TenantId string `db:"tenant_id"`
PlanId string `db:"plan_id"`
ProductId string `db:"product_id"`
BatchNo string `db:"batch_no"`
Quantity float64 `db:"quantity"`
Rolls int64 `db:"rolls"`
PricePerMeter float64 `db:"price_per_meter"`
OperatorId string `db:"operator_id"`
Remark sql.NullString `db:"remark"`
CreatedAt time.Time `db:"created_at"`
}
)
func newProInboundRecordModel(conn sqlx.SqlConn) *defaultProInboundRecordModel {
return &defaultProInboundRecordModel{conn: conn, table: "`pro_inbound_record`"}
}
func (m *defaultProInboundRecordModel) Insert(ctx context.Context, data *ProInboundRecord) (sql.Result, error) {
query := fmt.Sprintf("INSERT INTO %s (%s) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
m.table, proInboundRecordRowsExpectAutoSet)
return m.conn.ExecCtx(ctx, query, data.RecordId, data.TenantId, data.PlanId,
data.ProductId, data.BatchNo, data.Quantity, data.Rolls,
data.PricePerMeter, data.OperatorId, data.Remark)
}