From 54f4078e9462871995cf4b241df217b18cdd6e08 Mon Sep 17 00:00:00 2001
From: wangpengfei <274878379@qq.com>
Date: 星期五, 21 七月 2023 11:01:34 +0800
Subject: [PATCH] add

---
 api/v1/index.go               |    4 
 service/dataServer.go         |    7 
 api/v1/reportSource.go        |  113 +++++++
 router/reportSource.go        |   20 +
 pkg/ecode/code.go             |    9 
 docs/swagger.yaml             |  126 ++++++++
 docs/docs.go                  |  196 ++++++++++++
 docs/swagger.json             |  196 ++++++++++++
 model/response/response.go    |   10 
 model/serviceFollowup.go      |    1 
 service/reportSource.go       |   69 ++++
 service/index.go              |    3 
 model/request/reportSource.go |   15 +
 model/index.go                |    1 
 router/index.go               |    4 
 api/v1/orderManage.go         |    8 
 model/reportSource.go         |   85 +++++
 17 files changed, 844 insertions(+), 23 deletions(-)

diff --git a/api/v1/index.go b/api/v1/index.go
index 0378ded..885e94f 100644
--- a/api/v1/index.go
+++ b/api/v1/index.go
@@ -5,6 +5,7 @@
 )
 
 type Group struct {
+    ReportSourceApi
 	IsVisitApi
 	SolveRateApi
 	TimelyRateApi
@@ -106,4 +107,5 @@
 	timelyRateService           = service.ServiceGroup.TimelyRateService
 	solveRateService            = service.ServiceGroup.SolveRateService
 	isVisitService              = service.ServiceGroup.IsVisitService
-)
+   reportSourceService    = service.ServiceGroup.ReportSourceService
+)
\ No newline at end of file
diff --git a/api/v1/orderManage.go b/api/v1/orderManage.go
index 8f5856a..a295dfc 100644
--- a/api/v1/orderManage.go
+++ b/api/v1/orderManage.go
@@ -15,7 +15,7 @@
 // Add
 //
 //	@Tags		OrderManage
-//	@Summary	娣诲姞璁㈠崟
+//	@Summary	娣诲姞宸ュ崟
 //	@Produce	application/json
 //	@Param		object	body		request.AddOrderManage	true	"鏌ヨ鍙傛暟"
 //	@Success	200		{object}	contextx.Response{}
@@ -45,7 +45,7 @@
 // Delete
 //
 //	@Tags		OrderManage
-//	@Summary	鍒犻櫎璁㈠崟
+//	@Summary	鍒犻櫎宸ュ崟
 //	@Produce	application/json
 //	@Param		id	path		int	true	"鏌ヨ鍙傛暟"
 //	@Success	200	{object}	contextx.Response{}
@@ -69,7 +69,7 @@
 // Update
 //
 //	@Tags		OrderManage
-//	@Summary	鏇存柊璁㈠崟
+//	@Summary	鏇存柊宸ュ崟
 //	@Produce	application/json
 //	@Param		object	body		request.UpdateOrderManage	true	"鏌ヨ鍙傛暟"
 //	@Success	200		{object}	contextx.Response{}
@@ -101,7 +101,7 @@
 // List
 //
 //	@Tags		OrderManage
-//	@Summary	璁㈠崟鍒楄〃
+//	@Summary	宸ュ崟鍒楄〃
 //	@Produce	application/json
 //	@Success	200	{object}	contextx.Response{}
 //	@Router		/api/orderManage/list [get]
