From a63566fef15a499c82a5198578d5cb99fca299d4 Mon Sep 17 00:00:00 2001
From: wangpengfei <274878379@qq.com>
Date: 星期四, 20 七月 2023 14:20:58 +0800
Subject: [PATCH] add

---
 api/v1/index.go    |    2 
 constvar/const.go  |    9 +++
 service/index.go   |    1 
 api/v1/vetting.go  |   40 +++++++++----
 service/vetting.go |   12 +++
 pkg/ecode/code.go  |    3 +
 docs/swagger.yaml  |   26 +-------
 docs/docs.go       |   34 +---------
 docs/swagger.json  |   34 +---------
 9 files changed, 67 insertions(+), 94 deletions(-)

diff --git a/api/v1/index.go b/api/v1/index.go
index 1985418..d704084 100644
--- a/api/v1/index.go
+++ b/api/v1/index.go
@@ -48,6 +48,7 @@
 	MenuApi
 	GetAllDataApi
 	DepartmentApi
+	VettingApi
 }
 
 var ApiGroup = new(Group)
@@ -96,4 +97,5 @@
 	menuService                 = service.ServiceGroup.MenuService
 	allDataServer               = service.ServiceGroup.DataServer
 	departmentService           = service.ServiceGroup.DepartmentService
+	vettingService              = service.ServiceGroup.VettingService
 )
diff --git a/api/v1/vetting.go b/api/v1/vetting.go
index c5a676f..e025f69 100644
--- a/api/v1/vetting.go
+++ b/api/v1/vetting.go
@@ -1,8 +1,10 @@
 package v1
 
 import (
+	"aps_crm/model"
 	"aps_crm/model/request"
 	"aps_crm/pkg/contextx"
+	"aps_crm/pkg/ecode"
 	"github.com/gin-gonic/gin"
 )
 
@@ -23,19 +25,31 @@
 		return
 	}
 
-	//errCode, vetting := checkVettingParams(params.Vetting)
-	//if errCode != ecode.OK {
-	//	ctx.Fail(errCode)
-	//	return
-	//}
-	//
-	//// check member exist
-	//
-	//errCode = vettingService.AddVetting(vetting)
-	//if errCode != ecode.OK {
-	//	ctx.Fail(errCode)
-	//	return
-	//}
+	errCode, vetting := checkVettingParams(&params)
+	if errCode != ecode.OK {
+		ctx.Fail(errCode)
+		return
+	}
+
+	// check member exist
+
+	errCode = vettingService.AddVetting(vetting)
+	if errCode != ecode.OK {
+		ctx.Fail(errCode)
+		return
+	}
 
 	ctx.Ok()
 }
+
+func checkVettingParams(vetting *request.AddVetting) (int, *model.Vetting) {
+
+	v := &model.Vetting{
+		Opinion:   vetting.Opinion,
+		Status:    vetting.Status,
+		UserId:    vetting.UserId,
+		VettingId: vetting.VettingId,
+	}
+
+	return ecode.OK, v
+}
diff --git a/constvar/const.go b/constvar/const.go
index c5420da..dbb8fbb 100644
--- a/constvar/const.go
+++ b/constvar/const.go
@@ -58,3 +58,12 @@
 const (
 	MenuTypeClient MenuType = "client"
 )
+
+type VettingType int
+
+const (
+	VettingTypeClient VettingType = iota + 1
+	VettingTypeSales
+	VettingTypeSalesChance
+	VettingTypeSalesChanceFollow
+)
diff --git a/docs/docs.go b/docs/docs.go
index 2c1900c..294d119 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -4013,7 +4013,7 @@
                 }
             }
         },
