fusenapi/model/fsproducttemplatev2model_gen.go
laodaming 9a2f74fe64 fix
2023-06-06 17:36:11 +08:00

98 lines
4.3 KiB
Go
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 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
}