fusenapi/model/fsproductmodel3dmodel_gen.go

101 lines
4.5 KiB
Go
Raw Normal View History

2023-06-05 10:32:14 +00:00
// Code generated by goctl. DO NOT EDIT.
package model
import (
"context"
"database/sql"
"fmt"
"strings"
"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 (
2023-06-06 03:14:13 +00:00
fsProductModel3dFieldNames = builder.RawFieldNames(&FsProductModel3d{})
fsProductModel3dRows = strings.Join(fsProductModel3dFieldNames, ",")
fsProductModel3dRowsExpectAutoSet = strings.Join(stringx.Remove(fsProductModel3dFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
fsProductModel3dRowsWithPlaceHolder = strings.Join(stringx.Remove(fsProductModel3dFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
2023-06-05 10:32:14 +00:00
)
type (
2023-06-06 03:14:13 +00:00
fsProductModel3dModel interface {
Insert(ctx context.Context, data *FsProductModel3d) (sql.Result, error)
FindOne(ctx context.Context, id int64) (*FsProductModel3d, error)
Update(ctx context.Context, data *FsProductModel3d) error
2023-06-05 10:32:14 +00:00
Delete(ctx context.Context, id int64) error
}
2023-06-06 03:14:13 +00:00
defaultFsProductModel3dModel struct {
2023-06-05 10:32:14 +00:00
conn sqlx.SqlConn
table string
}
2023-06-06 03:14:13 +00:00
FsProductModel3d struct {
2023-06-05 10:32:14 +00:00
Id int64 `db:"id"`
ProductId sql.NullInt64 `db:"product_id"` // 产品ID
Tag int64 `db:"tag"` // 类别1模型2配件3场景
Title string `db:"title"` // 标题
Name string `db:"name"` // 详情页展示名称
ModelInfo string `db:"model_info"` // 模型详情
MaterialId int64 `db:"material_id"` // 材质ID
SizeId int64 `db:"size_id"` // 尺寸ID
Sort int64 `db:"sort"` // 排序
Light sql.NullInt64 `db:"light"` // 灯光组
LightList sql.NullString `db:"light_list"` // 灯光备选项
PartId sql.NullInt64 `db:"part_id"` // 配件选项id配件就是模型的id
PartList sql.NullString `db:"part_list"` // 配件备选项
Status int64 `db:"status"` // 状态位 显示 删除
Ctime int64 `db:"ctime"` // 添加时间
OptionTemplate sql.NullInt64 `db:"option_template"` // 配件绑定的公共模板
Price int64 `db:"price"` // 仅配件用,配件的价格, 单位:美分
Sku string `db:"sku"` // sku
}
)
2023-06-06 03:14:13 +00:00
func newFsProductModel3dModel(conn sqlx.SqlConn) *defaultFsProductModel3dModel {
return &defaultFsProductModel3dModel{
2023-06-05 10:32:14 +00:00
conn: conn,
2023-06-06 03:14:13 +00:00
table: "`fs_product_model3d`",
2023-06-05 10:32:14 +00:00
}
}
2023-06-06 03:14:13 +00:00
func (m *defaultFsProductModel3dModel) Delete(ctx context.Context, id int64) error {
2023-06-05 10:32:14 +00:00
query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
_, err := m.conn.ExecCtx(ctx, query, id)
return err
}
2023-06-06 03:14:13 +00:00
func (m *defaultFsProductModel3dModel) FindOne(ctx context.Context, id int64) (*FsProductModel3d, error) {
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", fsProductModel3dRows, m.table)
var resp FsProductModel3d
2023-06-05 10:32:14 +00:00
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
}
}
2023-06-06 03:14:13 +00:00
func (m *defaultFsProductModel3dModel) Insert(ctx context.Context, data *FsProductModel3d) (sql.Result, error) {
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, fsProductModel3dRowsExpectAutoSet)
2023-06-05 10:32:14 +00:00
ret, err := m.conn.ExecCtx(ctx, query, data.ProductId, data.Tag, data.Title, data.Name, data.ModelInfo, data.MaterialId, data.SizeId, data.Sort, data.Light, data.LightList, data.PartId, data.PartList, data.Status, data.Ctime, data.OptionTemplate, data.Price, data.Sku)
return ret, err
}
2023-06-06 03:14:13 +00:00
func (m *defaultFsProductModel3dModel) Update(ctx context.Context, data *FsProductModel3d) error {
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, fsProductModel3dRowsWithPlaceHolder)
2023-06-05 10:32:14 +00:00
_, err := m.conn.ExecCtx(ctx, query, data.ProductId, data.Tag, data.Title, data.Name, data.ModelInfo, data.MaterialId, data.SizeId, data.Sort, data.Light, data.LightList, data.PartId, data.PartList, data.Status, data.Ctime, data.OptionTemplate, data.Price, data.Sku, data.Id)
return err
}
2023-06-06 05:07:39 +00:00
2023-06-06 03:14:13 +00:00
func (m *defaultFsProductModel3dModel) tableName() string {
2023-06-05 10:32:14 +00:00
return m.table
}