From 67cf4fc49fdea5dcdd8007a94227f8486881c6bb Mon Sep 17 00:00:00 2001
From: liujiandao <274878379@qq.com>
Date: 星期二, 26 九月 2023 19:25:42 +0800
Subject: [PATCH] 部分功能修改
---
router/purchase/purchase.go | 1
api/v1/purchase/quality_inspection.go | 23 +++++
service/test/supplier.go | 2
docs/swagger.yaml | 34 ++++++++
api/v1/test/product.go | 13 +++
docs/docs.go | 60 +++++++++++++++
service/purchase/purchase.go | 2
docs/swagger.json | 60 +++++++++++++++
8 files changed, 193 insertions(+), 2 deletions(-)
diff --git a/api/v1/purchase/quality_inspection.go b/api/v1/purchase/quality_inspection.go
index 539adef..3e38bc9 100644
--- a/api/v1/purchase/quality_inspection.go
+++ b/api/v1/purchase/quality_inspection.go
@@ -86,6 +86,29 @@
}
//
+//// QualityTest
+//// @Tags QualityInspect
+//// @Summary QualityTest
+//// @Security ApiKeyAuth
+//// @accept application/json
+//// @Produce application/json
+//// @Success 200 {object} response.Response{data=response.PageResult,msg=string} "鍒嗛〉鑾峰彇璐ㄦ鍗曞垪琛�,杩斿洖鍖呮嫭鍒楄〃,鎬绘暟,椤电爜,姣忛〉鏁伴噺"
+//// @Router /purchase/qualityTest [get]
+//func (e *QualityInspectApi) QualityTest(c *gin.Context) {
+// client := quality.NewQualityServiceClient(qualityinspect.Conn)
+// list, err := client.GetQualityStatusList(context.Background(), &quality.QualityStatusRequest{WorkOrderId: []string{"GD-0116", "GD-0117", "GD-0156"}})
+// if err != nil {
+// fmt.Println(err)
+// response.FailWithMessage("鍐呴儴閿欒", c)
+// return
+// }
+// for _, status := range list.List {
+// fmt.Println(status)
+// }
+// response.Ok(c)
+//}
+
+//
//// GetQualityInspect
//// @Tags QualityInspect
//// @Summary 鑾峰彇鍗曚竴璐ㄦ鍗曚俊鎭�
diff --git a/api/v1/test/product.go b/api/v1/test/product.go
index ca47df4..dfb82c9 100644
--- a/api/v1/test/product.go
+++ b/api/v1/test/product.go
@@ -36,6 +36,19 @@
response.FailWithMessage(err.Error(), c)
return
}
+ for _, t := range p.List {
+ var num int64
+ db := global.GVA_DB.Model(&test.Product{})
+ err := db.Where("number = ?", t.Number).Where("supplier_id = ?", t.SupplierId).Count(&num).Error
+ if err != nil {
+ response.FailWithMessage(err.Error(), c)
+ return
+ }
+ if num > 0 {
+ response.FailWithMessage("褰撳墠渚涘簲鍟嗗凡缁忔彁渚涙浜у搧", c)
+ return
+ }
+ }
if err := pService.CreateProduct(p.List); err != nil {
global.GVA_LOG.Error("鍒涘缓澶辫触!", zap.Error(err))
response.FailWithMessage("鍒涘缓澶辫触", c)
diff --git a/docs/docs.go b/docs/docs.go
index bd498d8..faca9b4 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -4281,6 +4281,11 @@
},
{
"type": "string",
+ "name": "supplierName",
+ "in": "query"
+ },
+ {
+ "type": "string",
"name": "unit",
"in": "query"
},
@@ -4415,6 +4420,11 @@
{
"type": "integer",
"name": "supplierId",
+ "in": "query"
+ },
+ {
+ "type": "string",
+ "name": "supplierName",
"in": "query"
},
{
@@ -4558,6 +4568,11 @@
{
"type": "integer",
"name": "supplierId",
+ "in": "query"
+ },
+ {
+ "type": "string",
+ "name": "supplierName",
"in": "query"
},
{
@@ -5016,6 +5031,48 @@
"in": "query"
}
],
+ "responses": {
+ "200": {
+ "description": "鍒嗛〉鑾峰彇璐ㄦ鍗曞垪琛�,杩斿洖鍖呮嫭鍒楄〃,鎬绘暟,椤电爜,姣忛〉鏁伴噺",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/response.Response"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "data": {
+ "$ref": "#/definitions/response.PageResult"
+ },
+ "msg": {
+ "type": "string"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "/purchase/qualityTest": {
+ "get": {
+ "security": [
+ {
+ "ApiKeyAuth": []
+ }
+ ],
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "QualityInspect"
+ ],
+ "summary": "QualityTest",
"responses": {
"200": {
"description": "鍒嗛〉鑾峰彇璐ㄦ鍗曞垪琛�,杩斿洖鍖呮嫭鍒楄〃,鎬绘暟,椤电爜,姣忛〉鏁伴噺",
@@ -10413,6 +10470,9 @@
"supplierId": {
"type": "integer"
},
+ "supplierName": {
+ "type": "string"
+ },
"unit": {
"type": "string"
},
diff --git a/docs/swagger.json b/docs/swagger.json
index 7ab132a..4779ce3 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -4272,6 +4272,11 @@
},
{
"type": "string",
+ "name": "supplierName",
+ "in": "query"
+ },
+ {
+ "type": "string",
"name": "unit",
"in": "query"
},
@@ -4406,6 +4411,11 @@
{
"type": "integer",
"name": "supplierId",
+ "in": "query"
+ },
+ {
+ "type": "string",
+ "name": "supplierName",
"in": "query"
},
{
@@ -4549,6 +4559,11 @@
{
"type": "integer",
"name": "supplierId",
+ "in": "query"
+ },
+ {
+ "type": "string",
+ "name": "supplierName",
"in": "query"
},
{
@@ -5007,6 +5022,48 @@
"in": "query"
}
],
+ "responses": {
+ "200": {
+ "description": "鍒嗛〉鑾峰彇璐ㄦ鍗曞垪琛�,杩斿洖鍖呮嫭鍒楄〃,鎬绘暟,椤电爜,姣忛〉鏁伴噺",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/response.Response"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "data": {
+ "$ref": "#/definitions/response.PageResult"
+ },
+ "msg": {
+ "type": "string"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
+ "/purchase/qualityTest": {
+ "get": {
+ "security": [
+ {
+ "ApiKeyAuth": []
+ }
+ ],
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "QualityInspect"
+ ],
+ "summary": "QualityTest",
"responses": {
"200": {
"description": "鍒嗛〉鑾峰彇璐ㄦ鍗曞垪琛�,杩斿洖鍖呮嫭鍒楄〃,鎬绘暟,椤电爜,姣忛〉鏁伴噺",
@@ -10404,6 +10461,9 @@
"supplierId": {
"type": "integer"
},
+ "supplierName": {
+ "type": "string"
+ },
"unit": {
"type": "string"
},
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index 148b9e9..50a0f2c 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -1957,6 +1957,8 @@
$ref: '#/definitions/test.Supplier'
supplierId:
type: integer
+ supplierName:
+ type: string
unit:
type: string
updated_at:
@@ -4482,6 +4484,9 @@
name: supplierId
type: integer
- in: query
+ name: supplierName
+ type: string
+ - in: query
name: unit
type: string
- in: query
@@ -4565,6 +4570,9 @@
- in: query
name: supplierId
type: integer
+ - in: query
+ name: supplierName
+ type: string
- in: query
name: supplierNumber
type: string
@@ -4652,6 +4660,9 @@
- in: query
name: supplierId
type: integer
+ - in: query
+ name: supplierName
+ type: string
- in: query
name: supplierNumber
type: string
@@ -4933,6 +4944,29 @@
summary: 鍒嗛〉鑾峰彇璐ㄦ鍗曞垪琛�
tags:
- QualityInspect
+ /purchase/qualityTest:
+ get:
+ consumes:
+ - application/json
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: 鍒嗛〉鑾峰彇璐ㄦ鍗曞垪琛�,杩斿洖鍖呮嫭鍒楄〃,鎬绘暟,椤电爜,姣忛〉鏁伴噺
+ schema:
+ allOf:
+ - $ref: '#/definitions/response.Response'
+ - properties:
+ data:
+ $ref: '#/definitions/response.PageResult'
+ msg:
+ type: string
+ type: object
+ security:
+ - ApiKeyAuth: []
+ summary: QualityTest
+ tags:
+ - QualityInspect
/purchase/submit/{id}:
post:
consumes:
diff --git a/router/purchase/purchase.go b/router/purchase/purchase.go
index fc32f6a..5e8ba4f 100644
--- a/router/purchase/purchase.go
+++ b/router/purchase/purchase.go
@@ -24,6 +24,7 @@
{
//qualityInspectRouter.GET("purchase/:id", qualityInspectApi.GetPurchase) // 鑾峰彇鍗曚竴閲囪喘鍗曚俊鎭�
qualityInspectRouter.GET("qualityInspectList", qualityInspectApi.GetQualityInspectList) // 鑾峰彇閲囪喘鍗曞垪琛�
+ //qualityInspectRouter.GET("qualityTest", qualityInspectApi.QualityTest) // 娴嬭瘯
}
}
diff --git a/service/purchase/purchase.go b/service/purchase/purchase.go
index d07291e..ced5939 100644
--- a/service/purchase/purchase.go
+++ b/service/purchase/purchase.go
@@ -273,7 +273,7 @@
for _, item := range list {
if item.ID != 0 {
- err = tx.Save(item).Error
+ err = tx.Where("id = ?", item.ID).Updates(item).Error
if err != nil {
return err
}
diff --git a/service/test/supplier.go b/service/test/supplier.go
index 4ce559f..61417f3 100644
--- a/service/test/supplier.go
+++ b/service/test/supplier.go
@@ -83,7 +83,7 @@
return
}
- err = db.Debug().Limit(limit).Offset(offset).Preload("Contract").Find(&ss).Error
+ err = db.Debug().Limit(limit).Offset(offset).Order("created_at desc").Preload("Contract").Find(&ss).Error
return ss, total, err
}
--
Gitblit v1.8.0