fix
This commit is contained in:
parent
94212b1003
commit
a933f0d763
24
model/fsproductpricemodel.go
Executable file
24
model/fsproductpricemodel.go
Executable file
|
@ -0,0 +1,24 @@
|
|||
package model
|
||||
|
||||
import "github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
|
||||
var _ FsProductPriceModel = (*customFsProductPriceModel)(nil)
|
||||
|
||||
type (
|
||||
// FsProductPriceModel is an interface to be customized, add more methods here,
|
||||
// and implement the added methods in customFsProductPriceModel.
|
||||
FsProductPriceModel interface {
|
||||
fsProductPriceModel
|
||||
}
|
||||
|
||||
customFsProductPriceModel struct {
|
||||
*defaultFsProductPriceModel
|
||||
}
|
||||
)
|
||||
|
||||
// NewFsProductPriceModel returns a model for the database table.
|
||||
func NewFsProductPriceModel(conn sqlx.SqlConn) FsProductPriceModel {
|
||||
return &customFsProductPriceModel{
|
||||
defaultFsProductPriceModel: newFsProductPriceModel(conn),
|
||||
}
|
||||
}
|
123
model/fsproductpricemodel_gen.go
Executable file
123
model/fsproductpricemodel_gen.go
Executable file
|
@ -0,0 +1,123 @@
|
|||
// 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 (
|
||||
fsProductPriceFieldNames = builder.RawFieldNames(&FsProductPrice{})
|
||||
fsProductPriceRows = strings.Join(fsProductPriceFieldNames, ",")
|
||||
fsProductPriceRowsExpectAutoSet = strings.Join(stringx.Remove(fsProductPriceFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
|
||||
fsProductPriceRowsWithPlaceHolder = strings.Join(stringx.Remove(fsProductPriceFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
|
||||
)
|
||||
|
||||
type (
|
||||
fsProductPriceModel interface {
|
||||
Insert(ctx context.Context, data *FsProductPrice) (sql.Result, error)
|
||||
FindOne(ctx context.Context, id int64) (*FsProductPrice, error)
|
||||
FindOneByProductIdMaterialIdSizeId(ctx context.Context, productId int64, materialId int64, sizeId int64) (*FsProductPrice, error)
|
||||
Update(ctx context.Context, data *FsProductPrice) error
|
||||
Delete(ctx context.Context, id int64) error
|
||||
GetPriceList(ctx context.Context, productIds []string) ([]GetPriceListRsp, error)
|
||||
}
|
||||
|
||||
defaultFsProductPriceModel struct {
|
||||
conn sqlx.SqlConn
|
||||
table string
|
||||
}
|
||||
|
||||
FsProductPrice struct {
|
||||
Id int64 `db:"id"`
|
||||
Sn string `db:"sn"` // 唯一编码
|
||||
Title string `db:"title"` // 标题描述
|
||||
ProductId int64 `db:"product_id"` // 产品ID
|
||||
MaterialId int64 `db:"material_id"` // 材质ID
|
||||
SizeId int64 `db:"size_id"` // 尺寸ID
|
||||
EachBoxNum int64 `db:"each_box_num"` // 每一箱的个数
|
||||
EachBoxWeight float64 `db:"each_box_weight"` // 每一箱的重量 单位KG
|
||||
MinBuyNum int64 `db:"min_buy_num"` // 最少购买量
|
||||
StepNum string `db:"step_num"` // 数量阶梯 eg:10,20,30
|
||||
StepPrice string `db:"step_price"` // 价格阶梯 eg:100,50,25
|
||||
Status int64 `db:"status"` // 是否可用
|
||||
IsDefault int64 `db:"is_default"` // 是否默认
|
||||
}
|
||||
)
|
||||
|
||||
func newFsProductPriceModel(conn sqlx.SqlConn) *defaultFsProductPriceModel {
|
||||
return &defaultFsProductPriceModel{
|
||||
conn: conn,
|
||||
table: "`fs_product_price`",
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultFsProductPriceModel) 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 *defaultFsProductPriceModel) FindOne(ctx context.Context, id int64) (*FsProductPrice, error) {
|
||||
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", fsProductPriceRows, m.table)
|
||||
var resp FsProductPrice
|
||||
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 *defaultFsProductPriceModel) FindOneByProductIdMaterialIdSizeId(ctx context.Context, productId int64, materialId int64, sizeId int64) (*FsProductPrice, error) {
|
||||
var resp FsProductPrice
|
||||
query := fmt.Sprintf("select %s from %s where `product_id` = ? and `material_id` = ? and `size_id` = ? limit 1", fsProductPriceRows, m.table)
|
||||
err := m.conn.QueryRowCtx(ctx, &resp, query, productId, materialId, sizeId)
|
||||
switch err {
|
||||
case nil:
|
||||
return &resp, nil
|
||||
case sqlc.ErrNotFound:
|
||||
return nil, ErrNotFound
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultFsProductPriceModel) Insert(ctx context.Context, data *FsProductPrice) (sql.Result, error) {
|
||||
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, fsProductPriceRowsExpectAutoSet)
|
||||
ret, err := m.conn.ExecCtx(ctx, query, data.Sn, data.Title, data.ProductId, data.MaterialId, data.SizeId, data.EachBoxNum, data.EachBoxWeight, data.MinBuyNum, data.StepNum, data.StepPrice, data.Status, data.IsDefault)
|
||||
return ret, err
|
||||
}
|
||||
|
||||
func (m *defaultFsProductPriceModel) Update(ctx context.Context, newData *FsProductPrice) error {
|
||||
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, fsProductPriceRowsWithPlaceHolder)
|
||||
_, err := m.conn.ExecCtx(ctx, query, newData.Sn, newData.Title, newData.ProductId, newData.MaterialId, newData.SizeId, newData.EachBoxNum, newData.EachBoxWeight, newData.MinBuyNum, newData.StepNum, newData.StepPrice, newData.Status, newData.IsDefault, newData.Id)
|
||||
return err
|
||||
}
|
||||
|
||||
type GetPriceListRsp struct {
|
||||
ProductId int64 `json:"product_id"`
|
||||
Price string `json:"price"`
|
||||
}
|
||||
|
||||
func (m *defaultFsProductPriceModel) GetPriceList(ctx context.Context, productIds []string) (resp []GetPriceListRsp, err error) {
|
||||
query := fmt.Sprintf("select %s from %s where `product_id` in (?) and `status` = ? group by product_id", "product_id,group_concat(step_price) as price ", m.table)
|
||||
if err = m.conn.QueryRowsCtx(ctx, &resp, query, strings.Join(productIds, ","), 1); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
||||
func (m *defaultFsProductPriceModel) tableName() string {
|
||||
return m.table
|
||||
}
|
24
model/fsproducttemplatev2model.go
Executable file
24
model/fsproducttemplatev2model.go
Executable file
|
@ -0,0 +1,24 @@
|
|||
package model
|
||||
|
||||
import "github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
|
||||
var _ FsProductTemplateV2Model = (*customFsProductTemplateV2Model)(nil)
|
||||
|
||||
type (
|
||||
// FsProductTemplateV2Model is an interface to be customized, add more methods here,
|
||||
// and implement the added methods in customFsProductTemplateV2Model.
|
||||
FsProductTemplateV2Model interface {
|
||||
fsProductTemplateV2Model
|
||||
}
|
||||
|
||||
customFsProductTemplateV2Model struct {
|
||||
*defaultFsProductTemplateV2Model
|
||||
}
|
||||
)
|
||||
|
||||
// NewFsProductTemplateV2Model returns a model for the database table.
|
||||
func NewFsProductTemplateV2Model(conn sqlx.SqlConn) FsProductTemplateV2Model {
|
||||
return &customFsProductTemplateV2Model{
|
||||
defaultFsProductTemplateV2Model: newFsProductTemplateV2Model(conn),
|
||||
}
|
||||
}
|
105
model/fsproducttemplatev2model_gen.go
Executable file
105
model/fsproducttemplatev2model_gen.go
Executable file
|
@ -0,0 +1,105 @@
|
|||
// 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
|
||||
FindAllByCondition(ctx context.Context, productIds []string, isDel int, status int) ([]FsProductTemplateV2, 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) FindAllByCondition(ctx context.Context, productIds []string, isDel int, status int) (resp []FsProductTemplateV2, err error) {
|
||||
query := fmt.Sprintf("select %s from %s where `id` in (?) and `is_del` = ? and `status` = ?", fsProductTemplateV2Rows, m.table)
|
||||
if err = m.conn.QueryRowsCtx(ctx, &resp, query, strings.Join(productIds, ","), isDel, status); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
||||
func (m *defaultFsProductTemplateV2Model) tableName() string {
|
||||
return m.table
|
||||
}
|
24
model/fstagsmodel.go
Executable file
24
model/fstagsmodel.go
Executable file
|
@ -0,0 +1,24 @@
|
|||
package model
|
||||
|
||||
import "github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
|
||||
var _ FsTagsModel = (*customFsTagsModel)(nil)
|
||||
|
||||
type (
|
||||
// FsTagsModel is an interface to be customized, add more methods here,
|
||||
// and implement the added methods in customFsTagsModel.
|
||||
FsTagsModel interface {
|
||||
fsTagsModel
|
||||
}
|
||||
|
||||
customFsTagsModel struct {
|
||||
*defaultFsTagsModel
|
||||
}
|
||||
)
|
||||
|
||||
// NewFsTagsModel returns a model for the database table.
|
||||
func NewFsTagsModel(conn sqlx.SqlConn) FsTagsModel {
|
||||
return &customFsTagsModel{
|
||||
defaultFsTagsModel: newFsTagsModel(conn),
|
||||
}
|
||||
}
|
93
model/fstagsmodel_gen.go
Executable file
93
model/fstagsmodel_gen.go
Executable file
|
@ -0,0 +1,93 @@
|
|||
// 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 (
|
||||
fsTagsFieldNames = builder.RawFieldNames(&FsTags{})
|
||||
fsTagsRows = strings.Join(fsTagsFieldNames, ",")
|
||||
fsTagsRowsExpectAutoSet = strings.Join(stringx.Remove(fsTagsFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
|
||||
fsTagsRowsWithPlaceHolder = strings.Join(stringx.Remove(fsTagsFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
|
||||
)
|
||||
|
||||
type (
|
||||
fsTagsModel interface {
|
||||
Insert(ctx context.Context, data *FsTags) (sql.Result, error)
|
||||
FindOne(ctx context.Context, id int64) (*FsTags, error)
|
||||
Update(ctx context.Context, data *FsTags) error
|
||||
Delete(ctx context.Context, id int64) error
|
||||
}
|
||||
|
||||
defaultFsTagsModel struct {
|
||||
conn sqlx.SqlConn
|
||||
table string
|
||||
}
|
||||
|
||||
FsTags struct {
|
||||
Id int64 `db:"id"` // ID
|
||||
Title string `db:"title"` // 标题
|
||||
Level int64 `db:"level"` // 层级、分类 1 => 二维码分类
|
||||
ClickNum int64 `db:"click_num"` // 点击次数
|
||||
Sort int64 `db:"sort"` // 排序(从大到小)
|
||||
CreateAt int64 `db:"create_at"` // 创建时间
|
||||
Icon sql.NullString `db:"icon"` // 标签图标
|
||||
Status int64 `db:"status"` // 状态 1:可用
|
||||
Description string `db:"description"` // 介绍 Seo
|
||||
RecommendProduct sql.NullString `db:"recommend_product"` // 推荐产品id例如: 1,3,4,5
|
||||
RecommendProductSort sql.NullString `db:"recommend_product_sort"` // 推荐排序例如:1324
|
||||
}
|
||||
)
|
||||
|
||||
func newFsTagsModel(conn sqlx.SqlConn) *defaultFsTagsModel {
|
||||
return &defaultFsTagsModel{
|
||||
conn: conn,
|
||||
table: "`fs_tags`",
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultFsTagsModel) 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 *defaultFsTagsModel) FindOne(ctx context.Context, id int64) (*FsTags, error) {
|
||||
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", fsTagsRows, m.table)
|
||||
var resp FsTags
|
||||
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 *defaultFsTagsModel) Insert(ctx context.Context, data *FsTags) (sql.Result, error) {
|
||||
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, fsTagsRowsExpectAutoSet)
|
||||
ret, err := m.conn.ExecCtx(ctx, query, data.Title, data.Level, data.ClickNum, data.Sort, data.Icon, data.Status, data.Description, data.RecommendProduct, data.RecommendProductSort)
|
||||
return ret, err
|
||||
}
|
||||
|
||||
func (m *defaultFsTagsModel) Update(ctx context.Context, data *FsTags) error {
|
||||
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, fsTagsRowsWithPlaceHolder)
|
||||
_, err := m.conn.ExecCtx(ctx, query, data.Title, data.Level, data.ClickNum, data.Sort, data.Icon, data.Status, data.Description, data.RecommendProduct, data.RecommendProductSort, data.Id)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *defaultFsTagsModel) tableName() string {
|
||||
return m.table
|
||||
}
|
Loading…
Reference in New Issue
Block a user