diff --git a/api/v1/reportSource.go b/api/v1/reportSource.go
new file mode 100644
index 0000000..c691e2d
--- /dev/null
+++ b/api/v1/reportSource.go
@@ -0,0 +1,113 @@
+
+package v1
+
+import (
+	"aps_crm/model"
+	"aps_crm/model/request"
+	"aps_crm/model/response"
+	"aps_crm/pkg/contextx"
+	"aps_crm/pkg/ecode"
+	"github.com/gin-gonic/gin"
+	"strconv"
+)
+
+type ReportSourceApi struct{}
+
+// Add
+//
+//	@Tags		ReportSource
+//	@Summary	娣诲姞鎶ヨ〃鏉ユ簮
+//	@Produce	application/json
+//	@Param		object	body		request.AddReportSource	true	"鏌ヨ鍙傛暟"
+//	@Success	200		{object}	contextx.Response{}
+//	@Router		/api/reportSource/add [post]
+func (s *ReportSourceApi) Add(c *gin.Context) {
+	var params request.AddReportSource
+	ctx, ok := contextx.NewContext(c, &params)
+	if !ok {
+		return
+	}
+
+	reportSource := new(model.ReportSource)
+	reportSource.Name = params.Name
+
+	errCode := reportSourceService.AddReportSource(reportSource)
+	if errCode != ecode.OK {
+		ctx.Fail(errCode)
+		return
+	}
+
+	ctx.Ok()
+}
+
+// Delete
+//
+//	@Tags		ReportSource
+//	@Summary	鍒犻櫎鎶ヨ〃鏉ユ簮
+//	@Produce	application/json
+//	@Param		id	path		int	true	"鏌ヨ鍙傛暟"
+//	@Success	200	{object}	contextx.Response{}
+//	@Router		/api/reportSource/delete/{id} [delete]
+func (s *ReportSourceApi) Delete(c *gin.Context) {
+	ctx, ok := contextx.NewContext(c, nil)
+	if !ok {
+		return
+	}
+
+	id, _ := strconv.Atoi(c.Param("id"))
+	errCode := reportSourceService.DeleteReportSource(id)
+	if errCode != ecode.OK {
+		ctx.Fail(errCode)
+		return
+	}
+
+	ctx.Ok()
+}
+
+// Update
+//
+//	@Tags		ReportSource
+//	@Summary	鏇存柊鎶ヨ〃鏉ユ簮
+//	@Produce	application/json
+//	@Param		object	body		request.UpdateReportSources	true	"鏌ヨ鍙傛暟"
+//	@Success	200		{object}	contextx.Response{}
+//	@Router		/api/reportSource/update [put]
+func (s *ReportSourceApi) Update(c *gin.Context) {
+	var params request.UpdateReportSources
+	ctx, ok := contextx.NewContext(c, &params)
+	if !ok {
+		return
+	}
+
+	errCode := reportSourceService.UpdateReportSource(params.ReportSources)
+	if errCode != ecode.OK {
+		ctx.Fail(errCode)
+		return
+	}
+
+	ctx.Ok()
+}
+
+// List
+//
+//	@Tags		ReportSource
+//	@Summary	鑾峰彇鎶ヨ〃鏉ユ簮鍒楄〃
+//	@Produce	application/json
+//	@Success	200	{object}	contextx.Response{data=response.ReportSourceResponse}
+//	@Router		/api/reportSource/list [get]
+func (s *ReportSourceApi) List(c *gin.Context) {
+	ctx, ok := contextx.NewContext(c, nil)
+	if !ok {
+		return
+	}
+
+	reportSources, errCode := reportSourceService.GetReportSourceList()
+	if errCode != ecode.OK {
+		ctx.Fail(errCode)
+		return
+	}
+
+	ctx.OkWithDetailed(response.ReportSourceResponse{
+		List: reportSources,
+	})
+}
diff --git a/docs/docs.go b/docs/docs.go
index 0cb0f32..351d582 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -2331,7 +2331,7 @@
                 "tags": [
                     "OrderManage"
                 ],
