1
This commit is contained in:
parent
0ce9c3d8c2
commit
25418e7be5
|
@ -1,6 +1,6 @@
|
||||||
-- fusentest.fs_product_model definition
|
-- fusentest.fs_product_model definition
|
||||||
|
|
||||||
CREATE TABLE `fs_product_model` (
|
CREATE TABLE `fs_product_model3d` (
|
||||||
`id` int(10) NOT NULL AUTO_INCREMENT,
|
`id` int(10) NOT NULL AUTO_INCREMENT,
|
||||||
`product_id` int(10) unsigned DEFAULT NULL COMMENT '产品ID',
|
`product_id` int(10) unsigned DEFAULT NULL COMMENT '产品ID',
|
||||||
`tag` tinyint(1) NOT NULL DEFAULT '1' COMMENT '类别(1:模型,2:配件,3:场景)',
|
`tag` tinyint(1) NOT NULL DEFAULT '1' COMMENT '类别(1:模型,2:配件,3:场景)',
|
24
model/fsproductmodel3dmodel.go
Executable file
24
model/fsproductmodel3dmodel.go
Executable file
|
@ -0,0 +1,24 @@
|
||||||
|
package model
|
||||||
|
|
||||||
|
import "github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||||
|
|
||||||
|
var _ FsProductModel3dModel = (*customFsProductModel3dModel)(nil)
|
||||||
|
|
||||||
|
type (
|
||||||
|
// FsProductModel3dModel is an interface to be customized, add more methods here,
|
||||||
|
// and implement the added methods in customFsProductModel3dModel.
|
||||||
|
FsProductModel3dModel interface {
|
||||||
|
fsProductModel3dModel
|
||||||
|
}
|
||||||
|
|
||||||
|
customFsProductModel3dModel struct {
|
||||||
|
*defaultFsProductModel3dModel
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// NewFsProductModel3dModel returns a model for the database table.
|
||||||
|
func NewFsProductModel3dModel(conn sqlx.SqlConn) FsProductModel3dModel {
|
||||||
|
return &customFsProductModel3dModel{
|
||||||
|
defaultFsProductModel3dModel: newFsProductModel3dModel(conn),
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,27 +15,27 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
fsProductModelFieldNames = builder.RawFieldNames(&FsProductModel{})
|
fsProductModel3dFieldNames = builder.RawFieldNames(&FsProductModel3d{})
|
||||||
fsProductModelRows = strings.Join(fsProductModelFieldNames, ",")
|
fsProductModel3dRows = strings.Join(fsProductModel3dFieldNames, ",")
|
||||||
fsProductModelRowsExpectAutoSet = strings.Join(stringx.Remove(fsProductModelFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
|
fsProductModel3dRowsExpectAutoSet = strings.Join(stringx.Remove(fsProductModel3dFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
|
||||||
fsProductModelRowsWithPlaceHolder = strings.Join(stringx.Remove(fsProductModelFieldNames, "`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`"), "=?,") + "=?"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
fsProductModelModel interface {
|
fsProductModel3dModel interface {
|
||||||
Insert(ctx context.Context, data *FsProductModel) (sql.Result, error)
|
Insert(ctx context.Context, data *FsProductModel3d) (sql.Result, error)
|
||||||
FindOne(ctx context.Context, id int64) (*FsProductModel, error)
|
FindOne(ctx context.Context, id int64) (*FsProductModel3d, error)
|
||||||
Update(ctx context.Context, data *FsProductModel) error
|
Update(ctx context.Context, data *FsProductModel3d) error
|
||||||
Delete(ctx context.Context, id int64) error
|
Delete(ctx context.Context, id int64) error
|
||||||
ListBySizeIdsTag(ctx context.Context, sizeIds []string, tag int) ([]FsProductModel, error)
|
ListBySizeIdsTag(ctx context.Context, sizeIds []string, tag int) (resp []FsProductModel3d, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultFsProductModelModel struct {
|
defaultFsProductModel3dModel struct {
|
||||||
conn sqlx.SqlConn
|
conn sqlx.SqlConn
|
||||||
table string
|
table string
|
||||||
}
|
}
|
||||||
|
|
||||||
FsProductModel struct {
|
FsProductModel3d struct {
|
||||||
Id int64 `db:"id"`
|
Id int64 `db:"id"`
|
||||||
ProductId sql.NullInt64 `db:"product_id"` // 产品ID
|
ProductId sql.NullInt64 `db:"product_id"` // 产品ID
|
||||||
Tag int64 `db:"tag"` // 类别(1:模型,2:配件,3:场景)
|
Tag int64 `db:"tag"` // 类别(1:模型,2:配件,3:场景)
|
||||||
|
@ -57,22 +57,22 @@ type (
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func newFsProductModelModel(conn sqlx.SqlConn) *defaultFsProductModelModel {
|
func newFsProductModel3dModel(conn sqlx.SqlConn) *defaultFsProductModel3dModel {
|
||||||
return &defaultFsProductModelModel{
|
return &defaultFsProductModel3dModel{
|
||||||
conn: conn,
|
conn: conn,
|
||||||
table: "`fs_product_model`",
|
table: "`fs_product_model3d`",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *defaultFsProductModelModel) Delete(ctx context.Context, id int64) error {
|
func (m *defaultFsProductModel3dModel) Delete(ctx context.Context, id int64) error {
|
||||||
query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
|
query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
|
||||||
_, err := m.conn.ExecCtx(ctx, query, id)
|
_, err := m.conn.ExecCtx(ctx, query, id)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *defaultFsProductModelModel) FindOne(ctx context.Context, id int64) (*FsProductModel, error) {
|
func (m *defaultFsProductModel3dModel) FindOne(ctx context.Context, id int64) (*FsProductModel3d, error) {
|
||||||
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", fsProductModelRows, m.table)
|
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", fsProductModel3dRows, m.table)
|
||||||
var resp FsProductModel
|
var resp FsProductModel3d
|
||||||
err := m.conn.QueryRowCtx(ctx, &resp, query, id)
|
err := m.conn.QueryRowCtx(ctx, &resp, query, id)
|
||||||
switch err {
|
switch err {
|
||||||
case nil:
|
case nil:
|
||||||
|
@ -84,25 +84,25 @@ func (m *defaultFsProductModelModel) FindOne(ctx context.Context, id int64) (*Fs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *defaultFsProductModelModel) Insert(ctx context.Context, data *FsProductModel) (sql.Result, error) {
|
func (m *defaultFsProductModel3dModel) Insert(ctx context.Context, data *FsProductModel3d) (sql.Result, error) {
|
||||||
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, fsProductModelRowsExpectAutoSet)
|
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, fsProductModel3dRowsExpectAutoSet)
|
||||||
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)
|
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
|
return ret, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *defaultFsProductModelModel) Update(ctx context.Context, data *FsProductModel) error {
|
func (m *defaultFsProductModel3dModel) Update(ctx context.Context, data *FsProductModel3d) error {
|
||||||
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, fsProductModelRowsWithPlaceHolder)
|
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, fsProductModel3dRowsWithPlaceHolder)
|
||||||
_, 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)
|
_, 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
|
return err
|
||||||
}
|
}
|
||||||
func (m *defaultFsProductModelModel) ListBySizeIdsTag(ctx context.Context, sizeIds []string, tag int) (resp []FsProductModel, err error) {
|
func (m *defaultFsProductModel3dModel) ListBySizeIdsTag(ctx context.Context, sizeIds []string, tag int) (resp []FsProductModel3d, err error) {
|
||||||
query := fmt.Sprintf("select %s from %s where `size_id` in (?) and `tag` = ?", fsProductModelRows, m.table)
|
query := fmt.Sprintf("select %s from %s where `size_id` in (?) and `tag` = ?", fsProductModel3dRows, m.table)
|
||||||
err = m.conn.QueryRowsCtx(ctx, &resp, query, strings.Join(sizeIds, ","), tag)
|
err = m.conn.QueryRowsCtx(ctx, &resp, query, strings.Join(sizeIds, ","), tag)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
func (m *defaultFsProductModelModel) tableName() string {
|
func (m *defaultFsProductModel3dModel) tableName() string {
|
||||||
return m.table
|
return m.table
|
||||||
}
|
}
|
|
@ -1,24 +0,0 @@
|
||||||
package model
|
|
||||||
|
|
||||||
import "github.com/zeromicro/go-zero/core/stores/sqlx"
|
|
||||||
|
|
||||||
var _ FsProductModelModel = (*customFsProductModelModel)(nil)
|
|
||||||
|
|
||||||
type (
|
|
||||||
// FsProductModelModel is an interface to be customized, add more methods here,
|
|
||||||
// and implement the added methods in customFsProductModelModel.
|
|
||||||
FsProductModelModel interface {
|
|
||||||
fsProductModelModel
|
|
||||||
}
|
|
||||||
|
|
||||||
customFsProductModelModel struct {
|
|
||||||
*defaultFsProductModelModel
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
// NewFsProductModelModel returns a model for the database table.
|
|
||||||
func NewFsProductModelModel(conn sqlx.SqlConn) FsProductModelModel {
|
|
||||||
return &customFsProductModelModel{
|
|
||||||
defaultFsProductModelModel: newFsProductModelModel(conn),
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,16 +2,9 @@ package logic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"fusenapi/model"
|
|
||||||
"fusenapi/product/internal/svc"
|
"fusenapi/product/internal/svc"
|
||||||
"fusenapi/product/internal/types"
|
"fusenapi/product/internal/types"
|
||||||
"fusenapi/utils/auth"
|
"fusenapi/utils/auth"
|
||||||
"fusenapi/utils/image"
|
|
||||||
"github.com/zeromicro/go-zero/core/stores/sqlc"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -32,7 +25,7 @@ func NewGetProductInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Ge
|
||||||
// 获取产品详情
|
// 获取产品详情
|
||||||
func (l *GetProductInfoLogic) GetProductInfo(req *types.GetProductInfoReq, loginInfo auth.UserInfo) (resp *types.Response) {
|
func (l *GetProductInfoLogic) GetProductInfo(req *types.GetProductInfoReq, loginInfo auth.UserInfo) (resp *types.Response) {
|
||||||
//校验前台登录情况
|
//校验前台登录情况
|
||||||
if loginInfo.UserId == 0 {
|
/*if loginInfo.UserId == 0 {
|
||||||
return &types.Response{Code: 402, Message: "please sign in"}
|
return &types.Response{Code: 402, Message: "please sign in"}
|
||||||
}
|
}
|
||||||
req.Pid = strings.Trim(req.Pid, " ")
|
req.Pid = strings.Trim(req.Pid, " ")
|
||||||
|
@ -69,8 +62,8 @@ func (l *GetProductInfoLogic) GetProductInfo(req *types.GetProductInfoReq, login
|
||||||
sizeIds = append(sizeIds, fmt.Sprintf("%d", v.Id))
|
sizeIds = append(sizeIds, fmt.Sprintf("%d", v.Id))
|
||||||
}
|
}
|
||||||
//获取这些尺寸下的模型数据
|
//获取这些尺寸下的模型数据
|
||||||
productModelModel := model.NewFsProductModelModel(l.svcCtx.MysqlConn)
|
productModel3dModel := model.NewFsProductModel3dModel(l.svcCtx.MysqlConn)
|
||||||
models, err := productModelModel.ListBySizeIdsTag(l.ctx, sizeIds, 1)
|
models, err := productModel3dModel.ListBySizeIdsTag(l.ctx, sizeIds, 1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return &types.Response{Code: 510, Message: "failed to get product models"}
|
return &types.Response{Code: 510, Message: "failed to get product models"}
|
||||||
|
@ -90,6 +83,6 @@ func (l *GetProductInfoLogic) GetProductInfo(req *types.GetProductInfoReq, login
|
||||||
templateModelIds := make([]string, 0, len(templateV2List))
|
templateModelIds := make([]string, 0, len(templateV2List))
|
||||||
for _, v := range templateV2List {
|
for _, v := range templateV2List {
|
||||||
templateModelIds = append(templateModelIds, fmt.Sprintf("%d", v.ModelId))
|
templateModelIds = append(templateModelIds, fmt.Sprintf("%d", v.ModelId))
|
||||||
}
|
}*/
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user