From d7caa411da34db2c2df107ae6bc310e95b1a8a86 Mon Sep 17 00:00:00 2001
From: wangpengfei <274878379@qq.com>
Date: 星期五, 21 七月 2023 14:15:00 +0800
Subject: [PATCH] fix

---
 api/v1/vetting.go        |   49 ++++++++++++
 model/request/vetting.go |    5 +
 pkg/ecode/code.go        |   22 ++--
 docs/swagger.yaml        |   29 +++++++
 docs/docs.go             |   45 +++++++++++
 docs/swagger.json        |   45 +++++++++++
 6 files changed, 184 insertions(+), 11 deletions(-)

diff --git a/api/v1/vetting.go b/api/v1/vetting.go
index e025f69..4b7a96d 100644
--- a/api/v1/vetting.go
+++ b/api/v1/vetting.go
@@ -1,10 +1,12 @@
 package v1
 
 import (
+	"aps_crm/constvar"
 	"aps_crm/model"
 	"aps_crm/model/request"
 	"aps_crm/pkg/contextx"
 	"aps_crm/pkg/ecode"
+	"aps_crm/utils"
 	"github.com/gin-gonic/gin"
 )
 
@@ -42,6 +44,53 @@
 	ctx.Ok()
 }
 
+// Update
+//
+//	@Tags		Vetting
+//	@Summary	鏇存柊瀹℃壒
+//	@Produce	application/json
+//	@Param		object	body		request.UpdateVetting	true	"鏌ヨ鍙傛暟"
+//	@Success	200		{object}	contextx.Response{}
+//	@Router		/api/vetting/update [post]
+func (vet *VettingApi) Update(c *gin.Context) {
+	var params request.UpdateVetting
+	ctx, ok := contextx.NewContext(c, &params)
+	if !ok {
+		return
+	}
+
+	vetting, err := model.NewVettingSearch().SetId(params.Id).Get()
+	if err != nil {
+		ctx.Fail(ecode.VettingNotExist)
+		return
+	}
+
+	waitUse, _ := utils.GetClaims(c)
+	// 濡備綍褰撳墠鐢ㄦ埛鏄秴绾х鐞嗗憳锛屽垯涓嶉渶瑕佸垽鏂�
+	if waitUse.UserType != constvar.UserTypeSuper {
+		userId := waitUse.UserId
+		user, err := model.NewUserSearch(nil).SetId(userId).First()
+		if err != nil {
+			return
+		}
+
+		if user.ID != vetting.UserId {
+			ctx.Fail(ecode.VettingNotBelongToUser)
+			return
+		}
+	}
+
+	vetting.Status = params.Status
+
+	errCode := vettingService.UpdateVetting(vetting)
+	if errCode != ecode.OK {
+		ctx.Fail(errCode)
+		return
+	}
+
+	ctx.Ok()
+}
+
 func checkVettingParams(vetting *request.AddVetting) (int, *model.Vetting) {
 
 	v := &model.Vetting{
diff --git a/docs/docs.go b/docs/docs.go
index 7f94009..7984631 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -6812,6 +6812,36 @@
                     }
                 }
             }
+        },
+        "/api/vetting/update": {
+            "post": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "Vetting"
+                ],
+                "summary": "鏇存柊瀹℃壒",
+                "parameters": [
+                    {
+                        "description": "鏌ヨ鍙傛暟",
+                        "name": "object",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/request.UpdateVetting"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/contextx.Response"
+                        }
+                    }
+                }
+            }
         }
     },
     "definitions": {
@@ -11670,6 +11700,21 @@
                 }
             }
         },
+        "request.UpdateVetting": {
+            "type": "object",
+            "required": [
+                "id",
+                "status"
+            ],
+            "properties": {
+                "id": {
+                    "type": "integer"
+                },
+                "status": {
+                    "type": "integer"
+                }
+            }
+        },
         "response.AccountIdResponse": {
             "type": "object",
             "properties": {
diff --git a/docs/swagger.json b/docs/swagger.json
index 695c299..0216806 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -6800,6 +6800,36 @@
                     }
                 }
             }
+        },
+        "/api/vetting/update": {
+            "post": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "Vetting"
+                ],
+                "summary": "鏇存柊瀹℃壒",
+                "parameters": [
+                    {
+                        "description": "鏌ヨ鍙傛暟",
+                        "name": "object",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/request.UpdateVetting"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/contextx.Response"
+                        }
+                    }
+                }
+            }
         }
     },
     "definitions": {
@@ -11658,6 +11688,21 @@
                 }
             }
         },