-                "summary": "娣诲姞璁㈠崟",
+                "summary": "娣诲姞宸ュ崟",
                 "parameters": [
                     {
                         "description": "鏌ヨ鍙傛暟",
@@ -2361,7 +2361,7 @@
                 "tags": [
                     "OrderManage"
                 ],
-                "summary": "鍒犻櫎璁㈠崟",
+                "summary": "鍒犻櫎宸ュ崟",
                 "parameters": [
                     {
                         "type": "integer",
@@ -2389,7 +2389,7 @@
                 "tags": [
                     "OrderManage"
                 ],
-                "summary": "璁㈠崟鍒楄〃",
+                "summary": "宸ュ崟鍒楄〃",
                 "responses": {
                     "200": {
                         "description": "OK",
@@ -2408,7 +2408,7 @@
                 "tags": [
                     "OrderManage"
                 ],
-                "summary": "鏇存柊璁㈠崟",
+                "summary": "鏇存柊宸ュ崟",
                 "parameters": [
                     {
                         "description": "鏌ヨ鍙傛暟",
@@ -3316,6 +3316,125 @@
                         "required": true,
                         "schema": {
                             "$ref": "#/definitions/request.UpdateRegularCustomersList"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/contextx.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/api/reportSource/add": {
+            "post": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "ReportSource"
+                ],
+                "summary": "娣诲姞鎶ヨ〃鏉ユ簮",
+                "parameters": [
+                    {
+                        "description": "鏌ヨ鍙傛暟",
+                        "name": "object",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/request.AddReportSource"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/contextx.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/api/reportSource/delete/{id}": {
+            "delete": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "ReportSource"
+                ],
+                "summary": "鍒犻櫎鎶ヨ〃鏉ユ簮",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "鏌ヨ鍙傛暟",
+                        "name": "id",
+                        "in": "path",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/contextx.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/api/reportSource/list": {
+            "get": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "ReportSource"
+                ],
+                "summary": "鑾峰彇鎶ヨ〃鏉ユ簮鍒楄〃",
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "allOf": [
+                                {
+                                    "$ref": "#/definitions/contextx.Response"
+                                },
+                                {
+                                    "type": "object",
+                                    "properties": {
+                                        "data": {
+                                            "$ref": "#/definitions/response.ReportSourceResponse"
+                                        }
+                                    }
+                                }
+                            ]
+                        }
+                    }
+                }
+            }
+        },
+        "/api/reportSource/update": {
+            "put": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "ReportSource"
+                ],
+                "summary": "鏇存柊鎶ヨ〃鏉ユ簮",
+                "parameters": [
+                    {
+                        "description": "鏌ヨ鍙傛暟",
+                        "name": "object",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/request.UpdateReportSources"
                         }
                     }
                 ],
@@ -6342,6 +6461,17 @@
                 }
             }
         },
+        "model.ReportSource": {
+            "type": "object",
+            "properties": {
+                "id": {
+                    "type": "integer"
+                },
+                "name": {
+                    "type": "string"
+                }
+            }
+        },
         "model.SaleChance": {
             "type": "object",
             "properties": {
@@ -7421,6 +7551,17 @@
             }
         },
         "request.AddRegularCustomers": {
+            "type": "object",
+            "required": [
+                "name"
+            ],
+            "properties": {
+                "name": {
+                    "type": "string"
+                }
+            }
+        },
+        "request.AddReportSource": {
             "type": "object",
             "required": [
                 "name"
@@ -9180,6 +9321,35 @@
                 }
             }
         },
+        "request.UpdateReportSource": {
+            "type": "object",
+            "required": [
+                "id",
+                "name"
+            ],
+            "properties": {
+                "id": {
+                    "type": "integer"
+                },
+                "name": {
+                    "type": "string"
+                }
+            }
+        },
+        "request.UpdateReportSources": {
+            "type": "object",
+            "required": [
+                "report_source"
+            ],
+            "properties": {
+                "report_source": {
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/request.UpdateReportSource"
+                    }
+                }
+            }
+        },
         "request.UpdateSaleChance": {
             "type": "object",
             "required": [
@@ -10024,6 +10194,13 @@
                         "$ref": "#/definitions/model.RegularCustomers"
                     }
                 },
+                "reportSource": {
+                    "description": "鎶ヨ〃鏉ユ簮",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.ReportSource"
+                    }
+                },
                 "sale_stage": {
                     "description": "閿�鍞樁娈�",
                     "type": "array",
@@ -10251,6 +10428,17 @@
                 }
             }
         },
