From 138fddee3dc30b49e78ffef63c51706f1463a021 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期三, 27 三月 2024 19:37:25 +0800
Subject: [PATCH] 更改返回字段
---
outsourcing | 0
controllers/order.go | 20 +++++++++++++++++---
response/outsourcing.go | 9 +++++++++
3 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/controllers/order.go b/controllers/order.go
index 0f1fa2a..2908b1b 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"
@@ -370,7 +371,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 +380,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)
}
diff --git a/outsourcing b/outsourcing
index 1e3f77f..3485c5c 100644
--- a/outsourcing
+++ b/outsourcing
Binary files differ
diff --git a/response/outsourcing.go b/response/outsourcing.go
new file mode 100644
index 0000000..1c8d808
--- /dev/null
+++ b/response/outsourcing.go
@@ -0,0 +1,9 @@
+package response
+
+type Material struct {
+ Number string `json:"number"`
+ Name string `json:"name"`
+ Unit string `json:"unit"`
+ Specs string `json:"specs"`
+ Type string `json:"type"`
+}
--
Gitblit v1.8.0