98 lines
4.3 KiB
Go
Executable File
98 lines
4.3 KiB
Go
Executable File
// 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 (
|
||
fsProductTemplateV2FieldNames = builder.RawFieldNames(&FsProductTemplateV2{})
|
||
fsProductTemplateV2Rows = strings.Join(fsProductTemplateV2FieldNames, ",")
|
||
fsProductTemplateV2RowsExpectAutoSet = strings.Join(stringx.Remove(fsProductTemplateV2FieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
|
||
fsProductTemplateV2RowsWithPlaceHolder = strings.Join(stringx.Remove(fsProductTemplateV2FieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
|
||
)
|
||
|
||
type (
|
||
fsProductTemplateV2Model interface {
|
||
Insert(ctx context.Context, data *FsProductTemplateV2) (sql.Result, error)
|
||
FindOne(ctx context.Context, id int64) (*FsProductTemplateV2, error)
|
||
Update(ctx context.Context, data *FsProductTemplateV2) error
|
||
Delete(ctx context.Context, id int64) error
|
||
}
|
||
|
||
defaultFsProductTemplateV2Model struct {
|
||
conn sqlx.SqlConn
|
||
table string
|
||
}
|
||
|
||
FsProductTemplateV2 struct {
|
||
Id int64 `db:"id"`
|
||
ProductId int64 `db:"product_id"` // 产品ID
|
||
ModelId int64 `db:"model_id"` // 模型ID
|
||
Title string `db:"title"` // 模板(sku),预留字段
|
||
Name string `db:"name"` // 名称
|
||
CoverImg sql.NullString `db:"cover_img"` // 模板背景图
|
||
TemplateInfo string `db:"template_info"` // 模板详情
|
||
MaterialImg sql.NullString `db:"material_img"` // 合成好的贴图
|
||
Sort int64 `db:"sort"` // 排序
|
||
LogoWidth int64 `db:"logo_width"` // logo图最大宽度
|
||
LogoHeight int64 `db:"logo_height"` // logo图最大高度
|
||
IsPublic int64 `db:"is_public"` // 是否可公用(1:可以,0:不可以)
|
||
Status int64 `db:"status"` // 状态1正常 2异常
|
||
Ctime int64 `db:"ctime"` // 添加时间
|
||
Tag string `db:"tag"` // 标签(用户自填)
|
||
IsDel int64 `db:"is_del"` // 是否删除 1删除
|
||
}
|
||
)
|
||
|
||
func newFsProductTemplateV2Model(conn sqlx.SqlConn) *defaultFsProductTemplateV2Model {
|
||
return &defaultFsProductTemplateV2Model{
|
||
conn: conn,
|
||
table: "`fs_product_template_v2`",
|
||
}
|
||
}
|
||
|
||
func (m *defaultFsProductTemplateV2Model) 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 *defaultFsProductTemplateV2Model) FindOne(ctx context.Context, id int64) (*FsProductTemplateV2, error) {
|
||
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", fsProductTemplateV2Rows, m.table)
|
||
var resp FsProductTemplateV2
|
||
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 *defaultFsProductTemplateV2Model) Insert(ctx context.Context, data *FsProductTemplateV2) (sql.Result, error) {
|
||
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, fsProductTemplateV2RowsExpectAutoSet)
|
||
ret, err := m.conn.ExecCtx(ctx, query, data.ProductId, data.ModelId, data.Title, data.Name, data.CoverImg, data.TemplateInfo, data.MaterialImg, data.Sort, data.LogoWidth, data.LogoHeight, data.IsPublic, data.Status, data.Ctime, data.Tag, data.IsDel)
|
||
return ret, err
|
||
}
|
||
|
||
func (m *defaultFsProductTemplateV2Model) Update(ctx context.Context, data *FsProductTemplateV2) error {
|
||
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, fsProductTemplateV2RowsWithPlaceHolder)
|
||
_, err := m.conn.ExecCtx(ctx, query, data.ProductId, data.ModelId, data.Title, data.Name, data.CoverImg, data.TemplateInfo, data.MaterialImg, data.Sort, data.LogoWidth, data.LogoHeight, data.IsPublic, data.Status, data.Ctime, data.Tag, data.IsDel, data.Id)
|
||
return err
|
||
}
|
||
func (m *defaultFsProductTemplateV2Model) tableName() string {
|
||
return m.table
|
||
}
|