From e042cf209d4c28601c9c38cca9c3cca75c8f3127 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Sat, 7 Oct 2023 16:25:39 +0800 Subject: [PATCH] 11 --- server/shopping-cart/internal/logic/addtocartlogic.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/server/shopping-cart/internal/logic/addtocartlogic.go b/server/shopping-cart/internal/logic/addtocartlogic.go index 9b386fbf..2e28b3ef 100644 --- a/server/shopping-cart/internal/logic/addtocartlogic.go +++ b/server/shopping-cart/internal/logic/addtocartlogic.go @@ -13,6 +13,7 @@ import ( "fusenapi/utils/file" "fusenapi/utils/hash" "gorm.io/gorm" + "strings" "time" "github.com/zeromicro/go-zero/core/logx" @@ -53,9 +54,9 @@ func (l *AddToCartLogic) AddToCart(req *types.AddToCartReq, userinfo *auth.UserI if cartCount >= 100 { return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "sorry,the count of your carts can`t greater than 100") } - if req.RenderImage != "" { + //不是传路径则就是传base64 + if !strings.Contains(req.RenderImage, "https://") { //上传base64文件 - // 上传文件 var upload = file.Upload{ Ctx: l.ctx, MysqlConn: l.svcCtx.MysqlConn, @@ -270,6 +271,10 @@ func (l *AddToCartLogic) AddToCartParamVerify(req *types.AddToCartReq) error { if req.PurchaseQuantity <= 0 { return errors.New("purchase quantity can not less than 0 or equal 0") } + req.RenderImage = strings.Trim(req.RenderImage, " ") + if req.RenderImage == "" { + return errors.New("render image is required") + } return nil }