Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop
This commit is contained in:
@@ -4,7 +4,9 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"fusenapi/initalize"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/check"
|
||||
"log"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -96,3 +98,31 @@ func TestMain(t *testing.T) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestCaseJSON_EXTRACT(t *testing.T) {
|
||||
|
||||
userProfile := &gmodel.UserProfile{
|
||||
FirstName: "FirstName",
|
||||
LastName: "LastName",
|
||||
Resetaurant: "Resetaurant",
|
||||
}
|
||||
metadata, err := json.Marshal(userProfile)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
updatesql := `UPDATE fusen.fs_change_code
|
||||
SET metadata = CASE
|
||||
WHEN metadata IS NULL THEN '%s'
|
||||
ELSE JSON_MERGE_PATCH(metadata, '%s')
|
||||
END
|
||||
WHERE id = ?;`
|
||||
|
||||
updatesql = fmt.Sprintf(updatesql, metadata, metadata)
|
||||
log.Println(string(updatesql))
|
||||
|
||||
conn := initalize.InitMysql("fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen")
|
||||
// err = conn.Exec(updatesql, 6).Error
|
||||
log.Println(conn.Model(&gmodel.FsChangeCode{}).Select("id").Where("id = 5").Take(nil).Error)
|
||||
log.Println(err)
|
||||
}
|
||||
|
||||
@@ -193,6 +193,7 @@ func (l *GetRecommandProductListLogic) GetRecommandProductList(req *types.GetRec
|
||||
Intro: *v.Intro,
|
||||
IsRecommend: isRecommend,
|
||||
MinPrice: minPrice,
|
||||
IsCustomization: *productInfo.IsCustomization,
|
||||
}
|
||||
if _, ok := mapTagProp[productInfo.Id]; ok {
|
||||
item.CoverDefault = mapTagProp[productInfo.Id]
|
||||
|
||||
@@ -444,6 +444,7 @@ func (l *GetTagProductListLogic) getTagProducts(req getTagProductsReq) (productL
|
||||
Recommended: *productInfo.IsRecommend > 0,
|
||||
Cover: *productInfo.Cover,
|
||||
CoverMetadata: req.MapResourceMetadata[*productInfo.Cover],
|
||||
IsCustomization: *productInfo.IsCustomization,
|
||||
}
|
||||
if _, ok = req.MapTagProp[productInfo.Id]; ok {
|
||||
item.CoverDefault = req.MapTagProp[productInfo.Id]
|
||||
|
||||
@@ -217,6 +217,7 @@ func (l *HomePageRecommendProductListLogic) HomePageRecommendProductList(req *ty
|
||||
SizeNum: uint32(sizeNum),
|
||||
MinPrice: minPrice,
|
||||
HaveOptionalFitting: haveOptionalFitting,
|
||||
IsCustomization: *productInfo.IsCustomization,
|
||||
}
|
||||
if _, ok = mapTagProp[productInfo.Id]; ok {
|
||||
item.CoverDefault = mapTagProp[productInfo.Id]
|
||||
|
||||
@@ -246,6 +246,7 @@ type GetRecommandProductListRsp struct {
|
||||
Intro string `json:"intro"`
|
||||
IsRecommend int64 `json:"is_recommend"`
|
||||
MinPrice int64 `json:"min_price"`
|
||||
IsCustomization int64 `json:"is_customization"`
|
||||
}
|
||||
|
||||
type GetTagProductListReq struct {
|
||||
@@ -281,6 +282,7 @@ type TagProduct struct {
|
||||
CoverDefault []CoverDefaultItem `json:"cover_default"`
|
||||
HaveOptionalFitting bool `json:"have_optional_fitting"`
|
||||
Recommended bool `json:"recommended"`
|
||||
IsCustomization int64 `json:"is_customization"`
|
||||
}
|
||||
|
||||
type CoverDefaultItem struct {
|
||||
@@ -409,6 +411,7 @@ type HomePageRecommendProductListRsp struct {
|
||||
MinPrice int64 `json:"min_price"`
|
||||
CoverDefault []CoverDefaultItem `json:"cover_default"`
|
||||
HaveOptionalFitting bool `json:"have_optional_fitting"`
|
||||
IsCustomization int64 `json:"is_customization"`
|
||||
}
|
||||
|
||||
type Request struct {
|
||||
|
||||
@@ -94,6 +94,22 @@ func (w *wsConnectItem) renderImage(data []byte) {
|
||||
logx.Error("invalid format of websocket render image message", err)
|
||||
return
|
||||
}
|
||||
//获取产品信息
|
||||
productInfo, err := w.logic.svcCtx.AllModels.FsProduct.FindOne(w.logic.ctx, renderImageData.RenderData.ProductId)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "该产品不存在", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
|
||||
return
|
||||
}
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "获取产品失败", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
|
||||
logx.Error(err)
|
||||
return
|
||||
}
|
||||
//不可定制
|
||||
if *productInfo.IsCustomization == 0 {
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "该产品不可定制", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
|
||||
return
|
||||
}
|
||||
//获取上传最近的logo
|
||||
userMaterial, err := w.logic.svcCtx.AllModels.FsUserMaterial.FindLatestOne(w.logic.ctx, w.userId, w.guestId)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user