fix
This commit is contained in:
parent
bbb1a845ad
commit
6a9650b9d1
|
@ -2,6 +2,13 @@ package gmodel
|
||||||
|
|
||||||
import "context"
|
import "context"
|
||||||
|
|
||||||
|
func (p *FsProductModel) FindOne(ctx context.Context, id int64) (resp FsProduct, err error) {
|
||||||
|
err = p.db.Model(&FsProduct{}).Where("`id` = ? and `is_del` =? and `is_shelf` = ? and `status` =?", id, 0, 1, 1).First(&resp).Error
|
||||||
|
if err != nil {
|
||||||
|
return FsProduct{}, err
|
||||||
|
}
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
func (p *FsProductModel) GetProductListByIds(ctx context.Context, productIds []int64, sort string) (resp []FsProduct, err error) {
|
func (p *FsProductModel) GetProductListByIds(ctx context.Context, productIds []int64, sort string) (resp []FsProduct, err error) {
|
||||||
if len(productIds) == 0 {
|
if len(productIds) == 0 {
|
||||||
return
|
return
|
||||||
|
|
|
@ -2,8 +2,17 @@ package gmodel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (d *FsProductModel3dModel) FindOne(ctx context.Context, id int64) (resp FsProductModel3d, err error) {
|
||||||
|
err = d.db.WithContext(ctx).Model(&FsProductModel3d{}).Where("`id` = ? ", id).Find(&resp).Error
|
||||||
|
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
return FsProductModel3d{}, err
|
||||||
|
}
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
func (d *FsProductModel3dModel) GetAllByIds(ctx context.Context, ids []int64) (resp []FsProductModel3d, err error) {
|
func (d *FsProductModel3dModel) GetAllByIds(ctx context.Context, ids []int64) (resp []FsProductModel3d, err error) {
|
||||||
if len(ids) == 0 {
|
if len(ids) == 0 {
|
||||||
return
|
return
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *FsProductSizeModel) FindOne(ctx context.Context, id int64) (resp FsProductSize, err error) {
|
func (s *FsProductSizeModel) FindOne(ctx context.Context, id int64) (resp FsProductSize, err error) {
|
||||||
err = s.db.WithContext(ctx).Model(&FsProductSize{}).Where("`id` = ? and `status` = ?", id, 1).First(&resp).Error
|
err = s.db.WithContext(ctx).Model(&FsProductSize{}).Where("`id` = ? ", id).First(&resp).Error
|
||||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return FsProductSize{}, err
|
return FsProductSize{}, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ func (t *FsProductTemplateV2Model) FindAllByIds(ctx context.Context, ids []int64
|
||||||
}
|
}
|
||||||
func (t *FsProductTemplateV2Model) FindOne(ctx context.Context, id int64) (resp FsProductTemplateV2, err error) {
|
func (t *FsProductTemplateV2Model) FindOne(ctx context.Context, id int64) (resp FsProductTemplateV2, err error) {
|
||||||
|
|
||||||
err = t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`id` = ? and `is_del` = ? and `status` = ?", id, 0, 1).Find(&resp).Error
|
err = t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`id` = ? ", id).Find(&resp).Error
|
||||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return FsProductTemplateV2{}, err
|
return FsProductTemplateV2{}, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package logic
|
package logic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"fusenapi/model/gmodel"
|
"fusenapi/model/gmodel"
|
||||||
"fusenapi/utils/auth"
|
"fusenapi/utils/auth"
|
||||||
"fusenapi/utils/basic"
|
"fusenapi/utils/basic"
|
||||||
|
@ -65,11 +64,27 @@ func (l *GetProductDesignLogic) GetProductDesign(req *types.GetProductDesignReq,
|
||||||
if productTemplateV2Info.Id == 0 {
|
if productTemplateV2Info.Id == 0 {
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "template info is not exists")
|
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "template info is not exists")
|
||||||
}
|
}
|
||||||
//解析json
|
//获取产品模型信息
|
||||||
var info types.ProductDesignInfo
|
productModel3dModel := gmodel.NewFsProductModel3dModel(l.svcCtx.MysqlConn)
|
||||||
if err = json.Unmarshal([]byte(*designInfo.Info), &info); err != nil {
|
model3dInfo, err := productModel3dModel.FindOne(l.ctx, *designInfo.OptionalId)
|
||||||
|
if err != nil {
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to parse design info")
|
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get product 3D model info")
|
||||||
}
|
}
|
||||||
return resp.SetStatus(basic.CodeOK)
|
if model3dInfo.Id == 0 {
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "product 3D model info is not exists")
|
||||||
|
}
|
||||||
|
optionalId := *designInfo.OptionalId
|
||||||
|
if *model3dInfo.Status == 0 && *sizeInfo.Status == 1 && *productTemplateV2Info.Status == 1 && *productTemplateV2Info.IsDel == 0 {
|
||||||
|
optionalId = 0
|
||||||
|
}
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetProductDesignRsp{
|
||||||
|
ProductId: *designInfo.ProductId,
|
||||||
|
TemplateId: *designInfo.TemplateId,
|
||||||
|
MaterialId: *designInfo.MaterialId,
|
||||||
|
SizeId: *designInfo.SizeId,
|
||||||
|
OptionalId: optionalId,
|
||||||
|
Cover: *designInfo.Cover,
|
||||||
|
Info: *designInfo.Info,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@ type PriceObj struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetProductDesignReq struct {
|
type GetProductDesignReq struct {
|
||||||
Sn string `json:"sn"`
|
Sn string `form:"sn"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetProductDesignRsp struct {
|
type GetProductDesignRsp struct {
|
||||||
|
@ -107,69 +107,7 @@ type GetProductDesignRsp struct {
|
||||||
SizeId int64 `json:"size_id"`
|
SizeId int64 `json:"size_id"`
|
||||||
OptionalId int64 `json:"optional_id"`
|
OptionalId int64 `json:"optional_id"`
|
||||||
Cover string `json:"cover"`
|
Cover string `json:"cover"`
|
||||||
Info []ProductDesignInfo `json:"info"`
|
Info string `json:"info"`
|
||||||
}
|
|
||||||
|
|
||||||
type ProductDesignInfo struct {
|
|
||||||
Id string `json:"id"`
|
|
||||||
Tag string `json:"tag"`
|
|
||||||
Title string `json:"title"`
|
|
||||||
Type string `json:"type"`
|
|
||||||
Text string `json:"text"`
|
|
||||||
Fill string `json:"fill"`
|
|
||||||
FontSize int64 `json:"fontSize"`
|
|
||||||
FontFamily string `json:"fontFamily"`
|
|
||||||
IfBr bool `json:"ifBr"`
|
|
||||||
IfShow bool `json:"ifShow"`
|
|
||||||
IfGroup bool `json:"ifGroup"`
|
|
||||||
MaxNum int64 `json:"maxNum"`
|
|
||||||
Rotation int64 `json:"rotation"`
|
|
||||||
Align string `json:"align"`
|
|
||||||
VerticalAlign string `json:"verticalAlign"`
|
|
||||||
Material string `json:"material"`
|
|
||||||
QRcodeType string `json:"QRcodeType"`
|
|
||||||
Width int64 `json:"width"`
|
|
||||||
Height int64 `json:"height"`
|
|
||||||
X int64 `json:"x"`
|
|
||||||
Y int64 `json:"y"`
|
|
||||||
Opacity int64 `json:"opacity"`
|
|
||||||
OptionalColor []OptionalColor `json:"optionalColor"`
|
|
||||||
ZIndex int64 `json:"zIndex"`
|
|
||||||
SvgPath string `json:"svgPath"`
|
|
||||||
MaterialName string `json:"materialName"`
|
|
||||||
MaterialTime string `json:"materialTime"`
|
|
||||||
Follow DesignFollow `json:"follow"`
|
|
||||||
Group []DesignGroup `json:"group"`
|
|
||||||
CameraStand CameraStand `json:"cameraStand"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type CameraStand struct {
|
|
||||||
X int64 `json:"x"`
|
|
||||||
Y int64 `json:"y"`
|
|
||||||
Z int64 `json:"z"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type DesignGroup struct {
|
|
||||||
Tag string `json:"tag"`
|
|
||||||
Text string `json:"text"`
|
|
||||||
Title string `json:"title"`
|
|
||||||
IfBr bool `json:"ifBr"`
|
|
||||||
IfGroupNoBr bool `json:"ifGroupNoBr"`
|
|
||||||
IfShow bool `json:"ifShow"`
|
|
||||||
MaxNum int64 `json:"maxNum"`
|
|
||||||
PaddingNum int64 `json:"paddingNum"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type DesignFollow struct {
|
|
||||||
Fill string `json:"fill"`
|
|
||||||
IfShow string `json:"ifShow"`
|
|
||||||
Content string `json:"content"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type OptionalColor struct {
|
|
||||||
Color string `json:"color"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
Default bool `json:"default"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Response struct {
|
type Response struct {
|
||||||
|
|
|
@ -107,7 +107,7 @@ type PriceObj {
|
||||||
|
|
||||||
//获取保存的设计信息
|
//获取保存的设计信息
|
||||||
type GetProductDesignReq {
|
type GetProductDesignReq {
|
||||||
Sn string `json:"sn"`
|
Sn string `form:"sn"`
|
||||||
}
|
}
|
||||||
type GetProductDesignRsp {
|
type GetProductDesignRsp {
|
||||||
ProductId int64 `json:"product_id"`
|
ProductId int64 `json:"product_id"`
|
||||||
|
@ -116,62 +116,5 @@ type GetProductDesignRsp {
|
||||||
SizeId int64 `json:"size_id"`
|
SizeId int64 `json:"size_id"`
|
||||||
OptionalId int64 `json:"optional_id"`
|
OptionalId int64 `json:"optional_id"`
|
||||||
Cover string `json:"cover"`
|
Cover string `json:"cover"`
|
||||||
Info []ProductDesignInfo `json:"info"`
|
Info string `json:"info"`
|
||||||
}
|
|
||||||
type ProductDesignInfo {
|
|
||||||
Id string `json:"id"`
|
|
||||||
Tag string `json:"tag"`
|
|
||||||
Title string `json:"title"`
|
|
||||||
Type string `json:"type"`
|
|
||||||
Text string `json:"text"`
|
|
||||||
Fill string `json:"fill"`
|
|
||||||
FontSize int64 `json:"fontSize"`
|
|
||||||
FontFamily string `json:"fontFamily"`
|
|
||||||
IfBr bool `json:"ifBr"`
|
|
||||||
IfShow bool `json:"ifShow"`
|
|
||||||
IfGroup bool `json:"ifGroup"`
|
|
||||||
MaxNum int64 `json:"maxNum"`
|
|
||||||
Rotation int64 `json:"rotation"`
|
|
||||||
Align string `json:"align"`
|
|
||||||
VerticalAlign string `json:"verticalAlign"`
|
|
||||||
Material string `json:"material"`
|
|
||||||
QRcodeType string `json:"QRcodeType"`
|
|
||||||
Width int64 `json:"width"`
|
|
||||||
Height int64 `json:"height"`
|
|
||||||
X int64 `json:"x"`
|
|
||||||
Y int64 `json:"y"`
|
|
||||||
Opacity int64 `json:"opacity"`
|
|
||||||
OptionalColor []OptionalColor `json:"optionalColor"`
|
|
||||||
ZIndex int64 `json:"zIndex"`
|
|
||||||
SvgPath string `json:"svgPath"`
|
|
||||||
MaterialName string `json:"materialName"`
|
|
||||||
MaterialTime string `json:"materialTime"`
|
|
||||||
Follow DesignFollow `json:"follow"`
|
|
||||||
Group []DesignGroup `json:"group"`
|
|
||||||
CameraStand CameraStand `json:"cameraStand"`
|
|
||||||
}
|
|
||||||
type CameraStand {
|
|
||||||
X int64 `json:"x"`
|
|
||||||
Y int64 `json:"y"`
|
|
||||||
Z int64 `json:"z"`
|
|
||||||
}
|
|
||||||
type DesignGroup {
|
|
||||||
Tag string `json:"tag"`
|
|
||||||
Text string `json:"text"`
|
|
||||||
Title string `json:"title"`
|
|
||||||
IfBr bool `json:"ifBr"`
|
|
||||||
IfGroupNoBr bool `json:"ifGroupNoBr"`
|
|
||||||
IfShow bool `json:"ifShow"`
|
|
||||||
MaxNum int64 `json:"maxNum"`
|
|
||||||
PaddingNum int64 `json:"paddingNum"`
|
|
||||||
}
|
|
||||||
type DesignFollow {
|
|
||||||
Fill string `json:"fill"`
|
|
||||||
IfShow string `json:"ifShow"`
|
|
||||||
Content string `json:"content"`
|
|
||||||
}
|
|
||||||
type OptionalColor {
|
|
||||||
Color string `json:"color"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
Default bool `json:"default"`
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user