+        "response.ReportSourceResponse": {
+            "type": "object",
+            "properties": {
+                "list": {
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.ReportSource"
+                    }
+                }
+            }
+        },
         "response.SaleChanceResponse": {
             "type": "object",
             "properties": {
diff --git a/docs/swagger.json b/docs/swagger.json
index 92f5a6d..708e402 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -2319,7 +2319,7 @@
                 "tags": [
                     "OrderManage"
                 ],
-                "summary": "娣诲姞璁㈠崟",
+                "summary": "娣诲姞宸ュ崟",
                 "parameters": [
                     {
                         "description": "鏌ヨ鍙傛暟",
@@ -2349,7 +2349,7 @@
                 "tags": [
                     "OrderManage"
                 ],
-                "summary": "鍒犻櫎璁㈠崟",
+                "summary": "鍒犻櫎宸ュ崟",
                 "parameters": [
                     {
                         "type": "integer",
@@ -2377,7 +2377,7 @@
                 "tags": [
                     "OrderManage"
                 ],
-                "summary": "璁㈠崟鍒楄〃",
+                "summary": "宸ュ崟鍒楄〃",
                 "responses": {
                     "200": {
                         "description": "OK",
@@ -2396,7 +2396,7 @@
                 "tags": [
                     "OrderManage"
                 ],
-                "summary": "鏇存柊璁㈠崟",
+                "summary": "鏇存柊宸ュ崟",
                 "parameters": [
                     {
                         "description": "鏌ヨ鍙傛暟",
@@ -3304,6 +3304,125 @@
                         "required": true,
                         "schema": {
                             "$ref": "#/definitions/request.UpdateRegularCustomersList"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/contextx.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/api/reportSource/add": {
+            "post": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "ReportSource"
+                ],
+                "summary": "娣诲姞鎶ヨ〃鏉ユ簮",
+                "parameters": [
+                    {
+                        "description": "鏌ヨ鍙傛暟",
+                        "name": "object",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/request.AddReportSource"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/contextx.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/api/reportSource/delete/{id}": {
+            "delete": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "ReportSource"
+                ],
+                "summary": "鍒犻櫎鎶ヨ〃鏉ユ簮",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "鏌ヨ鍙傛暟",
+                        "name": "id",
+                        "in": "path",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/contextx.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/api/reportSource/list": {
+            "get": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "ReportSource"
+                ],
+                "summary": "鑾峰彇鎶ヨ〃鏉ユ簮鍒楄〃",
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "allOf": [
+                                {
+                                    "$ref": "#/definitions/contextx.Response"
+                                },
+                                {
+                                    "type": "object",
+                                    "properties": {
+                                        "data": {
+                                            "$ref": "#/definitions/response.ReportSourceResponse"
+                                        }
+                                    }
+                                }
+                            ]
+                        }
+                    }
+                }
+            }
+        },
+        "/api/reportSource/update": {
+            "put": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "ReportSource"
+                ],
+                "summary": "鏇存柊鎶ヨ〃鏉ユ簮",
+                "parameters": [
+                    {
+                        "description": "鏌ヨ鍙傛暟",
+                        "name": "object",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/request.UpdateReportSources"
                         }
                     }
                 ],
@@ -6330,6 +6449,17 @@
                 }
             }
         },
+        "model.ReportSource": {
+            "type": "object",
+            "properties": {
+                "id": {
+                    "type": "integer"
+                },
+                "name": {
+                    "type": "string"
+                }
+            }
+        },
         "model.SaleChance": {
             "type": "object",
             "properties": {
@@ -7409,6 +7539,17 @@
             }
         },
         "request.AddRegularCustomers": {
+            "type": "object",
+            "required": [
+                "name"
+            ],
+            "properties": {
+                "name": {
+                    "type": "string"
+                }
+            }
+        },
+        "request.AddReportSource": {
             "type": "object",
             "required": [
                 "name"
@@ -9168,6 +9309,35 @@
                 }
             }
         },
+        "request.UpdateReportSource": {
+            "type": "object",
+            "required": [
+                "id",
+                "name"
+            ],
+            "properties": {
+                "id": {
+                    "type": "integer"
+                },
+                "name": {
+                    "type": "string"
+                }
+            }
+        },
+        "request.UpdateReportSources": {
+            "type": "object",
+            "required": [
+                "report_source"
+            ],
+            "properties": {
+                "report_source": {
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/request.UpdateReportSource"
+                    }
+                }
+            }
+        },
         "request.UpdateSaleChance": {
             "type": "object",
             "required": [
@@ -10012,6 +10182,13 @@
                         "$ref": "#/definitions/model.RegularCustomers"
                     }
                 },