+        "request.UpdateVetting": {
+            "type": "object",
+            "required": [
+                "id",
+                "status"
+            ],
+            "properties": {
+                "id": {
+                    "type": "integer"
+                },
+                "status": {
+                    "type": "integer"
+                }
+            }
+        },
         "response.AccountIdResponse": {
             "type": "object",
             "properties": {
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index 1520f1c..cc6e9dd 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -3245,6 +3245,16 @@
     required:
     - timely_rate
     type: object
+  request.UpdateVetting:
+    properties:
+      id:
+        type: integer
+      status:
+        type: integer
+    required:
+    - id
+    - status
+    type: object
   response.AccountIdResponse:
     properties:
       list:
@@ -7964,4 +7974,23 @@
       summary: 娣诲姞瀹℃壒
       tags:
       - Vetting
+  /api/vetting/update:
+    post:
+      parameters:
+      - description: 鏌ヨ鍙傛暟
+        in: body
+        name: object
+        required: true
+        schema:
+          $ref: '#/definitions/request.UpdateVetting'
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/contextx.Response'
+      summary: 鏇存柊瀹℃壒
+      tags:
+      - Vetting
 swagger: "2.0"
diff --git a/model/request/vetting.go b/model/request/vetting.go
index 8263f6a..d8d240b 100644
--- a/model/request/vetting.go
+++ b/model/request/vetting.go
@@ -7,3 +7,8 @@
 	VettingType int    `json:"vettingType" form:"vettingType" binding:"required"`
 	VettingId   int    `json:"vettingId" form:"vettingId" binding:"required"`
 }
+
+type UpdateVetting struct {
+	Id     int `json:"id" form:"id" binding:"required"`
+	Status int `json:"status" form:"status" binding:"required"`
+}
diff --git a/pkg/ecode/code.go b/pkg/ecode/code.go
index 3656b29..e2462f4 100644
--- a/pkg/ecode/code.go
+++ b/pkg/ecode/code.go
@@ -287,10 +287,11 @@
 	DepartmentDeleteErr  = 4000006 // 鍒犻櫎閮ㄩ棬澶辫触
 	DepartmentDeleteErr1 = 4000007 // 璇ラ儴闂ㄤ笅瀛樺湪鐢ㄦ埛锛屾棤娉曞垹闄�
 
-	VettingExist    = 4100001 // 瀹℃壒宸插瓨鍦�
-	VettingNotExist = 4100002 // 瀹℃壒涓嶅瓨鍦�
-	VettingListErr  = 4100003 // 鑾峰彇瀹℃壒鍒楄〃澶辫触
-	VettingSetErr   = 4100004 // 璁剧疆瀹℃壒澶辫触
+	VettingExist           = 4100001 // 瀹℃壒宸插瓨鍦�
+	VettingNotExist        = 4100002 // 瀹℃壒涓嶅瓨鍦�
+	VettingListErr         = 4100003 // 鑾峰彇瀹℃壒鍒楄〃澶辫触
+	VettingSetErr          = 4100004 // 璁剧疆瀹℃壒澶辫触
+	VettingNotBelongToUser = 4100005 // 瀹℃壒涓嶅睘浜庡綋鍓嶇敤鎴�
 
 	SatisfactionExist     = 4200001 // 婊℃剰搴﹀凡瀛樺湪
 	SatisfactionNotExist  = 4200002 // 婊℃剰搴︿笉瀛樺湪
@@ -376,11 +377,10 @@
 	QuotationStatusSetErr    = 5500004 // 璁剧疆鎶ヤ环鍗曠姸鎬佸け璐�
 	QuotationStatusUpdateErr = 5500005 // 鏇存柊鎶ヤ环鍗曠姸鎬佸け璐�
 
+	CurrencyExist     = 5600001 // 甯佺宸插瓨鍦�
+	CurrencyNotExist  = 5600002 // 甯佺涓嶅瓨鍦�
+	CurrencyListErr   = 5600003 // 鑾峰彇甯佺鍒楄〃澶辫触
+	CurrencySetErr    = 5600004 // 璁剧疆甯佺澶辫触
+	CurrencyUpdateErr = 5600005 // 鏇存柊甯佺澶辫触
 
-	CurrencyExist     = 5000001 // 甯佺宸插瓨鍦�
-	CurrencyNotExist  = 5000002 // 甯佺涓嶅瓨鍦�
-	CurrencyListErr   = 5000003 // 鑾峰彇甯佺鍒楄〃澶辫触
-	CurrencySetErr    = 5000004 // 璁剧疆甯佺澶辫触
-	CurrencyUpdateErr = 5000005 // 鏇存柊甯佺澶辫触
-
-)
\ No newline at end of file
+)

--
Gitblit v1.8.0