From cca1ea711d55d67f08a052c73f65772ec9ea34a4 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 14:31:24 +0800 Subject: [PATCH 01/27] fix --- .../internal/logic/calculatecartpricelogic.go | 50 ++----------------- 1 file changed, 3 insertions(+), 47 deletions(-) diff --git a/server/shopping-cart/internal/logic/calculatecartpricelogic.go b/server/shopping-cart/internal/logic/calculatecartpricelogic.go index db6a4837..41e496ea 100644 --- a/server/shopping-cart/internal/logic/calculatecartpricelogic.go +++ b/server/shopping-cart/internal/logic/calculatecartpricelogic.go @@ -8,7 +8,6 @@ import ( "fusenapi/model/gmodel" "fusenapi/server/shopping-cart/internal/svc" "fusenapi/server/shopping-cart/internal/types" - "fusenapi/service/repositories" "fusenapi/utils/auth" "fusenapi/utils/basic" "fusenapi/utils/format" @@ -54,6 +53,7 @@ func (l *CalculateCartPriceLogic) CalculateCartPrice(req *types.CalculateCartPri //获取购物车列表 carts, _, err := l.svcCtx.AllModels.FsShoppingCart.GetAllCartsByParam(l.ctx, gmodel.GetAllCartsByParamReq{ Ids: cartIds, + Fields: "id,size_id,product_id,fitting_id", UserId: userinfo.UserId, Page: 1, Limit: len(cartIds), @@ -65,46 +65,6 @@ func (l *CalculateCartPriceLogic) CalculateCartPrice(req *types.CalculateCartPri if len(carts) < len(req.CalculateList) { return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "please refresh page for the shopping cart has changed!!") } - //**************获取相关数据校验变更************ - var ( - mapSize = make(map[int64]gmodel.FsProductSize) - mapModel = make(map[int64]gmodel.FsProductModel3d) - mapTemplate = make(map[int64]gmodel.FsProductTemplateV2) - mapSizePrice = make(map[string]gmodel.FsProductPrice) - mapProduct = make(map[int64]gmodel.FsProduct) - mapResourceMetadata = make(map[string]interface{}) - ) - //获取相关信息 - err = NewGetCartsLogic(l.ctx, l.svcCtx).GetRelationInfo(GetRelationInfoReq{ - Carts: carts, - MapSize: mapSize, - MapModel: mapModel, - MapTemplate: mapTemplate, - MapSizePrice: mapSizePrice, - MapProduct: mapProduct, - MapResourceMetadata: mapResourceMetadata, - }) - if err != nil { - return resp.SetStatusWithMessage(basic.CodeServiceErr, err.Error()) - } - //定义map收集变更信息 - mapCartChange := make(map[int64]string) - mapSnapshot := make(map[int64]gmodel.CartSnapshot) - //校验购物车数据是否变更 - err = l.svcCtx.Repositories.NewShoppingCart.VerifyShoppingCartSnapshotDataChange(repositories.VerifyShoppingCartSnapshotDataChangeReq{ - Carts: carts, - MapSize: mapSize, - MapModel: mapModel, - MapTemplate: mapTemplate, - MapCartChange: mapCartChange, - MapSnapshot: mapSnapshot, - MapProduct: mapProduct, - }) - if err != nil { - logx.Error("VerifyShoppingCartSnapshotDataChange err:", err.Error()) - return resp.SetStatusWithMessage(basic.CodeServiceErr, "system err:failed to check shopping cart change data") - } - //************************** sizeIds := make([]int64, 0, len(carts)) productIds := make([]int64, 0, len(carts)) fittingIds := make([]int64, 0, len(carts)) @@ -148,10 +108,6 @@ func (l *CalculateCartPriceLogic) CalculateCartPrice(req *types.CalculateCartPri } //请求的数量 reqPurchaseQuantity := mapCalculateQuantity[cart.Id].PurchaseQuantity - //传入数量是<= 0则取数据库的 - if reqPurchaseQuantity <= 0 { - reqPurchaseQuantity = *cart.PurchaseQuantity - } isSelected := int64(0) if mapCalculateQuantity[cart.Id].IsSelected { isSelected = 1 @@ -179,8 +135,8 @@ func (l *CalculateCartPriceLogic) CalculateCartPrice(req *types.CalculateCartPri updData := &gmodel.FsShoppingCart{ PurchaseQuantity: &reqPurchaseQuantity, } - //如果是没有变更且是选中则累加总价 - if _, ok = mapCartChange[cart.Id]; !ok && isSelected == 1 { + //如果是选中则累加总价 + if isSelected == 1 { subTotalPrice += totalPrice updData.IsSelected = &isSelected } From affd0dc9bb8086d86b40101e33ccc1673740bd15 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 14:41:20 +0800 Subject: [PATCH 02/27] fix --- .../internal/logic/getcartslogic.go | 21 ++----------------- server/shopping-cart/internal/types/types.go | 5 ++--- server_api/shopping-cart.api | 5 ++--- 3 files changed, 6 insertions(+), 25 deletions(-) diff --git a/server/shopping-cart/internal/logic/getcartslogic.go b/server/shopping-cart/internal/logic/getcartslogic.go index c77ac8fa..0c498c9f 100644 --- a/server/shopping-cart/internal/logic/getcartslogic.go +++ b/server/shopping-cart/internal/logic/getcartslogic.go @@ -44,23 +44,7 @@ func (l *GetCartsLogic) GetCarts(req *types.GetCartsReq, userinfo *auth.UserInfo if req.CurrentPage <= 0 { req.CurrentPage = constants.DEFAULT_PAGE } - //获取全部购物车id - allCratIds, count, err := l.svcCtx.AllModels.FsShoppingCart.GetAllCartsByParam(l.ctx, gmodel.GetAllCartsByParamReq{ - UserId: userinfo.UserId, - Fields: "id", - Sort: "id DESC", - Page: 1, - Limit: 1000, - }) - if err != nil { - logx.Error(err) - return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "system err:failed to get your shopping carts") - } - ids := make([]int64, 0, count) - for _, v := range allCratIds { - ids = append(ids, v.Id) - } - limit := 10 + limit := 300 //获取用户购物车列表 carts, total, err := l.svcCtx.AllModels.FsShoppingCart.GetAllCartsByParam(l.ctx, gmodel.GetAllCartsByParamReq{ UserId: userinfo.UserId, @@ -224,8 +208,7 @@ func (l *GetCartsLogic) GetCarts(req *types.GetCartsReq, userinfo *auth.UserInfo CurrentPage: req.CurrentPage, PerPage: limit, }, - AllCartIdArray: ids, - CartList: list, + CartList: list, }) } diff --git a/server/shopping-cart/internal/types/types.go b/server/shopping-cart/internal/types/types.go index 6ae69b01..ed87d501 100644 --- a/server/shopping-cart/internal/types/types.go +++ b/server/shopping-cart/internal/types/types.go @@ -34,9 +34,8 @@ type GetCartsReq struct { } type GetCartsRsp struct { - Meta Meta `json:"meta"` //分页信息 - AllCartIdArray []int64 `json:"all_cartId_array"` //全部购物车id(不分页) - CartList []CartItem `json:"cart_list"` + Meta Meta `json:"meta"` //分页信息 + CartList []CartItem `json:"cart_list"` } type CartItem struct { diff --git a/server_api/shopping-cart.api b/server_api/shopping-cart.api index 19ec260b..5ab4f029 100644 --- a/server_api/shopping-cart.api +++ b/server_api/shopping-cart.api @@ -52,9 +52,8 @@ type GetCartsReq { CurrentPage int `form:"current_page"` //当前页 } type GetCartsRsp { - Meta Meta `json:"meta"` //分页信息 - AllCartIdArray []int64 `json:"all_cartId_array"` //全部购物车id(不分页) - CartList []CartItem `json:"cart_list"` + Meta Meta `json:"meta"` //分页信息 + CartList []CartItem `json:"cart_list"` } type CartItem { CartId int64 `json:"cart_id"` From 6329c02b8e32f2a97af6e50877531a40ff4d1b26 Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 14:53:21 +0800 Subject: [PATCH 03/27] nacos config --- run_all_server.sh | 6 ++++-- server/info/internal/logic/infologic.go | 5 ++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/run_all_server.sh b/run_all_server.sh index c6244a3d..b76f910a 100755 --- a/run_all_server.sh +++ b/run_all_server.sh @@ -8,16 +8,18 @@ run_server() { server_name=$1 echo "Running $server_name" + + # 如果之前存在相同名字的 screen 会话,先将其终止 existing_session=$(screen -ls | grep -w "$server_name") if [ -n "$existing_session" ]; then echo "Terminating existing screen session for $server_name" screen -S "$server_name" -X quit fi - - # 导航到相应的目录 + # 导航到相应的目录 cd server/$server_name go build -linkshared + [ -f .gitignore ] || echo $server_name > .gitignore # 使用 screen 运行 go run .go screen -dmS $server_name -L ./$server_name diff --git a/server/info/internal/logic/infologic.go b/server/info/internal/logic/infologic.go index 27fc79dc..2ce5c883 100644 --- a/server/info/internal/logic/infologic.go +++ b/server/info/internal/logic/infologic.go @@ -120,13 +120,13 @@ func (l *InfoLogic) Info(req *types.UserInfoRequest, userinfo *auth.UserInfo) (r cond := fmt.Sprintf("module = '%s' and %s", moduleName, condUser) if mquery, ok := mquerys[mtable]; ok { - mquery.ModuleQuery[strings.Join(mlist[2:], ",")] = struct{}{} + mquery.ModuleQuery[strings.Join(mlist[2:], ".")] = struct{}{} } else { mquery := &ModuleQuery{ TableName: tname, ModuleName: mtable + "." + moduleName, Cond: cond, - ModuleQuery: map[string]struct{}{strings.Join(mlist[2:], ","): {}}} + ModuleQuery: map[string]struct{}{strings.Join(mlist[2:], "."): {}}} mquerys[mtable] = mquery } } @@ -134,7 +134,6 @@ func (l *InfoLogic) Info(req *types.UserInfoRequest, userinfo *auth.UserInfo) (r for _, mquery := range mquerys { sqlstr := fmt.Sprintf("select id, module, %s as querydata from %s where %s order by ctime DESC limit 1", mquery.EncodeQuery("metadata"), mquery.TableName, mquery.Cond) - raw := l.svcCtx.MysqlConn.Raw(sqlstr) if raw.Error != nil { From c54f804ebf7eee97e95aee56f417eec10d5aa000 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 14:55:23 +0800 Subject: [PATCH 04/27] fix --- server/shopping-cart/internal/logic/getcartslogic.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/shopping-cart/internal/logic/getcartslogic.go b/server/shopping-cart/internal/logic/getcartslogic.go index 0c498c9f..96a53135 100644 --- a/server/shopping-cart/internal/logic/getcartslogic.go +++ b/server/shopping-cart/internal/logic/getcartslogic.go @@ -132,15 +132,16 @@ func (l *GetCartsLogic) GetCarts(req *types.GetCartsReq, userinfo *auth.UserInfo stepQuantityList := make([]int64, 0, 20) tmpMinBuyNum := *sizePrice.MinBuyNum for tmpMinBuyNum < (int64(stepNum[len(stepNum)-1]) + 5) { - //阶梯数 tmpQuantity := tmpMinBuyNum * (*sizePrice.EachBoxNum) stepQuantityList = append(stepQuantityList, tmpQuantity) tmpMinBuyNum++ } + //尺寸信息 sizeCapacity := snapShot.SizeInfo.Capacity if sizeInfo, ok := mapSize[*cart.SizeId]; ok { sizeCapacity = *sizeInfo.Capacity } + //配件信息 fittingName := snapShot.FittingInfo.FittingName if fittingInfo, ok := mapModel[*cart.FittingId]; ok { fittingName = *fittingInfo.Name @@ -148,7 +149,9 @@ func (l *GetCartsLogic) GetCarts(req *types.GetCartsReq, userinfo *auth.UserInfo productCover := "" //产品封面图 productName := snapShot.ProductInfo.ProductName productSn := snapShot.ProductInfo.ProductSn + //产品封面图资源元数据 var productCoverMetadata interface{} + //产品信息 if productInfo, ok := mapProduct[*cart.ProductId]; ok { productCover = *productInfo.Cover productName = *productInfo.Title From e87dd4f80082c9bc0350fa07552088ded2afc23f Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 15:40:56 +0800 Subject: [PATCH 05/27] fix --- .../internal/logic/getcartslogic.go | 23 ++++++---------- server/shopping-cart/internal/types/types.go | 27 ++++++++++--------- server_api/shopping-cart.api | 27 ++++++++++--------- 3 files changed, 36 insertions(+), 41 deletions(-) diff --git a/server/shopping-cart/internal/logic/getcartslogic.go b/server/shopping-cart/internal/logic/getcartslogic.go index 96a53135..c0b3fe7d 100644 --- a/server/shopping-cart/internal/logic/getcartslogic.go +++ b/server/shopping-cart/internal/logic/getcartslogic.go @@ -123,19 +123,11 @@ func (l *GetCartsLogic) GetCarts(req *types.GetCartsReq, userinfo *auth.UserInfo } } //计算价格 - itemPrice, totalPrice, stepNum, _, err := l.svcCtx.Repositories.NewShoppingCart.CaculateCartPrice(*cart.PurchaseQuantity, &sizePrice, fittingPrice) + itemPrice, totalPrice, _, _, err := l.svcCtx.Repositories.NewShoppingCart.CaculateCartPrice(*cart.PurchaseQuantity, &sizePrice, fittingPrice) if err != nil { logx.Error(err) return resp.SetStatusWithMessage(basic.CodeServiceErr, err.Error()) } - //获取阶梯数量 - stepQuantityList := make([]int64, 0, 20) - tmpMinBuyNum := *sizePrice.MinBuyNum - for tmpMinBuyNum < (int64(stepNum[len(stepNum)-1]) + 5) { - tmpQuantity := tmpMinBuyNum * (*sizePrice.EachBoxNum) - stepQuantityList = append(stepQuantityList, tmpQuantity) - tmpMinBuyNum++ - } //尺寸信息 sizeCapacity := snapShot.SizeInfo.Capacity if sizeInfo, ok := mapSize[*cart.SizeId]; ok { @@ -190,12 +182,13 @@ func (l *GetCartsLogic) GetCarts(req *types.GetCartsReq, userinfo *auth.UserInfo Qrcode: snapShot.UserDiyInformation.Qrcode, Slogan: snapShot.UserDiyInformation.Slogan, }, - PurchaseQuantity: *cart.PurchaseQuantity, - StepNum: stepQuantityList, - IsInvalid: false, - InvalidDescription: "", - IsHighlyCustomized: *cart.IsHighlyCustomized > 0, - IsSelected: *cart.IsSelected > 0, + PurchaseQuantity: *cart.PurchaseQuantity, + MinPurchaseQuantity: *sizePrice.EachBoxNum * (*sizePrice.MinBuyNum), + StepPurchaseQuantity: *sizePrice.EachBoxNum, + IsInvalid: false, + InvalidDescription: "", + IsHighlyCustomized: *cart.IsHighlyCustomized > 0, + IsSelected: *cart.IsSelected > 0, } //是否有失效的 if description, ok := mapCartChange[cart.Id]; ok { diff --git a/server/shopping-cart/internal/types/types.go b/server/shopping-cart/internal/types/types.go index ed87d501..b30ae342 100644 --- a/server/shopping-cart/internal/types/types.go +++ b/server/shopping-cart/internal/types/types.go @@ -39,19 +39,20 @@ type GetCartsRsp struct { } type CartItem struct { - CartId int64 `json:"cart_id"` - ProductInfo ProductInfo `json:"product_info"` //产品信息 - SizeInfo SizeInfo `json:"size_info"` //尺寸信息 - FittingInfo FittingInfo `json:"fitting_info"` //配件信息 - ItemPrice string `json:"item_price"` //单价 - TotalPrice string `json:"total_price"` //单价X数量=总价 - DiyInformation DiyInformation `json:"diy_information"` //diy信息 - StepNum []int64 `json:"step_num"` //阶梯数量 - PurchaseQuantity int64 `json:"purchase_quantity"` //当前购买数量 - IsHighlyCustomized bool `json:"is_highly_customized"` //是否高度定制 - IsInvalid bool `json:"is_invalid"` //是否无效 - InvalidDescription string `json:"invalid_description"` //无效原因 - IsSelected bool `json:"is_selected"` //是否选中 + CartId int64 `json:"cart_id"` + ProductInfo ProductInfo `json:"product_info"` //产品信息 + SizeInfo SizeInfo `json:"size_info"` //尺寸信息 + FittingInfo FittingInfo `json:"fitting_info"` //配件信息 + ItemPrice string `json:"item_price"` //单价 + TotalPrice string `json:"total_price"` //单价X数量=总价 + DiyInformation DiyInformation `json:"diy_information"` //diy信息 + PurchaseQuantity int64 `json:"purchase_quantity"` //当前购买数量 + MinPurchaseQuantity int64 `json:"min_purchase_quantity"` //起购数量 + StepPurchaseQuantity int64 `json:"step_purchase_quantity"` //购买加或者减少步进量 + IsHighlyCustomized bool `json:"is_highly_customized"` //是否高度定制 + IsInvalid bool `json:"is_invalid"` //是否无效 + InvalidDescription string `json:"invalid_description"` //无效原因 + IsSelected bool `json:"is_selected"` //是否选中 } type ProductInfo struct { diff --git a/server_api/shopping-cart.api b/server_api/shopping-cart.api index 5ab4f029..5b73ac76 100644 --- a/server_api/shopping-cart.api +++ b/server_api/shopping-cart.api @@ -56,19 +56,20 @@ type GetCartsRsp { CartList []CartItem `json:"cart_list"` } type CartItem { - CartId int64 `json:"cart_id"` - ProductInfo ProductInfo `json:"product_info"` //产品信息 - SizeInfo SizeInfo `json:"size_info"` //尺寸信息 - FittingInfo FittingInfo `json:"fitting_info"` //配件信息 - ItemPrice string `json:"item_price"` //单价 - TotalPrice string `json:"total_price"` //单价X数量=总价 - DiyInformation DiyInformation `json:"diy_information"` //diy信息 - StepNum []int64 `json:"step_num"` //阶梯数量 - PurchaseQuantity int64 `json:"purchase_quantity"` //当前购买数量 - IsHighlyCustomized bool `json:"is_highly_customized"` //是否高度定制 - IsInvalid bool `json:"is_invalid"` //是否无效 - InvalidDescription string `json:"invalid_description"` //无效原因 - IsSelected bool `json:"is_selected"` //是否选中 + CartId int64 `json:"cart_id"` + ProductInfo ProductInfo `json:"product_info"` //产品信息 + SizeInfo SizeInfo `json:"size_info"` //尺寸信息 + FittingInfo FittingInfo `json:"fitting_info"` //配件信息 + ItemPrice string `json:"item_price"` //单价 + TotalPrice string `json:"total_price"` //单价X数量=总价 + DiyInformation DiyInformation `json:"diy_information"` //diy信息 + PurchaseQuantity int64 `json:"purchase_quantity"` //当前购买数量 + MinPurchaseQuantity int64 `json:"min_purchase_quantity"` //起购数量 + StepPurchaseQuantity int64 `json:"step_purchase_quantity"` //购买加或者减少步进量 + IsHighlyCustomized bool `json:"is_highly_customized"` //是否高度定制 + IsInvalid bool `json:"is_invalid"` //是否无效 + InvalidDescription string `json:"invalid_description"` //无效原因 + IsSelected bool `json:"is_selected"` //是否选中 } type ProductInfo { ProductId int64 `json:"product_id"` //产品id From 15b278f78286cff7cd12843c66db8956ba5c9d00 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 15:57:01 +0800 Subject: [PATCH 06/27] fix --- server/shopping-cart/internal/logic/calculatecartpricelogic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/shopping-cart/internal/logic/calculatecartpricelogic.go b/server/shopping-cart/internal/logic/calculatecartpricelogic.go index 41e496ea..81772b57 100644 --- a/server/shopping-cart/internal/logic/calculatecartpricelogic.go +++ b/server/shopping-cart/internal/logic/calculatecartpricelogic.go @@ -134,11 +134,11 @@ func (l *CalculateCartPriceLogic) CalculateCartPrice(req *types.CalculateCartPri }) updData := &gmodel.FsShoppingCart{ PurchaseQuantity: &reqPurchaseQuantity, + IsSelected: &isSelected, } //如果是选中则累加总价 if isSelected == 1 { subTotalPrice += totalPrice - updData.IsSelected = &isSelected } //更新购物车购买数量 if err = shoppingCartModel.Update(l.ctx, cart.Id, userinfo.UserId, updData); err != nil { From 82e510194879676f522ba4a94cff2c6ac28652d2 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 16:10:49 +0800 Subject: [PATCH 07/27] fix --- server/shopping-cart/internal/logic/getcartslogic.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/shopping-cart/internal/logic/getcartslogic.go b/server/shopping-cart/internal/logic/getcartslogic.go index c0b3fe7d..290740a0 100644 --- a/server/shopping-cart/internal/logic/getcartslogic.go +++ b/server/shopping-cart/internal/logic/getcartslogic.go @@ -185,8 +185,6 @@ func (l *GetCartsLogic) GetCarts(req *types.GetCartsReq, userinfo *auth.UserInfo PurchaseQuantity: *cart.PurchaseQuantity, MinPurchaseQuantity: *sizePrice.EachBoxNum * (*sizePrice.MinBuyNum), StepPurchaseQuantity: *sizePrice.EachBoxNum, - IsInvalid: false, - InvalidDescription: "", IsHighlyCustomized: *cart.IsHighlyCustomized > 0, IsSelected: *cart.IsSelected > 0, } @@ -194,6 +192,8 @@ func (l *GetCartsLogic) GetCarts(req *types.GetCartsReq, userinfo *auth.UserInfo if description, ok := mapCartChange[cart.Id]; ok { item.IsInvalid = true item.InvalidDescription = description + //失效了返回给前端也是不选中 + item.IsSelected = false } list = append(list, item) } From c06e5da01cacd8210565c6782748820a5959235e Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 16:48:09 +0800 Subject: [PATCH 08/27] fix --- server/websocket/internal/logic/ws_render_image.go | 1 + 1 file changed, 1 insertion(+) diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go index f1ac5270..67e48c9b 100644 --- a/server/websocket/internal/logic/ws_render_image.go +++ b/server/websocket/internal/logic/ws_render_image.go @@ -152,6 +152,7 @@ func (w *wsConnectItem) renderImage(data []byte) { renderImageData.RenderData.Slogan = templateSwitchInfo.MaterialData.Slogan.DefaultValue } }*/ + w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "暂停维护,请稍后", 0, 0, 0, 0, 0, 0, 0) //获取刀版图 combineReq := repositories.LogoCombineReq{ UserId: renderImageData.RenderData.UserId, From 93a69414321e77dcb6d09d0e5fe83ca64b8ee95f Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 16:54:49 +0800 Subject: [PATCH 09/27] fix --- server/websocket/internal/logic/ws_render_image.go | 1 + 1 file changed, 1 insertion(+) diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go index 67e48c9b..1eef99b9 100644 --- a/server/websocket/internal/logic/ws_render_image.go +++ b/server/websocket/internal/logic/ws_render_image.go @@ -153,6 +153,7 @@ func (w *wsConnectItem) renderImage(data []byte) { } }*/ w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "暂停维护,请稍后", 0, 0, 0, 0, 0, 0, 0) + return //获取刀版图 combineReq := repositories.LogoCombineReq{ UserId: renderImageData.RenderData.UserId, From b230d764e0d7fbad9e43bdba575cc1bb13ef4a2b Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 16:58:37 +0800 Subject: [PATCH 10/27] fix --- server/websocket/internal/logic/ws_render_image.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go index 1eef99b9..f1ac5270 100644 --- a/server/websocket/internal/logic/ws_render_image.go +++ b/server/websocket/internal/logic/ws_render_image.go @@ -152,8 +152,6 @@ func (w *wsConnectItem) renderImage(data []byte) { renderImageData.RenderData.Slogan = templateSwitchInfo.MaterialData.Slogan.DefaultValue } }*/ - w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "暂停维护,请稍后", 0, 0, 0, 0, 0, 0, 0) - return //获取刀版图 combineReq := repositories.LogoCombineReq{ UserId: renderImageData.RenderData.UserId, From f7c0d90ab3e6332d5a5e30e0eab1d8cfc0621b7b Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 17:06:12 +0800 Subject: [PATCH 11/27] fix --- server/websocket/internal/logic/datatransferlogic.go | 10 ++-------- server/websocket/internal/logic/ws_render_image.go | 4 +--- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index ca5d3bb9..974e3bf6 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -67,9 +67,9 @@ var ( //websocket连接存储 mapConnPool = sync.Map{} //每个websocket连接入口缓冲队列长度默认值 - websocketInChanLen = 500 + websocketInChanLen = 50 //每个websocket连接出口缓冲队列长度默认值 - websocketOutChanLen = 500 + websocketOutChanLen = 50 //是否开启debug openDebug = true //允许跨域的origin @@ -400,9 +400,6 @@ func (w *wsConnectItem) sendToOutChan(data []byte) { return case w.outChan <- data: return - case <-time.After(time.Millisecond * 50): //阻塞超过50ms丢弃 - logx.Error("failed to send to out chan,time expired,data:", string(data)) - return } } @@ -413,9 +410,6 @@ func (w *wsConnectItem) sendToInChan(data []byte) { return case w.inChan <- data: return - case <-time.After(time.Millisecond * 200): //200豪秒超时丢弃,说明超过消费速度了 - w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_INCOME_CACHE_QUEUE_OVERFLOW, "send message is too frequent,the message is ignore by system:"+string(data))) - return } } diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go index f1ac5270..41f6e070 100644 --- a/server/websocket/internal/logic/ws_render_image.go +++ b/server/websocket/internal/logic/ws_render_image.go @@ -21,7 +21,7 @@ import ( var ( //每个websocket渲染任务缓冲队列长度默认值 - renderChanLen = 500 + renderChanLen = 20 ) // 渲染处理器 @@ -42,8 +42,6 @@ func (r *renderProcessor) allocationMessage(w *wsConnectItem, data []byte) { return case w.extendRenderProperty.renderChan <- data: //发入到缓冲队列 return - case <-time.After(time.Second * 3): //三秒没进入缓冲队列就丢弃 - return } } From bcbcf0a4b25f8329ad19b296b5f18a5dd376f412 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 17:08:04 +0800 Subject: [PATCH 12/27] fix --- server/websocket/internal/logic/commonnotifylogic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/websocket/internal/logic/commonnotifylogic.go b/server/websocket/internal/logic/commonnotifylogic.go index c42af9eb..f7ec9b0c 100644 --- a/server/websocket/internal/logic/commonnotifylogic.go +++ b/server/websocket/internal/logic/commonnotifylogic.go @@ -28,7 +28,7 @@ func NewCommonNotifyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Comm } // 定义公共回调未找到websocket连接时暂存数据缓冲队列 -var commonConnectionNotFoundDataCacheChan = make(chan commonConnectionNotFoundDataCacheChanItem, 2000) +var commonConnectionNotFoundDataCacheChan = make(chan commonConnectionNotFoundDataCacheChanItem, 100) type commonConnectionNotFoundDataCacheChanItem struct { retryTimes int //重回队列次数 From 8a908a4438a1263f110c36f04eaa69ce28ecd11b Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 17:10:56 +0800 Subject: [PATCH 13/27] fix --- server/websocket/internal/logic/ws_render_image.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go index 41f6e070..36a92f8d 100644 --- a/server/websocket/internal/logic/ws_render_image.go +++ b/server/websocket/internal/logic/ws_render_image.go @@ -36,7 +36,7 @@ type extendRenderProperty struct { // 处理分发到这里的数据 func (r *renderProcessor) allocationMessage(w *wsConnectItem, data []byte) { - //logx.Info("收到渲染任务消息:", string(data)) + logx.Info("开始处理渲染任务消息:", string(data)) select { case <-w.closeChan: //已经关闭 return From e86a8072a5341add52f4c563aca6d034d76977da Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 17:13:31 +0800 Subject: [PATCH 14/27] fix --- server/websocket/internal/logic/datatransferlogic.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index 974e3bf6..bfa2321d 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -164,8 +164,6 @@ func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request) go ws.consumeOutChanData() //消费入口数据 go ws.consumeInChanData() - //操作连接中渲染任务的增加/删除 - //go ws.operationRenderTask() //消费渲染缓冲队列 go ws.consumeRenderImageData() //心跳 From 0885c645c3c30275f148904f9ee02a3c44c072eb Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 17:22:22 +0800 Subject: [PATCH 15/27] fix --- server/websocket/internal/logic/ws_render_image.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go index 36a92f8d..7dcb0863 100644 --- a/server/websocket/internal/logic/ws_render_image.go +++ b/server/websocket/internal/logic/ws_render_image.go @@ -36,7 +36,7 @@ type extendRenderProperty struct { // 处理分发到这里的数据 func (r *renderProcessor) allocationMessage(w *wsConnectItem, data []byte) { - logx.Info("开始处理渲染任务消息:", string(data)) + //logx.Info("开始处理渲染任务消息:", string(data)) select { case <-w.closeChan: //已经关闭 return From 5db1f3f09d2bb7de0dd093f6ae660d596ba6e304 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 17:56:48 +0800 Subject: [PATCH 16/27] fix --- .../internal/logic/commonnotifylogic.go | 4 +--- .../internal/logic/datatransferlogic.go | 7 +++---- .../websocket/internal/logic/ws_render_image.go | 16 +++++----------- .../internal/logic/ws_user_connect_pool.go | 7 ------- 4 files changed, 9 insertions(+), 25 deletions(-) diff --git a/server/websocket/internal/logic/commonnotifylogic.go b/server/websocket/internal/logic/commonnotifylogic.go index f7ec9b0c..ea961822 100644 --- a/server/websocket/internal/logic/commonnotifylogic.go +++ b/server/websocket/internal/logic/commonnotifylogic.go @@ -28,7 +28,7 @@ func NewCommonNotifyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Comm } // 定义公共回调未找到websocket连接时暂存数据缓冲队列 -var commonConnectionNotFoundDataCacheChan = make(chan commonConnectionNotFoundDataCacheChanItem, 100) +var commonConnectionNotFoundDataCacheChan = make(chan commonConnectionNotFoundDataCacheChanItem, 2000) type commonConnectionNotFoundDataCacheChanItem struct { retryTimes int //重回队列次数 @@ -40,8 +40,6 @@ func pushCommonNotifyCache(data commonConnectionNotFoundDataCacheChanItem) { select { case commonConnectionNotFoundDataCacheChan <- data: return - case <-time.After(time.Millisecond * 50): //超50ms就丢弃 - return } } diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index bfa2321d..fa7a9258 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -67,9 +67,9 @@ var ( //websocket连接存储 mapConnPool = sync.Map{} //每个websocket连接入口缓冲队列长度默认值 - websocketInChanLen = 50 + websocketInChanLen = 500 //每个websocket连接出口缓冲队列长度默认值 - websocketOutChanLen = 50 + websocketOutChanLen = 500 //是否开启debug openDebug = true //允许跨域的origin @@ -192,8 +192,7 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo *auth.Use userId: userInfo.UserId, guestId: userInfo.GuestId, extendRenderProperty: extendRenderProperty{ - renderChan: make(chan []byte, renderChanLen), - renderConsumeTickTime: 1, //默认1纳秒,后面需要根据不同用户不同触发速度 + renderChan: make(chan []byte, renderChanLen), }, } //保存连接 diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go index 7dcb0863..3d9ad20a 100644 --- a/server/websocket/internal/logic/ws_render_image.go +++ b/server/websocket/internal/logic/ws_render_image.go @@ -21,7 +21,7 @@ import ( var ( //每个websocket渲染任务缓冲队列长度默认值 - renderChanLen = 20 + renderChanLen = 200 ) // 渲染处理器 @@ -30,8 +30,7 @@ type renderProcessor struct { // 云渲染属性 type extendRenderProperty struct { - renderChan chan []byte //渲染消息入口的缓冲队列 - renderConsumeTickTime time.Duration //消费渲染消息时钟间隔(纳秒),用于后期控制不同类型用户渲染速度限制 + renderChan chan []byte //渲染消息入口的缓冲队列 } // 处理分发到这里的数据 @@ -52,18 +51,13 @@ func (w *wsConnectItem) consumeRenderImageData() { logx.Error("func renderImage err:", err) } }() - var duration time.Duration = 1 - if w.extendRenderProperty.renderConsumeTickTime > 0 { - duration = w.extendRenderProperty.renderConsumeTickTime - } - ticker := time.NewTicker(duration) - defer ticker.Stop() + var data []byte for { select { case <-w.closeChan: //已关闭 return - case <-ticker.C: //消费数据 - w.renderImage(<-w.extendRenderProperty.renderChan) + case data = <-w.extendRenderProperty.renderChan: //消费数据 + w.renderImage(data) } } } diff --git a/server/websocket/internal/logic/ws_user_connect_pool.go b/server/websocket/internal/logic/ws_user_connect_pool.go index 265e6490..8f02bb1d 100644 --- a/server/websocket/internal/logic/ws_user_connect_pool.go +++ b/server/websocket/internal/logic/ws_user_connect_pool.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "github.com/zeromicro/go-zero/core/logx" - "time" ) var ( @@ -30,8 +29,6 @@ func createUserConnPoolElement(userId, guestId int64, uniqueId string) { select { case userConnPoolCtlChan <- data: return - case <-time.After(time.Millisecond * 200): - return } } @@ -51,8 +48,6 @@ func deleteUserConnPoolElement(userId, guestId int64, uniqueId string) { select { case userConnPoolCtlChan <- data: return - case <-time.After(time.Millisecond * 200): - return } } @@ -68,8 +63,6 @@ func sendToOutChanByUserIndex(userId, guestId int64, message []byte) { select { case userConnPoolCtlChan <- data: return - case <-time.After(time.Millisecond * 200): - return } } From 11cdcefa4c77a2778077c3735e526b708abb0be3 Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 18:12:22 +0800 Subject: [PATCH 17/27] nacos config --- go.mod | 2 +- go.sum | 22 +++++ model/gmodel/fs_user_logic.go | 3 +- server/info/internal/logic/infologic.go | 1 + server/info/internal/logic/infologic_test.go | 90 +++++++++++++++++--- utils/check/check.go | 2 +- utils/fssql/metadata.go | 3 +- 7 files changed, 105 insertions(+), 18 deletions(-) diff --git a/go.mod b/go.mod index 8bf4cb92..386905b4 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module fusenapi -go 1.20 +go 1.21 require ( github.com/474420502/passer v0.0.1 diff --git a/go.sum b/go.sum index 06dd5c40..71417c7e 100644 --- a/go.sum +++ b/go.sum @@ -38,6 +38,7 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7 github.com/474420502/passer v0.0.1 h1:ZWnt7hpFzsYDV7LHSEyLvLUvW5mRxrnDmgFdIl17q3w= github.com/474420502/passer v0.0.1/go.mod h1:MmnnrF9d51sPkFzdRq2pQtxQKqyjburVM1LjMbOCezE= github.com/474420502/random v0.4.1 h1:HUUyLXRWMijVb7CJoEC16f0aFQOW25Lkr80Mut6PoKU= +github.com/474420502/random v0.4.1/go.mod h1:Kq5VC8ezVvzp9CUahvebIdlSiFdHzEzscaOScLvbw2c= github.com/474420502/requests v1.42.0 h1:aUj0rWhfldbOOlGHDIcqT9zgXEoSlK4IBmRF3LxI1+Y= github.com/474420502/requests v1.42.0/go.mod h1:2SCVzim0ONFYG09g/GrM7RTeJIC6qTyZfnohsjnG5C8= github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= @@ -49,6 +50,7 @@ github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53/go.mod h1:+3 github.com/CloudyKit/jet v2.1.3-0.20180809161101-62edd43e4f88+incompatible/go.mod h1:HPYO+50pSWkPoj9Q/eq0aRGByCL6ScRlUmiEX5Zgm+w= github.com/CloudyKit/jet/v3 v3.0.0/go.mod h1:HKQPgSJmdK8hdoAbKUUWajkHyHo4RaU5rMdUywE7VMo= github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= +github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ= github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= @@ -69,7 +71,9 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a h1:HbKu58rmZpUGpz5+4FfNmIU+FmZg2P3Xaj2v2bfNWmk= +github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc= github.com/alicebob/miniredis/v2 v2.30.4 h1:8S4/o1/KoUArAGbGwPxcwf0krlzceva2XVOSchFS7Eo= +github.com/alicebob/miniredis/v2 v2.30.4/go.mod h1:b25qWj4fCEsBeAAR2mlb0ufImGC6uH3VlUfb/HS5zKg= github.com/aliyun/alibaba-cloud-sdk-go v1.61.1704 h1:PpfENOj/vPfhhy9N2OFRjpue0hjM5XqAp2thFmkXXIk= github.com/aliyun/alibaba-cloud-sdk-go v1.61.1704/go.mod h1:RcDobYh8k5VP6TNybz9m++gL3ijVI5wueVr0EM10VsU= github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= @@ -83,6 +87,7 @@ github.com/aws/aws-sdk-go v1.44.295 h1:SGjU1+MqttXfRiWHD6WU0DRhaanJgAFY+xIhEaugV github.com/aws/aws-sdk-go v1.44.295/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= +github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -147,6 +152,7 @@ github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44am github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385/go.mod h1:0vRUJqYpeSZifjYj7uP3BG/gKcuzL9xWVV/Y+cK33KM= github.com/elazarl/goproxy v0.0.0-20210801061803-8e322dfb79c4 h1:lS3P5Nw3oPO05Lk2gFiYUOL3QPaH+fRoI1wFOc4G1UY= +github.com/elazarl/goproxy v0.0.0-20210801061803-8e322dfb79c4/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -217,6 +223,7 @@ github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGw github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= github.com/golang/glog v1.1.0 h1:/d3pCKDPWNnvIWe0vVUpNP32qc8U3PDVxySP/y360qE= +github.com/golang/glog v1.1.0/go.mod h1:pfYeQZ3JWZoXTV5sFc986z3HTpwQs9At6P4ImfuP3NQ= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -265,6 +272,7 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= @@ -294,6 +302,7 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0/go.mod h1:hgWBS7lorOAVIJEQMi4Zs github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0 h1:1JYBfzqrWPcCclBwxFCPAou9n+q86mfnu7NAeHfte7A= github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0/go.mod h1:YDZoGHuwE+ov0c8smSH49WLF3F2LaWnYYuDVd+EWrc0= github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw= +github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -313,6 +322,7 @@ github.com/hashicorp/go-sockaddr v1.0.0 h1:GeH6tui99pF4NJgfnhp+L6+FfobzVW3Ah46sL github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= +github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= @@ -413,6 +423,7 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/ github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= +github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= @@ -447,14 +458,17 @@ github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.13.0/go.mod h1:+REjRxOmWfHCjfv9TTWB1jD1Frx4XydAD3zm1lskyM0= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= +github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= +github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs= github.com/openzipkin/zipkin-go v0.4.1 h1:kNd/ST2yLLWhaWrkgchya40TJabe8Hioj9udfPcEO5A= github.com/openzipkin/zipkin-go v0.4.1/go.mod h1:qY0VqDSN1pOBN94dBc6w2GJlWLiovAyg7Qt6/I9HecM= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= @@ -475,6 +489,7 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g= +github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= @@ -496,6 +511,7 @@ github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+Gx github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+PymziUAg= github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= +github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= @@ -586,6 +602,7 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yuin/gopher-lua v1.1.0 h1:BojcDhfyDWgU2f2TOzYK/g5p2gxMrku8oupLDqlnSqE= +github.com/yuin/gopher-lua v1.1.0/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw= github.com/zeromicro/go-zero v1.5.4 h1:kRvcYuxcHOkUZvg7887KQl77Qv4klGL7MqGkTBgkpS8= github.com/zeromicro/go-zero v1.5.4/go.mod h1:x/aUyLmSwRECvOyjOf+lhwThBOilJIY+s3slmPAeboA= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= @@ -621,6 +638,7 @@ go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0 go.uber.org/automaxprocs v1.5.2 h1:2LxUOGiR3O6tw8ui5sZa2LAaHnsviZdVOUZw4fvbnME= go.uber.org/automaxprocs v1.5.2/go.mod h1:eRbA25aqJrxAbsLO0xy5jVwPt7FQnRgjW+efnwa1WM0= go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= +go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4= go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= @@ -990,12 +1008,15 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/cheggaaa/pb.v1 v1.0.28 h1:n1tBJnnK2r7g9OW2btFH91V92STTUevLXYFb8gy9EMk= +gopkg.in/cheggaaa/pb.v1 v1.0.28/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y= gopkg.in/h2non/gock.v1 v1.1.2 h1:jBbHXgGBK/AoPVfJh5x4r/WxIrElvbLel8TCZkkZJoY= +gopkg.in/h2non/gock.v1 v1.1.2/go.mod h1:n7UGz/ckNChHiK05rDoiC4MYSunEC/lyaUm2WWaDva0= gopkg.in/ini.v1 v1.51.1/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.66.2 h1:XfR1dOYubytKy4Shzc2LHrrGhU0lDCfDGG1yLPmpgsI= gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= @@ -1030,6 +1051,7 @@ honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= k8s.io/utils v0.0.0-20230209194617-a36077c30491 h1:r0BAOLElQnnFhE/ApUsg3iHdVYYPBjNSSOMowRZxxsY= +k8s.io/utils v0.0.0-20230209194617-a36077c30491/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= diff --git a/model/gmodel/fs_user_logic.go b/model/gmodel/fs_user_logic.go index 596c6b13..c4478a90 100644 --- a/model/gmodel/fs_user_logic.go +++ b/model/gmodel/fs_user_logic.go @@ -216,7 +216,7 @@ func (u *FsUserModel) RegisterByFusen(ctx context.Context, token *auth.RegisterT err = txUserInfo.Where("module = 'profile' and user_id = ?", uinfo.UserId).Take(nil).Error // txUserInfo.Statement.Table - + logx.Error(err, "找到user_id1") if err != nil { if err == gorm.ErrRecordNotFound { err = txUserInfo.Create(uinfo).Error @@ -225,6 +225,7 @@ func (u *FsUserModel) RegisterByFusen(ctx context.Context, token *auth.RegisterT } } } else { + logx.Error("找到user_id2") err = fssql.MetadataModulePATCH(txUserInfo, "profile", FsUserInfo{}, metadata, "user_id = ?", *uinfo.UserId) if err != nil { return err diff --git a/server/info/internal/logic/infologic.go b/server/info/internal/logic/infologic.go index 2ce5c883..41bc7a91 100644 --- a/server/info/internal/logic/infologic.go +++ b/server/info/internal/logic/infologic.go @@ -86,6 +86,7 @@ func (l *InfoLogic) Info(req *types.UserInfoRequest, userinfo *auth.UserInfo) (r // 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data) // userinfo 传入值时, 一定不为null + //TODO: 可以优化, 合并模块 var condUser string switch userinfo.GetIdType() { case auth.IDTYPE_User: diff --git a/server/info/internal/logic/infologic_test.go b/server/info/internal/logic/infologic_test.go index 11bad8a8..c6b32168 100644 --- a/server/info/internal/logic/infologic_test.go +++ b/server/info/internal/logic/infologic_test.go @@ -17,46 +17,57 @@ import ( func TestMain(t *testing.T) { conn := initalize.InitMysql("fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen") - condUser := "user_id = 105" + condUser := "user_id = 134" + + // var condUser string + // switch userinfo.GetIdType() { + // case auth.IDTYPE_User: + // condUser = fmt.Sprintf("user_id = %d", userinfo.UserId) + // case auth.IDTYPE_Guest: + // condUser = fmt.Sprintf("guest_id = %d", userinfo.GuestId) + // default: + // condUser = "user_id = 0 and guest_id = 0" + // } var mquerys map[string]*ModuleQuery = make(map[string]*ModuleQuery) var metadict map[string]any = make(map[string]any) - for _, module := range []string{"material.logo.logo_url", "userinfo.profile"} { - if !check.CheckModuleQuery(module) { + for _, module := range []string{"userinfo.profile", "userinfo.profile.logo_selected", "userinfo.profile.logo_selected.logo_url1"} { + if !check.CheckModuleQuery(module) { + return } mlist := strings.Split(module, ".") if len(mlist) < 2 { - + return } mtable := mlist[0] tname, ok := ModuleTable[mtable] if !ok { - + return } moduleName := mlist[1] cond := fmt.Sprintf("module = '%s' and %s", moduleName, condUser) if mquery, ok := mquerys[mtable]; ok { - mquery.ModuleQuery[strings.Join(mlist[2:], ",")] = struct{}{} + mquery.ModuleQuery[strings.Join(mlist[2:], ".")] = struct{}{} } else { mquery := &ModuleQuery{ TableName: tname, - Cond: cond, ModuleName: mtable + "." + moduleName, - ModuleQuery: map[string]struct{}{strings.Join(mlist[2:], ","): {}}} + Cond: cond, + ModuleQuery: map[string]struct{}{strings.Join(mlist[2:], "."): {}}} mquerys[mtable] = mquery } } for _, mquery := range mquerys { - sqlstr := fmt.Sprintf("select id, module, %s as querydata from %s where %s order by ctime dec limit 1", mquery.EncodeQuery("metadata"), mquery.TableName, mquery.Cond) - + log.Println(mquery.ModuleName, mquery.ModuleQuery) + sqlstr := fmt.Sprintf("select id, module, %s as querydata from %s where %s order by ctime DESC limit 1", mquery.EncodeQuery("metadata"), mquery.TableName, mquery.Cond) raw := conn.Raw(sqlstr) if raw.Error != nil { @@ -64,10 +75,11 @@ func TestMain(t *testing.T) { continue } else { logx.Error(raw.Error) + } } - var info map[string]any = make(map[string]any) + var info map[string]any err := raw.Scan(&info).Error if err == gorm.ErrRecordNotFound { continue @@ -78,11 +90,13 @@ func TestMain(t *testing.T) { } - logx.Error(info) - queryjson, ok := info["querydata"].(string) if !ok { - return + for k, v := range mquery.EncodeEmpty() { + metadict[k] = v + } + continue + // return resp.SetStatusWithMessage(basic.CodeDbSqlErr, mquery.ModuleName) } var querydata map[string]any = make(map[string]any) @@ -97,6 +111,54 @@ func TestMain(t *testing.T) { } } + // 隐含白板用户逻辑 + if v, ok := metadict["userinfo.profile"]; ok { + + if v == nil { + + info := QueryDefault(conn, "profile", "logo_selected", "fs_user_info") + log.Println(info) + metadict["userinfo.profile"] = info + // log.Println(metadict) + } else { + profileDict := v.(map[string]any) + if _, ok := profileDict["logo_selected"]; !ok { + info := QueryDefault(conn, "profile", "logo_selected", "fs_user_info") + profileDict["logo_selected"] = info["logo_selected"] + } + + } + + } else if v, ok := metadict["userinfo.profile.logo_selected"]; ok { + if v == nil { + + } + } + + log.Println(metadict) + + return + +} + +func QueryDefault(conn *gorm.DB, module string, moduleQuery string, tname string) map[string]any { + + qname := strings.Split(moduleQuery, ".") + queryAsName := qname[len(qname)-1] + sqlstr := fmt.Sprintf( + "select JSON_EXTRACT(metadata,'$.%s') as %s from %s where module = '%s' and user_id = 0 and guest_id = 0 order by ctime DESC limit 1", + moduleQuery, // logo_selected + queryAsName, // logo_selected + tname, // fs_user_info + module, // profile + ) + raw := conn.Raw(sqlstr) + var info map[string]any + err := raw.Scan(&info).Error + if err == gorm.ErrRecordNotFound { + logx.Error(err) + } + return info } func TestCaseJSON_EXTRACT(t *testing.T) { diff --git a/utils/check/check.go b/utils/check/check.go index f33f9dab..b0622693 100644 --- a/utils/check/check.go +++ b/utils/check/check.go @@ -57,7 +57,7 @@ func hasInvalidPatterns(key string) bool { return false } -var checkModuleRe = regexp.MustCompile("[^\\.a-zA-Z_-]") +var checkModuleRe = regexp.MustCompile("[^\\.a-zA-Z_\\-0-9]") // CheckModuleQuery 检查模块的json查询的格式 func CheckModuleQuery(moduleQuery string) bool { diff --git a/utils/fssql/metadata.go b/utils/fssql/metadata.go index 5e671a81..eb5e0ae7 100644 --- a/utils/fssql/metadata.go +++ b/utils/fssql/metadata.go @@ -52,6 +52,7 @@ func MetadataModulePATCH(tx *gorm.DB, module string, tableStructPointer any, upd if stype.Kind() == reflect.Pointer { stype = stype.Elem() } + tname := tx.NamingStrategy.TableName(stype.Name()) updatesql := `UPDATE %s SET metadata = CASE @@ -80,7 +81,7 @@ func MetadataModulePATCH(tx *gorm.DB, module string, tableStructPointer any, upd args = append(args, metadata, metadata) args = append(args, values...) - updatesql = fmt.Sprintf(updatesql, tx.NamingStrategy.TableName(stype.Name()), module, WhereKeysCond) + updatesql = fmt.Sprintf(updatesql, tname, module, WhereKeysCond) // logx.Error(updatesql) err = tx.Exec(updatesql, args...).Error if err != nil { From 14f4f959d6d9772dcb6a237cba0025eefce1a1d9 Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 18:21:00 +0800 Subject: [PATCH 18/27] nacos config --- model/gmodel/fs_user_logic.go | 1 + 1 file changed, 1 insertion(+) diff --git a/model/gmodel/fs_user_logic.go b/model/gmodel/fs_user_logic.go index c4478a90..ef2fd642 100644 --- a/model/gmodel/fs_user_logic.go +++ b/model/gmodel/fs_user_logic.go @@ -97,6 +97,7 @@ func InheritGuestIdResource(tx *gorm.DB, userId, guestId int64, afterDo func(txR if txUserInfo.Error != nil { txUserInfo = tx.Model(&FsUserInfo{}) } + logx.Error(err, "找到user_id1 afterDo") return afterDo(txRes, txUserMaterial, txUserInfo) } return nil From 584cb5d5310ccfb68a6ab74a2a00c4f407c8b2b9 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 18:21:31 +0800 Subject: [PATCH 19/27] fix --- .../internal/logic/calculatecartpricelogic.go | 6 +++--- server/shopping-cart/internal/logic/getcartslogic.go | 4 ++-- utils/format/price.go | 12 ++++-------- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/server/shopping-cart/internal/logic/calculatecartpricelogic.go b/server/shopping-cart/internal/logic/calculatecartpricelogic.go index 81772b57..4dbe0ed4 100644 --- a/server/shopping-cart/internal/logic/calculatecartpricelogic.go +++ b/server/shopping-cart/internal/logic/calculatecartpricelogic.go @@ -129,8 +129,8 @@ func (l *CalculateCartPriceLogic) CalculateCartPrice(req *types.CalculateCartPri } calculateResultList = append(calculateResultList, types.CalculateResultItem{ CartId: cart.Id, - ItemPrice: fmt.Sprintf("%.3f", format.CentitoDollar(itemPrice)), - TotalPrice: fmt.Sprintf("%.3f", format.CentitoDollar(totalPrice)), + ItemPrice: format.CentitoDollar(itemPrice, 3), + TotalPrice: format.CentitoDollar(totalPrice, 2), }) updData := &gmodel.FsShoppingCart{ PurchaseQuantity: &reqPurchaseQuantity, @@ -152,7 +152,7 @@ func (l *CalculateCartPriceLogic) CalculateCartPrice(req *types.CalculateCartPri return resp.SetStatusWithMessage(basic.CodeDbSqlErr, err.Error()) } return resp.SetStatusWithMessage(basic.CodeOK, "success", types.CalculateCartPriceRsp{ - SubTotalPrice: fmt.Sprintf("%.3f", format.CentitoDollar(subTotalPrice)), + SubTotalPrice: format.CentitoDollar(subTotalPrice, 2), CalculateResultList: calculateResultList, }) } diff --git a/server/shopping-cart/internal/logic/getcartslogic.go b/server/shopping-cart/internal/logic/getcartslogic.go index 290740a0..35ba6f08 100644 --- a/server/shopping-cart/internal/logic/getcartslogic.go +++ b/server/shopping-cart/internal/logic/getcartslogic.go @@ -173,8 +173,8 @@ func (l *GetCartsLogic) GetCarts(req *types.GetCartsReq, userinfo *auth.UserInfo FittingId: *cart.FittingId, FittingName: fittingName, }, - ItemPrice: fmt.Sprintf("%.3f", format.CentitoDollar(itemPrice)), - TotalPrice: fmt.Sprintf("%.3f", format.CentitoDollar(totalPrice)), + ItemPrice: format.CentitoDollar(itemPrice, 3), + TotalPrice: format.CentitoDollar(totalPrice, 2), DiyInformation: types.DiyInformation{ Phone: snapShot.UserDiyInformation.Phone, Address: snapShot.UserDiyInformation.Address, diff --git a/utils/format/price.go b/utils/format/price.go index 9af4a35e..23603452 100644 --- a/utils/format/price.go +++ b/utils/format/price.go @@ -2,19 +2,15 @@ package format import ( "fmt" - "strconv" ) // 厘转美元 -func CentitoDollar(price int64, remainFloatPoint ...uint) float64 { - s := "%.3f" +func CentitoDollar(price int64, remainFloatPoint ...uint) string { + s := "%0.3f" if len(remainFloatPoint) > 0 { - s = fmt.Sprintf("%%.%df", remainFloatPoint[0]) + s = fmt.Sprintf("%%0.%df", remainFloatPoint[0]) } - fmt.Println(s) - str := fmt.Sprintf(s, float64(price)/float64(1000)) - dollar, _ := strconv.ParseFloat(str, 64) - return dollar + return fmt.Sprintf(s, float64(price)/float64(1000)) } // 厘转美元 From f767af9a7f48407e01feb373bfa904c78cd6aaac Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 18:22:55 +0800 Subject: [PATCH 20/27] fix --- utils/format/price.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/format/price.go b/utils/format/price.go index 23603452..af736079 100644 --- a/utils/format/price.go +++ b/utils/format/price.go @@ -15,6 +15,6 @@ func CentitoDollar(price int64, remainFloatPoint ...uint) string { // 厘转美元 func CentitoDollarStr(price float64) string { - s := "%.2f" + s := "%0.2f" return fmt.Sprintf(s, price/float64(1000)) } From 68bd764c6ebc60c9450b0ba10f87f75a55801a2a Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 18:26:13 +0800 Subject: [PATCH 21/27] nacos config --- model/gmodel/fs_user_logic.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/model/gmodel/fs_user_logic.go b/model/gmodel/fs_user_logic.go index ef2fd642..8244cd98 100644 --- a/model/gmodel/fs_user_logic.go +++ b/model/gmodel/fs_user_logic.go @@ -68,6 +68,7 @@ func InheritGuestIdResource(tx *gorm.DB, userId, guestId int64, afterDo func(txR Where("guest_id = ?", guestId). UpdateColumn("user_id", userId).Error if err != nil && err != gorm.ErrRecordNotFound { + logx.Error(err, "找到user_id1 afterDo") return err } @@ -76,13 +77,16 @@ func InheritGuestIdResource(tx *gorm.DB, userId, guestId int64, afterDo func(txR UpdateColumn("user_id", userId).Error if err != nil && err != gorm.ErrRecordNotFound { + logx.Error(err, "找到user_id1 afterDo") return err } err = txUserInfo. Where("guest_id = ?", guestId). UpdateColumn("user_id", userId).Error + if err != nil && err != gorm.ErrRecordNotFound { + logx.Error(err, "找到user_id1 afterDo") return err } } @@ -97,7 +101,6 @@ func InheritGuestIdResource(tx *gorm.DB, userId, guestId int64, afterDo func(txR if txUserInfo.Error != nil { txUserInfo = tx.Model(&FsUserInfo{}) } - logx.Error(err, "找到user_id1 afterDo") return afterDo(txRes, txUserMaterial, txUserInfo) } return nil From 26c008b4da7c497eede7e0cf830efd8aa41e1706 Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 18:33:39 +0800 Subject: [PATCH 22/27] nacos config --- go.mod | 2 +- go.sum | 22 ---------------------- run_all_server.sh | 17 +++++++++++------ 3 files changed, 12 insertions(+), 29 deletions(-) diff --git a/go.mod b/go.mod index 386905b4..8bf4cb92 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module fusenapi -go 1.21 +go 1.20 require ( github.com/474420502/passer v0.0.1 diff --git a/go.sum b/go.sum index 71417c7e..06dd5c40 100644 --- a/go.sum +++ b/go.sum @@ -38,7 +38,6 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7 github.com/474420502/passer v0.0.1 h1:ZWnt7hpFzsYDV7LHSEyLvLUvW5mRxrnDmgFdIl17q3w= github.com/474420502/passer v0.0.1/go.mod h1:MmnnrF9d51sPkFzdRq2pQtxQKqyjburVM1LjMbOCezE= github.com/474420502/random v0.4.1 h1:HUUyLXRWMijVb7CJoEC16f0aFQOW25Lkr80Mut6PoKU= -github.com/474420502/random v0.4.1/go.mod h1:Kq5VC8ezVvzp9CUahvebIdlSiFdHzEzscaOScLvbw2c= github.com/474420502/requests v1.42.0 h1:aUj0rWhfldbOOlGHDIcqT9zgXEoSlK4IBmRF3LxI1+Y= github.com/474420502/requests v1.42.0/go.mod h1:2SCVzim0ONFYG09g/GrM7RTeJIC6qTyZfnohsjnG5C8= github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= @@ -50,7 +49,6 @@ github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53/go.mod h1:+3 github.com/CloudyKit/jet v2.1.3-0.20180809161101-62edd43e4f88+incompatible/go.mod h1:HPYO+50pSWkPoj9Q/eq0aRGByCL6ScRlUmiEX5Zgm+w= github.com/CloudyKit/jet/v3 v3.0.0/go.mod h1:HKQPgSJmdK8hdoAbKUUWajkHyHo4RaU5rMdUywE7VMo= github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= -github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ= github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= @@ -71,9 +69,7 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a h1:HbKu58rmZpUGpz5+4FfNmIU+FmZg2P3Xaj2v2bfNWmk= -github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc= github.com/alicebob/miniredis/v2 v2.30.4 h1:8S4/o1/KoUArAGbGwPxcwf0krlzceva2XVOSchFS7Eo= -github.com/alicebob/miniredis/v2 v2.30.4/go.mod h1:b25qWj4fCEsBeAAR2mlb0ufImGC6uH3VlUfb/HS5zKg= github.com/aliyun/alibaba-cloud-sdk-go v1.61.1704 h1:PpfENOj/vPfhhy9N2OFRjpue0hjM5XqAp2thFmkXXIk= github.com/aliyun/alibaba-cloud-sdk-go v1.61.1704/go.mod h1:RcDobYh8k5VP6TNybz9m++gL3ijVI5wueVr0EM10VsU= github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= @@ -87,7 +83,6 @@ github.com/aws/aws-sdk-go v1.44.295 h1:SGjU1+MqttXfRiWHD6WU0DRhaanJgAFY+xIhEaugV github.com/aws/aws-sdk-go v1.44.295/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= -github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -152,7 +147,6 @@ github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44am github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385/go.mod h1:0vRUJqYpeSZifjYj7uP3BG/gKcuzL9xWVV/Y+cK33KM= github.com/elazarl/goproxy v0.0.0-20210801061803-8e322dfb79c4 h1:lS3P5Nw3oPO05Lk2gFiYUOL3QPaH+fRoI1wFOc4G1UY= -github.com/elazarl/goproxy v0.0.0-20210801061803-8e322dfb79c4/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -223,7 +217,6 @@ github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGw github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= github.com/golang/glog v1.1.0 h1:/d3pCKDPWNnvIWe0vVUpNP32qc8U3PDVxySP/y360qE= -github.com/golang/glog v1.1.0/go.mod h1:pfYeQZ3JWZoXTV5sFc986z3HTpwQs9At6P4ImfuP3NQ= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -272,7 +265,6 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= @@ -302,7 +294,6 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0/go.mod h1:hgWBS7lorOAVIJEQMi4Zs github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0 h1:1JYBfzqrWPcCclBwxFCPAou9n+q86mfnu7NAeHfte7A= github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0/go.mod h1:YDZoGHuwE+ov0c8smSH49WLF3F2LaWnYYuDVd+EWrc0= github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw= -github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -322,7 +313,6 @@ github.com/hashicorp/go-sockaddr v1.0.0 h1:GeH6tui99pF4NJgfnhp+L6+FfobzVW3Ah46sL github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= -github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= @@ -423,7 +413,6 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/ github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= -github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= @@ -458,17 +447,14 @@ github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= -github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.13.0/go.mod h1:+REjRxOmWfHCjfv9TTWB1jD1Frx4XydAD3zm1lskyM0= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= -github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= -github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs= github.com/openzipkin/zipkin-go v0.4.1 h1:kNd/ST2yLLWhaWrkgchya40TJabe8Hioj9udfPcEO5A= github.com/openzipkin/zipkin-go v0.4.1/go.mod h1:qY0VqDSN1pOBN94dBc6w2GJlWLiovAyg7Qt6/I9HecM= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= @@ -489,7 +475,6 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g= -github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= @@ -511,7 +496,6 @@ github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+Gx github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+PymziUAg= github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= -github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= @@ -602,7 +586,6 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yuin/gopher-lua v1.1.0 h1:BojcDhfyDWgU2f2TOzYK/g5p2gxMrku8oupLDqlnSqE= -github.com/yuin/gopher-lua v1.1.0/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw= github.com/zeromicro/go-zero v1.5.4 h1:kRvcYuxcHOkUZvg7887KQl77Qv4klGL7MqGkTBgkpS8= github.com/zeromicro/go-zero v1.5.4/go.mod h1:x/aUyLmSwRECvOyjOf+lhwThBOilJIY+s3slmPAeboA= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= @@ -638,7 +621,6 @@ go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0 go.uber.org/automaxprocs v1.5.2 h1:2LxUOGiR3O6tw8ui5sZa2LAaHnsviZdVOUZw4fvbnME= go.uber.org/automaxprocs v1.5.2/go.mod h1:eRbA25aqJrxAbsLO0xy5jVwPt7FQnRgjW+efnwa1WM0= go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= -go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4= go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= @@ -1008,15 +990,12 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/cheggaaa/pb.v1 v1.0.28 h1:n1tBJnnK2r7g9OW2btFH91V92STTUevLXYFb8gy9EMk= -gopkg.in/cheggaaa/pb.v1 v1.0.28/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y= gopkg.in/h2non/gock.v1 v1.1.2 h1:jBbHXgGBK/AoPVfJh5x4r/WxIrElvbLel8TCZkkZJoY= -gopkg.in/h2non/gock.v1 v1.1.2/go.mod h1:n7UGz/ckNChHiK05rDoiC4MYSunEC/lyaUm2WWaDva0= gopkg.in/ini.v1 v1.51.1/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.66.2 h1:XfR1dOYubytKy4Shzc2LHrrGhU0lDCfDGG1yLPmpgsI= gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= @@ -1051,7 +1030,6 @@ honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= k8s.io/utils v0.0.0-20230209194617-a36077c30491 h1:r0BAOLElQnnFhE/ApUsg3iHdVYYPBjNSSOMowRZxxsY= -k8s.io/utils v0.0.0-20230209194617-a36077c30491/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= diff --git a/run_all_server.sh b/run_all_server.sh index b76f910a..afc602ba 100755 --- a/run_all_server.sh +++ b/run_all_server.sh @@ -1,5 +1,7 @@ #!/bin/bash +single_server_name=$1 + go mod tidy go mod vendor @@ -31,14 +33,17 @@ run_server() { find /tmp/go-build* -mmin +5 -exec rm -rf {} + find /tmp/go-link* -mmin +5 -exec rm -rf {} + -# 列出所有服务器目录 server_dirs=() # 初始化一个空数组 -for dir in server/*/ ; do # 遍历 "server/" 下的所有子目录 - dir=${dir%*/} # 删除末尾的 "/" - dir=${dir##*/} # 删除开头的 "server/" - server_dirs+=("$dir") # 添加到数组 -done +if [ -n "$single_server_name" ]; then + server_dirs=("$single_server_name") +else + for dir in server/*/ ; do # 遍历 "server/" 下的所有子目录 + dir=${dir%*/} # 删除末尾的 "/" + dir=${dir##*/} # 删除开头的 "server/" + server_dirs+=("$dir") # 添加到数组 + done +fi # 在每个服务器目录下运行相应的 go 程序 for server_dir in "${server_dirs[@]}"; do From e8546d615b9cf73f0602143219d87e14d3bd9904 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 18:34:29 +0800 Subject: [PATCH 23/27] fix --- .../internal/logic/calculatecartpricelogic.go | 4 ++-- server/shopping-cart/internal/logic/getcartslogic.go | 2 +- utils/format/price.go | 12 +++++++++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/server/shopping-cart/internal/logic/calculatecartpricelogic.go b/server/shopping-cart/internal/logic/calculatecartpricelogic.go index 4dbe0ed4..fc461746 100644 --- a/server/shopping-cart/internal/logic/calculatecartpricelogic.go +++ b/server/shopping-cart/internal/logic/calculatecartpricelogic.go @@ -130,7 +130,7 @@ func (l *CalculateCartPriceLogic) CalculateCartPrice(req *types.CalculateCartPri calculateResultList = append(calculateResultList, types.CalculateResultItem{ CartId: cart.Id, ItemPrice: format.CentitoDollar(itemPrice, 3), - TotalPrice: format.CentitoDollar(totalPrice, 2), + TotalPrice: format.CentitoDollarWithNoHalfAdjust(totalPrice, 2), }) updData := &gmodel.FsShoppingCart{ PurchaseQuantity: &reqPurchaseQuantity, @@ -152,7 +152,7 @@ func (l *CalculateCartPriceLogic) CalculateCartPrice(req *types.CalculateCartPri return resp.SetStatusWithMessage(basic.CodeDbSqlErr, err.Error()) } return resp.SetStatusWithMessage(basic.CodeOK, "success", types.CalculateCartPriceRsp{ - SubTotalPrice: format.CentitoDollar(subTotalPrice, 2), + SubTotalPrice: format.CentitoDollarWithNoHalfAdjust(subTotalPrice, 2), CalculateResultList: calculateResultList, }) } diff --git a/server/shopping-cart/internal/logic/getcartslogic.go b/server/shopping-cart/internal/logic/getcartslogic.go index 35ba6f08..67e67138 100644 --- a/server/shopping-cart/internal/logic/getcartslogic.go +++ b/server/shopping-cart/internal/logic/getcartslogic.go @@ -174,7 +174,7 @@ func (l *GetCartsLogic) GetCarts(req *types.GetCartsReq, userinfo *auth.UserInfo FittingName: fittingName, }, ItemPrice: format.CentitoDollar(itemPrice, 3), - TotalPrice: format.CentitoDollar(totalPrice, 2), + TotalPrice: format.CentitoDollarWithNoHalfAdjust(totalPrice, 2), DiyInformation: types.DiyInformation{ Phone: snapShot.UserDiyInformation.Phone, Address: snapShot.UserDiyInformation.Address, diff --git a/utils/format/price.go b/utils/format/price.go index af736079..52aa1a65 100644 --- a/utils/format/price.go +++ b/utils/format/price.go @@ -4,7 +4,7 @@ import ( "fmt" ) -// 厘转美元 +// 厘转美元(四舍五入) func CentitoDollar(price int64, remainFloatPoint ...uint) string { s := "%0.3f" if len(remainFloatPoint) > 0 { @@ -13,6 +13,16 @@ func CentitoDollar(price int64, remainFloatPoint ...uint) string { return fmt.Sprintf(s, float64(price)/float64(1000)) } +// 厘转美元(向下截断,舍弃掉厘)用于计算总价 +func CentitoDollarWithNoHalfAdjust(price int64, remainFloatPoint ...uint) string { + s := "%0.2f" + if len(remainFloatPoint) > 0 { + s = fmt.Sprintf("%%0.%df", remainFloatPoint[0]) + } + t := price / 10 + return fmt.Sprintf(s, float64(t)/float64(100)) +} + // 厘转美元 func CentitoDollarStr(price float64) string { s := "%0.2f" From 3c4d50ed0a0a62425aa109883c197080235c5be6 Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 18:36:44 +0800 Subject: [PATCH 24/27] nacos config --- server/auth/internal/logic/useremailconfirmationlogic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/auth/internal/logic/useremailconfirmationlogic.go b/server/auth/internal/logic/useremailconfirmationlogic.go index 3cb86bc8..16c33fd6 100644 --- a/server/auth/internal/logic/useremailconfirmationlogic.go +++ b/server/auth/internal/logic/useremailconfirmationlogic.go @@ -97,7 +97,7 @@ func CommonNotify(WebsocketAddr, wid string, event *wevent.WebsocketEvent) error func (l *UserEmailConfirmationLogic) UserEmailConfirmation(req *types.RequestEmailConfirmation, userinfo *auth.UserInfo) (resp *basic.Response) { // 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data) // userinfo 传入值时, 一定不为null - + logx.Error("找到user_id1 UserEmailConfirmation") switch auth.OperateType(req.OpType) { case auth.OpTypeRegister: From dc489b1ca3a8feead547cfcf286f554a5d2f7887 Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 18:53:04 +0800 Subject: [PATCH 25/27] nacos config --- model/gmodel/fs_user_logic.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/model/gmodel/fs_user_logic.go b/model/gmodel/fs_user_logic.go index 8244cd98..3f2810b8 100644 --- a/model/gmodel/fs_user_logic.go +++ b/model/gmodel/fs_user_logic.go @@ -68,7 +68,7 @@ func InheritGuestIdResource(tx *gorm.DB, userId, guestId int64, afterDo func(txR Where("guest_id = ?", guestId). UpdateColumn("user_id", userId).Error if err != nil && err != gorm.ErrRecordNotFound { - logx.Error(err, "找到user_id1 afterDo") + logx.Info(err, "找到user_id1 afterDo") return err } @@ -77,7 +77,7 @@ func InheritGuestIdResource(tx *gorm.DB, userId, guestId int64, afterDo func(txR UpdateColumn("user_id", userId).Error if err != nil && err != gorm.ErrRecordNotFound { - logx.Error(err, "找到user_id1 afterDo") + logx.Info(err, "找到user_id1 afterDo") return err } @@ -86,7 +86,7 @@ func InheritGuestIdResource(tx *gorm.DB, userId, guestId int64, afterDo func(txR UpdateColumn("user_id", userId).Error if err != nil && err != gorm.ErrRecordNotFound { - logx.Error(err, "找到user_id1 afterDo") + logx.Info(err, "找到user_id1 afterDo") return err } } @@ -220,7 +220,7 @@ func (u *FsUserModel) RegisterByFusen(ctx context.Context, token *auth.RegisterT err = txUserInfo.Where("module = 'profile' and user_id = ?", uinfo.UserId).Take(nil).Error // txUserInfo.Statement.Table - logx.Error(err, "找到user_id1") + logx.Info(err, "找到user_id1") if err != nil { if err == gorm.ErrRecordNotFound { err = txUserInfo.Create(uinfo).Error @@ -229,7 +229,7 @@ func (u *FsUserModel) RegisterByFusen(ctx context.Context, token *auth.RegisterT } } } else { - logx.Error("找到user_id2") + logx.Info("找到user_id2") err = fssql.MetadataModulePATCH(txUserInfo, "profile", FsUserInfo{}, metadata, "user_id = ?", *uinfo.UserId) if err != nil { return err From 822a2163a0a9be261ac1457e9d89afa61e6a9b1f Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 18:57:18 +0800 Subject: [PATCH 26/27] nacos config --- model/gmodel/fs_user_logic.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/model/gmodel/fs_user_logic.go b/model/gmodel/fs_user_logic.go index 3f2810b8..aa11295f 100644 --- a/model/gmodel/fs_user_logic.go +++ b/model/gmodel/fs_user_logic.go @@ -173,6 +173,7 @@ func (u *FsUserModel) RegisterByFusen(ctx context.Context, token *auth.RegisterT var err error err = tx.Model(&FsUser{}).Where("email = ?", token.Email).Take(user).Error + logx.Info("success", token.TraceId) if err == gorm.ErrRecordNotFound { FirstName := token.Extend["first_name"].(string) @@ -193,9 +194,11 @@ func (u *FsUserModel) RegisterByFusen(ctx context.Context, token *auth.RegisterT return err } + logx.Info("success", token.TraceId) + // 继承guest_id的资源表 err = InheritGuestIdResource(tx, user.Id, token.GuestId, func(txResouce, txUserMaterial, txUserInfo *gorm.DB) error { - + logx.Info("success", token.TraceId) userProfile := &UserProfile{ FirstName: FirstName, LastName: LastName, From edb1b0c0f2e5f6402478ac3f932210513b9a87a9 Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 18:59:47 +0800 Subject: [PATCH 27/27] nacos config --- model/gmodel/fs_user_logic.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/model/gmodel/fs_user_logic.go b/model/gmodel/fs_user_logic.go index aa11295f..f9ea7790 100644 --- a/model/gmodel/fs_user_logic.go +++ b/model/gmodel/fs_user_logic.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "log" "fusenapi/utils/auth" "fusenapi/utils/fssql" @@ -173,7 +174,7 @@ func (u *FsUserModel) RegisterByFusen(ctx context.Context, token *auth.RegisterT var err error err = tx.Model(&FsUser{}).Where("email = ?", token.Email).Take(user).Error - logx.Info("success", token.TraceId) + log.Println("success", token.TraceId) if err == gorm.ErrRecordNotFound { FirstName := token.Extend["first_name"].(string) @@ -194,11 +195,11 @@ func (u *FsUserModel) RegisterByFusen(ctx context.Context, token *auth.RegisterT return err } - logx.Info("success", token.TraceId) + log.Println("success", token.TraceId) // 继承guest_id的资源表 err = InheritGuestIdResource(tx, user.Id, token.GuestId, func(txResouce, txUserMaterial, txUserInfo *gorm.DB) error { - logx.Info("success", token.TraceId) + log.Println("success", token.TraceId) userProfile := &UserProfile{ FirstName: FirstName, LastName: LastName, @@ -223,7 +224,7 @@ func (u *FsUserModel) RegisterByFusen(ctx context.Context, token *auth.RegisterT err = txUserInfo.Where("module = 'profile' and user_id = ?", uinfo.UserId).Take(nil).Error // txUserInfo.Statement.Table - logx.Info(err, "找到user_id1") + log.Println(err, "找到user_id1") if err != nil { if err == gorm.ErrRecordNotFound { err = txUserInfo.Create(uinfo).Error @@ -232,7 +233,7 @@ func (u *FsUserModel) RegisterByFusen(ctx context.Context, token *auth.RegisterT } } } else { - logx.Info("找到user_id2") + log.Println("找到user_id2") err = fssql.MetadataModulePATCH(txUserInfo, "profile", FsUserInfo{}, metadata, "user_id = ?", *uinfo.UserId) if err != nil { return err