+                "reportSource": {
+                    "description": "鎶ヨ〃鏉ユ簮",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.ReportSource"
+                    }
+                },
                 "sale_stage": {
                     "description": "閿�鍞樁娈�",
                     "type": "array",
@@ -10239,6 +10416,17 @@
                 }
             }
         },
+        "response.ReportSourceResponse": {
+            "type": "object",
+            "properties": {
+                "list": {
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.ReportSource"
+                    }
+                }
+            }
+        },
         "response.SaleChanceResponse": {
             "type": "object",
             "properties": {
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index 34747d8..4040537 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -558,6 +558,13 @@
       name:
         type: string
     type: object
+  model.ReportSource:
+    properties:
+      id:
+        type: integer
+      name:
+        type: string
+    type: object
   model.SaleChance:
     properties:
       advantages:
@@ -1278,6 +1285,13 @@
     - name
     type: object
   request.AddRegularCustomers:
+    properties:
+      name:
+        type: string
+    required:
+    - name
+    type: object
+  request.AddReportSource:
     properties:
       name:
         type: string
@@ -2469,6 +2483,25 @@
     required:
     - regularCustomers
     type: object
+  request.UpdateReportSource:
+    properties:
+      id:
+        type: integer
+      name:
+        type: string
+    required:
+    - id
+    - name
+    type: object
+  request.UpdateReportSources:
+    properties:
+      report_source:
+        items:
+          $ref: '#/definitions/request.UpdateReportSource'
+        type: array
+    required:
+    - report_source
+    type: object
   request.UpdateSaleChance:
     properties:
       advantages:
@@ -3037,6 +3070,11 @@
         items:
           $ref: '#/definitions/model.RegularCustomers'
         type: array
+      reportSource:
+        description: 鎶ヨ〃鏉ユ簮
+        items:
+          $ref: '#/definitions/model.ReportSource'
+        type: array
       sale_stage:
         description: 閿�鍞樁娈�
         items:
@@ -3183,6 +3221,13 @@
       list:
         items:
           $ref: '#/definitions/model.RegularCustomers'
+        type: array
+    type: object
+  response.ReportSourceResponse:
+    properties:
+      list:
+        items:
+          $ref: '#/definitions/model.ReportSource'
         type: array
     type: object
   response.SaleChanceResponse:
@@ -4721,7 +4766,7 @@
           description: OK
           schema:
             $ref: '#/definitions/contextx.Response'
-      summary: 娣诲姞璁㈠崟
+      summary: 娣诲姞宸ュ崟
       tags:
       - OrderManage
   /api/orderManage/delete/{id}:
@@ -4739,7 +4784,7 @@
           description: OK
           schema:
             $ref: '#/definitions/contextx.Response'
-      summary: 鍒犻櫎璁㈠崟
+      summary: 鍒犻櫎宸ュ崟
       tags:
       - OrderManage
   /api/orderManage/list:
@@ -4751,7 +4796,7 @@
           description: OK
           schema:
             $ref: '#/definitions/contextx.Response'
-      summary: 璁㈠崟鍒楄〃
+      summary: 宸ュ崟鍒楄〃
       tags:
       - OrderManage
   /api/orderManage/update:
@@ -4770,7 +4815,7 @@
           description: OK
           schema:
             $ref: '#/definitions/contextx.Response'
-      summary: 鏇存柊璁㈠崟
+      summary: 鏇存柊宸ュ崟
       tags:
       - OrderManage
   /api/plan/add:
@@ -5329,6 +5374,79 @@
       summary: 鏇存柊甯稿
       tags:
       - RegularCustomers
+  /api/reportSource/add:
+    post:
+      parameters:
+      - description: 鏌ヨ鍙傛暟
+        in: body
+        name: object
+        required: true
+        schema:
+          $ref: '#/definitions/request.AddReportSource'
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/contextx.Response'
+      summary: 娣诲姞鎶ヨ〃鏉ユ簮
+      tags:
+      - ReportSource
+  /api/reportSource/delete/{id}:
+    delete:
+      parameters:
+      - description: 鏌ヨ鍙傛暟
+        in: path
+        name: id
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/contextx.Response'
+      summary: 鍒犻櫎鎶ヨ〃鏉ユ簮
+      tags:
+      - ReportSource
+  /api/reportSource/list:
+    get:
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            allOf:
+            - $ref: '#/definitions/contextx.Response'
+            - properties:
+                data:
+                  $ref: '#/definitions/response.ReportSourceResponse'
+              type: object
+      summary: 鑾峰彇鎶ヨ〃鏉ユ簮鍒楄〃
+      tags:
+      - ReportSource
+  /api/reportSource/update:
+    put:
+      parameters:
+      - description: 鏌ヨ鍙傛暟
+        in: body
+        name: object
+        required: true
+        schema:
+          $ref: '#/definitions/request.UpdateReportSources'
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/contextx.Response'
+      summary: 鏇存柊鎶ヨ〃鏉ユ簮
+      tags:
+      - ReportSource
   /api/saleChance/add:
     post:
       parameters:
diff --git a/model/index.go b/model/index.go
index c955be5..83e3377 100644
--- a/model/index.go
+++ b/model/index.go
@@ -68,6 +68,7 @@
 		SolveRate{},
         IsVisit{},
         IsVisit{},
+        ReportSource{},
 	)
 	return err
 }
