diff --git a/server/shopping-cart-confirmation/internal/handler/cartlisthandler.go b/server/shopping-cart-confirmation/internal/handler/cartlisthandler.go index 8e45bb62..7232a4b9 100644 --- a/server/shopping-cart-confirmation/internal/handler/cartlisthandler.go +++ b/server/shopping-cart-confirmation/internal/handler/cartlisthandler.go @@ -18,7 +18,7 @@ import ( func CartListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { // 解析jwtToken - /*claims, err := svcCtx.ParseJwtToken(r) + claims, err := svcCtx.ParseJwtToken(r) // 如果解析出错,则返回未授权的JSON响应并记录错误消息 if err != nil { httpx.OkJsonCtx(r.Context(), w, &basic.Response{ @@ -40,7 +40,7 @@ func CartListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { logx.Info("unauthorized:", err.Error()) return } - */ + var req types.CartListReq // 如果端点有请求结构体,则使用httpx.Parse方法从HTTP请求体中解析请求数据 if err := httpx.Parse(r, &req); err != nil { @@ -53,7 +53,7 @@ func CartListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { } // 创建一个业务逻辑层实例 l := logic.NewCartListLogic(r.Context(), svcCtx) - resp := l.CartList(&req, &auth.UserInfo{86}) + resp := l.CartList(&req, userinfo) // 如果响应不为nil,则使用httpx.OkJsonCtx方法返回JSON响应; // 否则,发送500内部服务器错误的JSON响应并记录错误消息logx.Error。 if resp != nil { diff --git a/server/shopping-cart-confirmation/internal/logic/cartlistlogic.go b/server/shopping-cart-confirmation/internal/logic/cartlistlogic.go index fa138655..4f54248b 100644 --- a/server/shopping-cart-confirmation/internal/logic/cartlistlogic.go +++ b/server/shopping-cart-confirmation/internal/logic/cartlistlogic.go @@ -194,9 +194,8 @@ func (l *CartListLogic) getUserCartRelativeList(ctx context.Context, userId int6 } //******************************协程并发开始*********************************** wait := sync.WaitGroup{} - gorutine := 6 //注意要加协程这里要记得加 - errChan := make(chan error, gorutine) - wait.Add(gorutine) + errChan := make(chan error) + wait.Add(6) //注意要加协程这里要记得加 //获取产品数据1 go func() { defer wait.Done()