-        "/api/salesReturn/update/{id}": {
+        "/api/salesReturn/update": {
             "put": {
                 "produces": [
                     "application/json"
@@ -6758,7 +6758,7 @@
                     "type": "integer"
                 },
                 "money": {
-                    "type": "string"
+                    "type": "number"
                 },
                 "number": {
                     "type": "string"
@@ -8367,7 +8367,7 @@
                     "type": "integer"
                 },
                 "money": {
-                    "type": "string"
+                    "type": "number"
                 },
                 "number": {
                     "type": "string"
@@ -8837,35 +8837,11 @@
         "request.UpdateSalesReturnRequest": {
             "type": "object",
             "properties": {
-                "clientId": {
-                    "type": "integer"
-                },
                 "id": {
                     "type": "integer"
                 },
-                "memberId": {
-                    "type": "integer"
-                },
-                "number": {
-                    "type": "string"
-                },
-                "products": {
-                    "type": "array",
-                    "items": {
-                        "$ref": "#/definitions/model.Product"
-                    }
-                },
-                "reason": {
-                    "type": "string"
-                },
-                "repository": {
-                    "type": "string"
-                },
-                "returnDate": {
-                    "type": "string"
-                },
-                "status": {
-                    "type": "integer"
+                "salesReturn": {
+                    "$ref": "#/definitions/request.SalesReturn"
                 }
             }
         },
diff --git a/docs/swagger.json b/docs/swagger.json
index 5ff6be6..f952311 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -4001,7 +4001,7 @@
                 }
             }
         },
-        "/api/salesReturn/update/{id}": {
+        "/api/salesReturn/update": {
             "put": {
                 "produces": [
                     "application/json"
@@ -6746,7 +6746,7 @@
                     "type": "integer"
                 },
                 "money": {
-                    "type": "string"
+                    "type": "number"
                 },
                 "number": {
                     "type": "string"
@@ -8355,7 +8355,7 @@
                     "type": "integer"
                 },
                 "money": {
-                    "type": "string"
+                    "type": "number"
                 },
                 "number": {
                     "type": "string"
@@ -8825,35 +8825,11 @@
         "request.UpdateSalesReturnRequest": {
             "type": "object",
             "properties": {
-                "clientId": {
-                    "type": "integer"
-                },
                 "id": {
                     "type": "integer"
                 },
-                "memberId": {
-                    "type": "integer"
-                },
-                "number": {
-                    "type": "string"
-                },
-                "products": {
-                    "type": "array",
-                    "items": {
-                        "$ref": "#/definitions/model.Product"
-                    }
-                },
-                "reason": {
-                    "type": "string"
-                },
-                "repository": {
-                    "type": "string"
-                },
-                "returnDate": {
-                    "type": "string"
-                },
-                "status": {
-                    "type": "integer"
+                "salesReturn": {
+                    "$ref": "#/definitions/request.SalesReturn"
                 }
             }
         },
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index 170d8a0..3d51f94 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -1157,7 +1157,7 @@
       member_id:
         type: integer
       money:
-        type: string
+        type: number
       number:
         type: string
       start_time:
@@ -2249,7 +2249,7 @@
       member_id:
         type: integer
       money:
-        type: string
+        type: number
       number:
         type: string
       start_time:
@@ -2561,26 +2561,10 @@
     type: object
   request.UpdateSalesReturnRequest:
     properties:
-      clientId:
-        type: integer
       id:
         type: integer
-      memberId:
-        type: integer
-      number:
-        type: string
-      products:
-        items:
-          $ref: '#/definitions/model.Product'
-        type: array
-      reason:
-        type: string
-      repository:
-        type: string
-      returnDate:
-        type: string
-      status:
-        type: integer
+      salesReturn:
+        $ref: '#/definitions/request.SalesReturn'
     type: object
   request.UpdateSalesSources:
     properties:
@@ -5530,7 +5514,7 @@
       summary: 鑾峰彇閿�鍞��璐у垪琛�
       tags:
       - SalesReturn
-  /api/salesReturn/update/{id}:
+  /api/salesReturn/update:
     put:
       parameters:
       - description: 鏌ヨ鍙傛暟
diff --git a/pkg/ecode/code.go b/pkg/ecode/code.go
index 782289d..5a1d754 100644
--- a/pkg/ecode/code.go
+++ b/pkg/ecode/code.go
@@ -289,4 +289,7 @@
 
 	VettingExist    = 4100001 // 瀹℃壒宸插瓨鍦�
 	VettingNotExist = 4100002 // 瀹℃壒涓嶅瓨鍦�
+	VettingListErr  = 4100003 // 鑾峰彇瀹℃壒鍒楄〃澶辫触
+	VettingSetErr   = 4100004 // 璁剧疆瀹℃壒澶辫触
+
 )
diff --git a/service/index.go b/service/index.go
index fd0d2ed..2ecec7b 100644
--- a/service/index.go
+++ b/service/index.go
@@ -44,6 +44,7 @@
 	MenuService
 	DataServer
 	DepartmentService
+	VettingService
 }
 
 var ServiceGroup = new(Group)
diff --git a/service/vetting.go b/service/vetting.go
index 4fafb9e..a29c672 100644
--- a/service/vetting.go
+++ b/service/vetting.go
@@ -5,12 +5,20 @@
 	"aps_crm/pkg/ecode"
 )
 
-type Vettingservice struct{}
+type VettingService struct{}
 
-func (Vettingservice) AddVetting(vetting *model.Vetting) int {
+func (VettingService) AddVetting(vetting *model.Vetting) int {
 	err := model.NewVettingSearch().Create(vetting)
 	if err != nil {
 		return ecode.VettingExist
 	}
 	return ecode.OK
 }
+
+func (VettingService) UpdateVetting(vetting *model.Vetting) int {
+	err := model.NewVettingSearch().Update(vetting)
+	if err != nil {
+		return ecode.VettingExist
+	}
+	return ecode.OK
+}

--
Gitblit v1.8.0