\ No newline at end of file
diff --git a/model/reportSource.go b/model/reportSource.go
new file mode 100644
index 0000000..5a4e15f
--- /dev/null
+++ b/model/reportSource.go
@@ -0,0 +1,85 @@
+package model
+
+import (
+	"aps_crm/pkg/mysqlx"
+	"gorm.io/gorm"
+)
+
+type (
+	// ReportSource 鍟嗘満闃舵
+	ReportSource struct {
+		Id   int    `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
+		Name string `json:"name" gorm:"column:name;type:varchar(255);comment:鍟嗘満闃舵鍚嶇О"`
+	}
+   
+	ReportSourceSearch struct {
+		ReportSource
+		Orm *gorm.DB
+	}
+)
+
+func (ReportSource) TableName() string {
+	return "report_source"
+}
+
+func NewReportSourceSearch() *ReportSourceSearch {
+	return &ReportSourceSearch{
+		Orm: mysqlx.GetDB(),
+	}
+}
+
+func (slf *ReportSourceSearch) build() *gorm.DB {
+	var db = slf.Orm.Model(&ReportSource{})
+	if slf.Id != 0 {
+		db = db.Where("id = ?", slf.Id)
+	}
+	if slf.Name != "" {
+		db = db.Where("name = ?", slf.Name)
+	}
+
+	return db
+}
+
+func (slf *ReportSourceSearch) Create(record *ReportSource) error {
+	var db = slf.build()
+	return db.Create(record).Error
+}
+
+func (slf *ReportSourceSearch) Delete() error {
+	var db = slf.build()
+	return db.Delete(&ReportSource{}).Error
+}
+
+func (slf *ReportSourceSearch) Update(record *ReportSource) error {
+	var db = slf.build()
+	return db.Updates(record).Error
+}
+
+func (slf *ReportSourceSearch) Find() (*ReportSource, error) {
+	var db = slf.build()
+	var record = new(ReportSource)
+	err := db.First(record).Error
+	return record, err
+}
+
+func (slf *ReportSourceSearch) FindAll() ([]*ReportSource, error) {
+	var db = slf.build()
+	var records = make([]*ReportSource, 0)
+	err := db.Find(&records).Error
+	return records, err
+}
+
+func (slf *ReportSourceSearch) SetId(id int) *ReportSourceSearch {
+	slf.Id = id
+	return slf
+}
+
+func (slf *ReportSourceSearch) SetName(name string) *ReportSourceSearch {
+	slf.Name = name
+	return slf
+}
+
+func (slf *ReportSourceSearch) Updates(data map[string]interface{}) error {
+	var db = slf.build()
+	return db.Updates(data).Error
+}
diff --git a/model/request/reportSource.go b/model/request/reportSource.go
new file mode 100644
index 0000000..9ebce95
--- /dev/null
+++ b/model/request/reportSource.go
@@ -0,0 +1,15 @@
+
+package request
+
+type AddReportSource struct {
+	Name string `  json:"name" binding:"required"`
+}
+
+type UpdateReportSource struct {
+	Id   int    `json:"id" binding:"required"`
+	Name string `json:"name" binding:"required"`
+}
+
+type UpdateReportSources struct {
+	ReportSources []*UpdateReportSource `json:"report_source" binding:"required"`
+}
diff --git a/model/response/response.go b/model/response/response.go
index 138e921..1831323 100644
--- a/model/response/response.go
+++ b/model/response/response.go
@@ -180,6 +180,10 @@
 
 	DataResponse struct {
 
+		// 鎶ヨ〃鏉ユ簮
+		ReportSource []*model.ReportSource `json:"reportSource"`
+
+
 		// 鏈嶅姟浜哄憳鏄惁鏉ヨ繃
 		IsVisit []*model.IsVisit `json:"isVisit"`
 
@@ -246,4 +250,8 @@
 	IsVisitResponse struct {
 		List []*model.IsVisit `json:"list"`
 	}
-)
+
+	ReportSourceResponse struct {
+		List []*model.ReportSource `json:"list"`
+	}
+)
\ No newline at end of file
diff --git a/model/serviceFollowup.go b/model/serviceFollowup.go
index c534dcf..6a3fc37 100644
--- a/model/serviceFollowup.go
+++ b/model/serviceFollowup.go
@@ -85,7 +85,6 @@
 	return slf
 }
 
-// 鍙婃椂鐜� 瑙e喅鐜� 婊℃剰搴� 鏈嶅姟浜哄憳鏄惁鏉ヨ繃 锛堟湇鍔″洖璁垮崟锛�
 // 宸ュ崟绫诲瀷 鎶ヤ慨鏉ユ簮锛堝伐鍗曠鐞嗭級
 // 鍚堝悓绫诲瀷 鍚堝悓鐘舵�侊紙鏈嶅姟鍚堝悓锛�
 // 浠樻鏂瑰紡 鏄惁寮�绁� 璐︽埛锛堥攢鍞��娆惧崟锛�
diff --git a/pkg/ecode/code.go b/pkg/ecode/code.go
index b6c7fc9..a59546c 100644
--- a/pkg/ecode/code.go
+++ b/pkg/ecode/code.go
@@ -316,4 +316,11 @@
 	IsVisitSetErr    = 4500004 // 璁剧疆鏈嶅姟浜哄憳鏄惁鏉ヨ繃澶辫触
 	IsVisitUpdateErr = 4500005 // 鏇存柊鏈嶅姟浜哄憳鏄惁鏉ヨ繃澶辫触
 
-)
+
+	ReportSourceExist     = 4400001 // 鎶ヨ〃鏉ユ簮宸插瓨鍦�
+	ReportSourceNotExist  = 4400002 // 鎶ヨ〃鏉ユ簮涓嶅瓨鍦�
+	ReportSourceListErr   = 4400003 // 鑾峰彇鎶ヨ〃鏉ユ簮鍒楄〃澶辫触
+	ReportSourceSetErr    = 4400004 // 璁剧疆鎶ヨ〃鏉ユ簮澶辫触
+	ReportSourceUpdateErr = 4400005 // 鏇存柊鎶ヨ〃鏉ユ簮澶辫触
+
+)
\ No newline at end of file
diff --git a/router/index.go b/router/index.go
index 8a603b8..34d7365 100644
--- a/router/index.go
+++ b/router/index.go
@@ -11,6 +11,7 @@
 )
 
 type Group struct {
+    ReportSourceRouter
 	IsVisitRouter
 	SolveRateRouter
 	TimelyRateRouter
@@ -135,6 +136,7 @@
 		routerGroup.InitTimelyRateRouter(PrivateGroup)
 		routerGroup.InitSolveRateRouter(PrivateGroup)
 		routerGroup.InitIsVisitRouter(PrivateGroup)
+        routerGroup.InitReportSourceRouter(PrivateGroup)
 	}
 	return Router
-}
+}
\ No newline at end of file
diff --git a/router/reportSource.go b/router/reportSource.go
new file mode 100644
index 0000000..2ef698e
--- /dev/null
+++ b/router/reportSource.go
@@ -0,0 +1,20 @@
+
+package router
+
+import (
+	v1 "aps_crm/api/v1"
+	"github.com/gin-gonic/gin"
+)
+
+type ReportSourceRouter struct{}
+
+func (s *ReportSourceRouter) InitReportSourceRouter(router *gin.RouterGroup) {
+	reportSourceRouter := router.Group("reportSource")
+	reportSourceApi := v1.ApiGroup.ReportSourceApi
+	{
+		reportSourceRouter.POST("add", reportSourceApi.Add)             // 娣诲姞$CName$
+		reportSourceRouter.DELETE("delete/:id", reportSourceApi.Delete) // 鍒犻櫎$CName$
+		reportSourceRouter.PUT("update", reportSourceApi.Update)        // 鏇存柊$CName$
+		reportSourceRouter.GET("list", reportSourceApi.List)            // 鑾峰彇$CName$鍒楄〃
+	}
+}
\ No newline at end of file
diff --git a/service/dataServer.go b/service/dataServer.go
index d9af969..9043420 100644
--- a/service/dataServer.go
+++ b/service/dataServer.go
@@ -96,7 +96,12 @@
 	isVisitList, _ := ServiceGroup.GetIsVisitList()
 	data.IsVisit = isVisitList
 
+	// get ReportSource list
+	reportSourceList, _ := ServiceGroup.GetReportSourceList()
+	data.ReportSource = reportSourceList
+
+
 	errCode = ecode.OK
 
 	return
-}
+}
\ No newline at end of file
diff --git a/service/index.go b/service/index.go
index e8c2d4f..45468dc 100644
--- a/service/index.go
+++ b/service/index.go
@@ -49,6 +49,7 @@
 	TimelyRateService
 	SolveRateService
 	IsVisitService
+    ReportSourceService
 }
 
-var ServiceGroup = new(Group)
+var ServiceGroup = new(Group)
\ No newline at end of file
diff --git a/service/reportSource.go b/service/reportSource.go
new file mode 100644
index 0000000..ccec0aa
--- /dev/null
+++ b/service/reportSource.go
@@ -0,0 +1,69 @@
+
+package service
+
+import (
+	"aps_crm/model"
+	"aps_crm/model/request"
+	"aps_crm/pkg/ecode"
+)
+
+type ReportSourceService struct{}
+
+func (ReportSourceService) AddReportSource(reportSource *model.ReportSource) int {
+	err := model.NewReportSourceSearch().Create(reportSource)
+	if err != nil {
+		return ecode.ReportSourceExist
+	}
+
+	return ecode.OK
+}
+
+func (ReportSourceService) DeleteReportSource(id int) int {
+	_, err := model.NewReportSourceSearch().SetId(id).Find()
+	if err != nil {
+		return ecode.ReportSourceNotExist
+	}
+
+	err = model.NewReportSourceSearch().SetId(id).Delete()
+	if err != nil {
+		return ecode.ReportSourceNotExist
+	}
+	return ecode.OK
+}
+
+func (ReportSourceService) GetReportSourceList() ([]*model.ReportSource, int) {
+	list, err := model.NewReportSourceSearch().FindAll()
+	if err != nil {
+		return nil, ecode.ReportSourceListErr
+	}
+
+	return list, ecode.OK
+}
+
+func (ReportSourceService) UpdateReportSource(reportSources []*request.UpdateReportSource) int {
+	for _, v := range reportSources {
+		// check reportSource exist
+		_, err := model.NewReportSourceSearch().SetId(v.Id).Find()
+		if err != nil {
+			return ecode.ReportSourceNotExist
+		}
+
+		err = model.NewReportSourceSearch().SetId(v.Id).Updates(map[string]interface{}{
+			"name": v.Name,
+		})
+		if err != nil {
+			return ecode.ReportSourceSetErr
+		}
+	}
+
+	return ecode.OK
+}
+
+func (ReportSourceService) GetReportSourceDetail(id int) (*model.ReportSource, int) {
+	reportSource, err := model.NewReportSourceSearch().SetId(id).Find()
+	if err != nil {
+		return nil, ecode.ReportSourceNotExist
+	}
+
+	return reportSource, ecode.OK
+}

--
Gitblit v1.8.0