From d182e581dd48d2e289f8cfa06405f8802a04573b Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期四, 28 三月 2024 19:45:45 +0800 Subject: [PATCH] 运营商去掉必填 --- controllers/order.go | 23 +++++++++++++++++++---- 1 files changed, 19 insertions(+), 4 deletions(-) diff --git a/controllers/order.go b/controllers/order.go index 0f1fa2a..ffa4406 100644 --- a/controllers/order.go +++ b/controllers/order.go @@ -11,6 +11,7 @@ "outsourcing/pkg/logx" "outsourcing/pkg/structx" "outsourcing/request" + "outsourcing/response" "outsourcing/service" "outsourcing/service/outsourcing" "outsourcing/utils/jwt" @@ -286,7 +287,7 @@ util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�") return } - if params.OutsourcingOrderID == 0 || params.Number == "" || params.Carrier == "" || params.WaybillNumber == "" { + if params.OutsourcingOrderID == 0 || params.Number == "" { util.ResponseFormat(c, code.RequestParamError, "鍙傛暟缂哄け") return } @@ -321,6 +322,7 @@ OutsourcingOrderDeliveryID: delivery.ID, OutsourcingOrderProductID: v.OutsourcingOrderProductID, SendAmount: v.SendAmount, + IsReceived: 2, }) } return models.NewOutsourcingOrderDeliveryDetailsSearch().SetOrm(db).CreateBatch(items) @@ -370,7 +372,7 @@ // @Summary 鐗╂枡鎼滅储 // @Produce application/json // @Param object body request.MaterialSearch true "鍙傛暟" -// @Success 200 {object} util.ResponseList{[]models.OutsourcingOrderDeliveryDetails} "鎴愬姛" +// @Success 200 {object} util.ResponseList{[]response.Material} "鎴愬姛" // @Router /api-outsourcing/v1/order/materialSearch [post] func (slf *OrderController) MaterialSearch(c *gin.Context) { var params request.MaterialSearch @@ -379,15 +381,28 @@ return } client := outsourcing.NewOutsourcingServiceClient(service.ApsServiceConn) - list, err := client.GetMaterialList(c, &outsourcing.GetMaterialListRequest{ + resp, err := client.GetMaterialList(c, &outsourcing.GetMaterialListRequest{ Page: int32(params.Page), PageSize: int32(params.PageSize), Keyword: params.Keyword, }) + if err != nil { logx.Errorf("grpc outsourcing GetProductList err:%v", err) util.ResponseFormat(c, code.RequestParamError, "鏌ヨ澶辫触") return } - util.ResponseFormat(c, code.Success, list) + + data := make([]*response.Material, 0, len(resp.List)) + for _, item := range resp.List { + data = append(data, &response.Material{ + Number: item.ID, + Name: item.Name, + Unit: item.Unit, + Specs: item.Specs, + Type: item.Type, + }) + } + + util.ResponseFormat(c, code.Success, data) } -- Gitblit v1.8.0