From 6a8a20e02f0530284296d3373d44aa218fc85210 Mon Sep 17 00:00:00 2001
From: wangpengfei <274878379@qq.com>
Date: 星期五, 21 七月 2023 10:33:32 +0800
Subject: [PATCH] add

---
 api/v1/index.go            |    2 
 service/dataServer.go      |    7 
 model/solveRate.go         |   85 +++++
 service/solveRate.go       |   69 ++++
 pkg/ecode/code.go          |    5 
 docs/swagger.yaml          |  125 ++++++++
 docs/docs.go               |  197 +++++++++++++
 docs/swagger.json          |  197 +++++++++++++
 model/response/response.go |    6 
 model/serviceFollowup.go   |    2 
 model/request/solveRate.go |   15 +
 service/index.go           |    1 
 api/v1/solveRate.go        |  112 +++++++
 router/solveRate.go        |   20 +
 model/index.go             |    1 
 router/index.go            |    2 
 api/v1/serviceFollowup.go  |    2 
 17 files changed, 842 insertions(+), 6 deletions(-)

diff --git a/api/v1/index.go b/api/v1/index.go
index 7142d2e..dc8b10b 100644
--- a/api/v1/index.go
+++ b/api/v1/index.go
@@ -5,6 +5,7 @@
 )
 
 type Group struct {
+	SolveRateApi
 	TimelyRateApi
 	BaseApi
 	JwtApi
@@ -102,4 +103,5 @@
 	vettingService              = service.ServiceGroup.VettingService
 	satisfactionService         = service.ServiceGroup.SatisfactionService
 	timelyRateService           = service.ServiceGroup.TimelyRateService
+	solveRateService            = service.ServiceGroup.SolveRateService
 )
diff --git a/api/v1/serviceFollowup.go b/api/v1/serviceFollowup.go
index 2157325..e124cc7 100644
--- a/api/v1/serviceFollowup.go
+++ b/api/v1/serviceFollowup.go
@@ -141,7 +141,7 @@
 		PlanId:         serviceFollowup.PlanId,
 		SatisfactionId: serviceFollowup.Satisfaction,
 		TimelyRateId:   serviceFollowup.TimelyRate,
-		SolveRate:      serviceFollowup.SolveRate,
+		SolveRateId:    serviceFollowup.SolveRate,
 		IsVisit:        serviceFollowup.IsVisit,
 		OldMemberId:    serviceFollowup.OldMemberId,
 		Remark:         serviceFollowup.Remark,
diff --git a/api/v1/solveRate.go b/api/v1/solveRate.go
new file mode 100644
index 0000000..d7c931c
--- /dev/null
+++ b/api/v1/solveRate.go
@@ -0,0 +1,112 @@
+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 SolveRateApi struct{}
+
+// Add
+//
+//	@Tags		SolveRate
+//	@Summary	娣诲姞瑙e喅鐜�
+//	@Produce	application/json
+//	@Param		object	body		request.AddSolveRate	true	"鏌ヨ鍙傛暟"
+//	@Success	200		{object}	contextx.Response{}
+//	@Router		/api/solveRate/add [post]
+func (s *SolveRateApi) Add(c *gin.Context) {
+	var params request.AddSolveRate
+	ctx, ok := contextx.NewContext(c, &params)
+	if !ok {
+		return
+	}
+
+	solveRate := new(model.SolveRate)
+	solveRate.Name = params.Name
+
+	errCode := solveRateService.AddSolveRate(solveRate)
+	if errCode != ecode.OK {
+		ctx.Fail(errCode)
+		return
+	}
+
+	ctx.Ok()
+}
+
+// Delete
+//
+//	@Tags		SolveRate
+//	@Summary	鍒犻櫎瑙e喅鐜�
+//	@Produce	application/json
+//	@Param		id	path		int	true	"鏌ヨ鍙傛暟"
+//	@Success	200	{object}	contextx.Response{}
+//	@Router		/api/solveRate/delete/{id} [delete]
+func (s *SolveRateApi) Delete(c *gin.Context) {
+	ctx, ok := contextx.NewContext(c, nil)
+	if !ok {
+		return
+	}
+
+	id, _ := strconv.Atoi(c.Param("id"))
+	errCode := solveRateService.DeleteSolveRate(id)
+	if errCode != ecode.OK {
+		ctx.Fail(errCode)
+		return
+	}
+
+	ctx.Ok()
+}
+
+// Update
+//
+//	@Tags		SolveRate
+//	@Summary	鏇存柊瑙e喅鐜�
+//	@Produce	application/json
+//	@Param		object	body		request.UpdateSolveRates	true	"鏌ヨ鍙傛暟"
+//	@Success	200		{object}	contextx.Response{}
+//	@Router		/api/solveRate/update [put]
+func (s *SolveRateApi) Update(c *gin.Context) {
+	var params request.UpdateSolveRates
+	ctx, ok := contextx.NewContext(c, &params)
+	if !ok {
+		return
+	}
+
+	errCode := solveRateService.UpdateSolveRate(params.SolveRates)
+	if errCode != ecode.OK {
+		ctx.Fail(errCode)
+		return
+	}
+
+	ctx.Ok()
+}
+
+// List
+//
+//	@Tags		SolveRate
+//	@Summary	鑾峰彇瑙e喅鐜囧垪琛�
+//	@Produce	application/json
+//	@Success	200	{object}	contextx.Response{data=response.SolveRateResponse}
+//	@Router		/api/solveRate/list [get]
+func (s *SolveRateApi) List(c *gin.Context) {
+	ctx, ok := contextx.NewContext(c, nil)
+	if !ok {
+		return
+	}
+
+	solveRates, errCode := solveRateService.GetSolveRateList()
+	if errCode != ecode.OK {
+		ctx.Fail(errCode)
+		return
+	}
+
+	ctx.OkWithDetailed(response.SolveRateResponse{
+		List: solveRates,
+	})
+}
diff --git a/docs/docs.go b/docs/docs.go
index eeb01be..75ba54b 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -4638,6 +4638,125 @@
                 }
             }
         },
+        "/api/solveRate/add": {
+            "post": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "SolveRate"
+                ],
+                "summary": "娣诲姞瑙e喅鐜�",
+                "parameters": [
+                    {
+                        "description": "鏌ヨ鍙傛暟",
+                        "name": "object",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/request.AddSolveRate"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/contextx.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/api/solveRate/delete/{id}": {
+            "delete": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "SolveRate"
+                ],
+                "summary": "鍒犻櫎瑙e喅鐜�",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "鏌ヨ鍙傛暟",
+                        "name": "id",
+                        "in": "path",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/contextx.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/api/solveRate/list": {
+            "get": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "SolveRate"
+                ],
+                "summary": "鑾峰彇瑙e喅鐜囧垪琛�",
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "allOf": [
+                                {
+                                    "$ref": "#/definitions/contextx.Response"
+                                },
+                                {
+                                    "type": "object",
+                                    "properties": {
+                                        "data": {
+                                            "$ref": "#/definitions/response.SolveRateResponse"
+                                        }
+                                    }
+                                }
+                            ]
+                        }
+                    }
+                }
+            }
+        },
+        "/api/solveRate/update": {
+            "put": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "SolveRate"
+                ],
+                "summary": "鏇存柊瑙e喅鐜�",
+                "parameters": [
+                    {
+                        "description": "鏌ヨ鍙傛暟",
+                        "name": "object",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/request.UpdateSolveRates"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/contextx.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/api/status/add": {
             "post": {
                 "produces": [
@@ -6586,11 +6705,22 @@
                 "serviceId": {
                     "type": "integer"
                 },
-                "solveRate": {
+                "solveRateId": {
                     "type": "integer"
                 },
                 "timelyRateId": {
                     "type": "integer"
+                }
+            }
+        },
+        "model.SolveRate": {
+            "type": "object",
+            "properties": {
+                "id": {
+                    "type": "integer"
+                },
+                "name": {
+                    "type": "string"
                 }
             }
         },
@@ -7580,6 +7710,17 @@
                 },
                 "timelyRate": {
                     "type": "integer"
+                }
+            }
+        },
+        "request.AddSolveRate": {
+            "type": "object",
+            "required": [
+                "name"
+            ],
+            "properties": {
+                "name": {
+                    "type": "string"
                 }
             }
         },
@@ -9386,6 +9527,35 @@
                 }
             }
         },
+        "request.UpdateSolveRate": {
+            "type": "object",
+            "required": [
+                "id",
+                "name"
+            ],
+            "properties": {
+                "id": {
+                    "type": "integer"
+                },
+                "name": {
+                    "type": "string"
+                }
+            }
+        },
+        "request.UpdateSolveRates": {
+            "type": "object",
+            "required": [
+                "solve_rate"
+            ],
+            "properties": {
+                "solve_rate": {
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/request.UpdateSolveRate"
+                    }
+                }
+            }
+        },
         "request.UpdateStatus": {
             "type": "object",
             "required": [
@@ -9704,6 +9874,20 @@
                     "items": {
                         "$ref": "#/definitions/model.Satisfaction"
                     }
+                },
+                "solve_rate": {
+                    "description": "瑙e喅鐜�",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.SolveRate"
+                    }
+                },
+                "timely_rate": {
+                    "description": "鍙婃椂鐜�",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.TimelyRate"
+                    }
                 }
             }
         },
@@ -10011,6 +10195,17 @@
                 }
             }
         },
+        "response.SolveRateResponse": {
+            "type": "object",
+            "properties": {
+                "list": {
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.SolveRate"
+                    }
+                }
+            }
+        },
         "response.SubOrderResponse": {
             "type": "object",
             "properties": {
diff --git a/docs/swagger.json b/docs/swagger.json
index fc1e881..4d1423a 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -4626,6 +4626,125 @@
                 }
             }
         },
+        "/api/solveRate/add": {
+            "post": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "SolveRate"
+                ],
+                "summary": "娣诲姞瑙e喅鐜�",
+                "parameters": [
+                    {
+                        "description": "鏌ヨ鍙傛暟",
+                        "name": "object",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/request.AddSolveRate"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/contextx.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/api/solveRate/delete/{id}": {
+            "delete": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "SolveRate"
+                ],
+                "summary": "鍒犻櫎瑙e喅鐜�",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "鏌ヨ鍙傛暟",
+                        "name": "id",
+                        "in": "path",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/contextx.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/api/solveRate/list": {
+            "get": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "SolveRate"
+                ],
+                "summary": "鑾峰彇瑙e喅鐜囧垪琛�",
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "allOf": [
+                                {
+                                    "$ref": "#/definitions/contextx.Response"
+                                },
+                                {
+                                    "type": "object",
+                                    "properties": {
+                                        "data": {
+                                            "$ref": "#/definitions/response.SolveRateResponse"
+                                        }
+                                    }
+                                }
+                            ]
+                        }
+                    }
+                }
+            }
+        },
+        "/api/solveRate/update": {
+            "put": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "SolveRate"
+                ],
+                "summary": "鏇存柊瑙e喅鐜�",
+                "parameters": [
+                    {
+                        "description": "鏌ヨ鍙傛暟",
+                        "name": "object",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/request.UpdateSolveRates"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/contextx.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/api/status/add": {
             "post": {
                 "produces": [
@@ -6574,11 +6693,22 @@
                 "serviceId": {
                     "type": "integer"
                 },
-                "solveRate": {
+                "solveRateId": {
                     "type": "integer"
                 },
                 "timelyRateId": {
                     "type": "integer"
+                }
+            }
+        },
+        "model.SolveRate": {
+            "type": "object",
+            "properties": {
+                "id": {
+                    "type": "integer"
+                },
+                "name": {
+                    "type": "string"
                 }
             }
         },
@@ -7568,6 +7698,17 @@
                 },
                 "timelyRate": {
                     "type": "integer"
+                }
+            }
+        },
+        "request.AddSolveRate": {
+            "type": "object",
+            "required": [
+                "name"
+            ],
+            "properties": {
+                "name": {
+                    "type": "string"
                 }
             }
         },
@@ -9374,6 +9515,35 @@
                 }
             }
         },
+        "request.UpdateSolveRate": {
+            "type": "object",
+            "required": [
+                "id",
+                "name"
+            ],
+            "properties": {
+                "id": {
+                    "type": "integer"
+                },
+                "name": {
+                    "type": "string"
+                }
+            }
+        },
+        "request.UpdateSolveRates": {
+            "type": "object",
+            "required": [
+                "solve_rate"
+            ],
+            "properties": {
+                "solve_rate": {
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/request.UpdateSolveRate"
+                    }
+                }
+            }
+        },
         "request.UpdateStatus": {
             "type": "object",
             "required": [
@@ -9692,6 +9862,20 @@
                     "items": {
                         "$ref": "#/definitions/model.Satisfaction"
                     }
+                },
+                "solve_rate": {
+                    "description": "瑙e喅鐜�",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.SolveRate"
+                    }
+                },
+                "timely_rate": {
+                    "description": "鍙婃椂鐜�",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.TimelyRate"
+                    }
                 }
             }
         },
@@ -9999,6 +10183,17 @@
                 }
             }
         },
+        "response.SolveRateResponse": {
+            "type": "object",
+            "properties": {
+                "list": {
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.SolveRate"
+                    }
+                }
+            }
+        },
         "response.SubOrderResponse": {
             "type": "object",
             "properties": {
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index 9b02d7a..cb0cbb2 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -876,10 +876,17 @@
         type: integer
       serviceId:
         type: integer
-      solveRate:
+      solveRateId:
         type: integer
       timelyRateId:
         type: integer
+    type: object
+  model.SolveRate:
+    properties:
+      id:
+        type: integer
+      name:
+        type: string
     type: object
   model.SubOrder:
     properties:
@@ -1549,6 +1556,13 @@
         type: integer
       timelyRate:
         type: integer
+    type: object
+  request.AddSolveRate:
+    properties:
+      name:
+        type: string
+    required:
+    - name
     type: object
   request.AddStatus:
     properties:
@@ -2771,6 +2785,25 @@
       timelyRate:
         type: integer
     type: object
+  request.UpdateSolveRate:
+    properties:
+      id:
+        type: integer
+      name:
+        type: string
+    required:
+    - id
+    - name
+    type: object
+  request.UpdateSolveRates:
+    properties:
+      solve_rate:
+        items:
+          $ref: '#/definitions/request.UpdateSolveRate'
+        type: array
+    required:
+    - solve_rate
+    type: object
   request.UpdateStatus:
     properties:
       id:
@@ -2986,6 +3019,16 @@
         items:
           $ref: '#/definitions/model.Satisfaction'
         type: array
+      solve_rate:
+        description: 瑙e喅鐜�
+        items:
+          $ref: '#/definitions/model.SolveRate'
+        type: array
+      timely_rate:
+        description: 鍙婃椂鐜�
+        items:
+          $ref: '#/definitions/model.TimelyRate'
+        type: array
     type: object
   response.DepartmentResponse:
     properties:
@@ -3179,6 +3222,13 @@
       list:
         items:
           $ref: '#/definitions/model.ServiceFollowup'
+        type: array
+    type: object
+  response.SolveRateResponse:
+    properties:
+      list:
+        items:
+          $ref: '#/definitions/model.SolveRate'
         type: array
     type: object
   response.SubOrderResponse:
@@ -6037,6 +6087,79 @@
       summary: 鏇存柊鏈嶅姟璺熻繘
       tags:
       - ServiceFollowup
+  /api/solveRate/add:
+    post:
+      parameters:
+      - description: 鏌ヨ鍙傛暟
+        in: body
+        name: object
+        required: true
+        schema:
+          $ref: '#/definitions/request.AddSolveRate'
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/contextx.Response'
+      summary: 娣诲姞瑙e喅鐜�
+      tags:
+      - SolveRate
+  /api/solveRate/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: 鍒犻櫎瑙e喅鐜�
+      tags:
+      - SolveRate
+  /api/solveRate/list:
+    get:
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            allOf:
+            - $ref: '#/definitions/contextx.Response'
+            - properties:
+                data:
+                  $ref: '#/definitions/response.SolveRateResponse'
+              type: object
+      summary: 鑾峰彇瑙e喅鐜囧垪琛�
+      tags:
+      - SolveRate
+  /api/solveRate/update:
+    put:
+      parameters:
+      - description: 鏌ヨ鍙傛暟
+        in: body
+        name: object
+        required: true
+        schema:
+          $ref: '#/definitions/request.UpdateSolveRates'
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/contextx.Response'
+      summary: 鏇存柊瑙e喅鐜�
+      tags:
+      - SolveRate
   /api/status/add:
     post:
       parameters:
diff --git a/model/index.go b/model/index.go
index efcc71c..2ded31e 100644
--- a/model/index.go
+++ b/model/index.go
@@ -65,6 +65,7 @@
 		Department{},
 		Satisfaction{},
 		TimelyRate{},
+		SolveRate{},
 	)
 	return err
 }
diff --git a/model/request/solveRate.go b/model/request/solveRate.go
new file mode 100644
index 0000000..33b7145
--- /dev/null
+++ b/model/request/solveRate.go
@@ -0,0 +1,15 @@
+
+package request
+
+type AddSolveRate struct {
+	Name string `  json:"name" binding:"required"`
+}
+
+type UpdateSolveRate struct {
+	Id   int    `json:"id" binding:"required"`
+	Name string `json:"name" binding:"required"`
+}
+
+type UpdateSolveRates struct {
+	SolveRates []*UpdateSolveRate `json:"solve_rate" binding:"required"`
+}
diff --git a/model/response/response.go b/model/response/response.go
index 61a502c..2bb073b 100644
--- a/model/response/response.go
+++ b/model/response/response.go
@@ -219,6 +219,8 @@
 		Satisfaction []*model.Satisfaction `json:"satisfaction"`
 		// 鍙婃椂鐜�
 		TimelyRate []*model.TimelyRate `json:"timely_rate"`
+		// 瑙e喅鐜�
+		SolveRate []*model.SolveRate `json:"solve_rate"`
 	}
 
 	DepartmentResponse struct {
@@ -232,4 +234,8 @@
 	TimelyRateResponse struct {
 		List []*model.TimelyRate `json:"list"`
 	}
+
+	SolveRateResponse struct {
+		List []*model.SolveRate `json:"list"`
+	}
 )
diff --git a/model/serviceFollowup.go b/model/serviceFollowup.go
index 9b15ae9..4557eff 100644
--- a/model/serviceFollowup.go
+++ b/model/serviceFollowup.go
@@ -17,7 +17,7 @@
 		PlanId               int                  `json:"planId" gorm:"column:plan_id;type:int;comment:鏈嶅姟璁″垝id"`
 		SatisfactionId       int                  `json:"satisfactionId" gorm:"column:satisfaction_id;type:int;comment:婊℃剰搴d"`
 		TimelyRateId         int                  `json:"timelyRateId" gorm:"column:timely_rate_id;type:int;comment:鍙婃椂鐜噄d"`
-		SolveRate            int                  `json:"solveRate" gorm:"column:solve_rate;type:int;comment:瑙e喅鐜�"`
+		SolveRateId          int                  `json:"solveRateId" gorm:"column:solve_rate_id;type:int;comment:瑙e喅鐜噄d"`
 		IsVisit              int                  `json:"isVisit" gorm:"column:is_visit;type:int;comment:鏈嶅姟浜哄憳鏄惁鏉ヨ繃"`
 		OldMemberId          int                  `json:"oldMemberId" gorm:"column:old_member_id;type:int;comment:鍘熸湇鍔′汉鍛�"`
 		Remark               string               `json:"remark" gorm:"column:remark;type:text;comment:澶囨敞"`
diff --git a/model/solveRate.go b/model/solveRate.go
new file mode 100644
index 0000000..97f6be1
--- /dev/null
+++ b/model/solveRate.go
@@ -0,0 +1,85 @@
+package model
+
+import (
+	"aps_crm/pkg/mysqlx"
+	"gorm.io/gorm"
+)
+
+type (
+	// SolveRate 鍟嗘満闃舵
+	SolveRate struct {
+		Id   int    `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
+		Name string `json:"name" gorm:"column:name;type:varchar(255);comment:鍟嗘満闃舵鍚嶇О"`
+	}
+   
+	SolveRateSearch struct {
+		SolveRate
+		Orm *gorm.DB
+	}
+)
+
+func (SolveRate) TableName() string {
+	return "solve_rate"
+}
+
+func NewSolveRateSearch() *SolveRateSearch {
+	return &SolveRateSearch{
+		Orm: mysqlx.GetDB(),
+	}
+}
+
+func (slf *SolveRateSearch) build() *gorm.DB {
+	var db = slf.Orm.Model(&SolveRate{})
+	if slf.Id != 0 {
+		db = db.Where("id = ?", slf.Id)
+	}
+	if slf.Name != "" {
+		db = db.Where("name = ?", slf.Name)
+	}
+
+	return db
+}
+
+func (slf *SolveRateSearch) Create(record *SolveRate) error {
+	var db = slf.build()
+	return db.Create(record).Error
+}
+
+func (slf *SolveRateSearch) Delete() error {
+	var db = slf.build()
+	return db.Delete(&SolveRate{}).Error
+}
+
+func (slf *SolveRateSearch) Update(record *SolveRate) error {
+	var db = slf.build()
+	return db.Updates(record).Error
+}
+
+func (slf *SolveRateSearch) Find() (*SolveRate, error) {
+	var db = slf.build()
+	var record = new(SolveRate)
+	err := db.First(record).Error
+	return record, err
+}
+
+func (slf *SolveRateSearch) FindAll() ([]*SolveRate, error) {
+	var db = slf.build()
+	var records = make([]*SolveRate, 0)
+	err := db.Find(&records).Error
+	return records, err
+}
+
+func (slf *SolveRateSearch) SetId(id int) *SolveRateSearch {
+	slf.Id = id
+	return slf
+}
+
+func (slf *SolveRateSearch) SetName(name string) *SolveRateSearch {
+	slf.Name = name
+	return slf
+}
+
+func (slf *SolveRateSearch) Updates(data map[string]interface{}) error {
+	var db = slf.build()
+	return db.Updates(data).Error
+}
diff --git a/pkg/ecode/code.go b/pkg/ecode/code.go
index bab5c87..2b7b61e 100644
--- a/pkg/ecode/code.go
+++ b/pkg/ecode/code.go
@@ -304,4 +304,9 @@
 	TimelyRateSetErr    = 4300004 // 璁剧疆鍙婃椂鐜囧け璐�
 	TimelyRateUpdateErr = 4300005 // 鏇存柊鍙婃椂鐜囧け璐�
 
+	SolveRateExist     = 4400001 // 瑙e喅鐜囧凡瀛樺湪
+	SolveRateNotExist  = 4400002 // 瑙e喅鐜囦笉瀛樺湪
+	SolveRateListErr   = 4400003 // 鑾峰彇瑙e喅鐜囧垪琛ㄥけ璐�
+	SolveRateSetErr    = 4400004 // 璁剧疆瑙e喅鐜囧け璐�
+	SolveRateUpdateErr = 4400005 // 鏇存柊瑙e喅鐜囧け璐�
 )
diff --git a/router/index.go b/router/index.go
index c23206c..21f46de 100644
--- a/router/index.go
+++ b/router/index.go
@@ -11,6 +11,7 @@
 )
 
 type Group struct {
+	SolveRateRouter
 	TimelyRateRouter
 	BaseRouter
 	UserRouter
@@ -131,6 +132,7 @@
 		routerGroup.InitDepartmentRouter(PrivateGroup)           // 娉ㄥ唽department璺敱
 		routerGroup.InitSatisfactionRouter(PrivateGroup)         // 娉ㄥ唽satisfaction璺敱
 		routerGroup.InitTimelyRateRouter(PrivateGroup)
+		routerGroup.InitSolveRateRouter(PrivateGroup)
 	}
 	return Router
 }
diff --git a/router/solveRate.go b/router/solveRate.go
new file mode 100644
index 0000000..fa20b2e
--- /dev/null
+++ b/router/solveRate.go
@@ -0,0 +1,20 @@
+
+package router
+
+import (
+	v1 "aps_crm/api/v1"
+	"github.com/gin-gonic/gin"
+)
+
+type SolveRateRouter struct{}
+
+func (s *SolveRateRouter) InitSolveRateRouter(router *gin.RouterGroup) {
+	solveRateRouter := router.Group("solveRate")
+	solveRateApi := v1.ApiGroup.SolveRateApi
+	{
+		solveRateRouter.POST("add", solveRateApi.Add)             // 娣诲姞閿�鍞樁娈�
+		solveRateRouter.DELETE("delete/:id", solveRateApi.Delete) // 鍒犻櫎閿�鍞樁娈�
+		solveRateRouter.PUT("update", solveRateApi.Update)        // 鏇存柊閿�鍞樁娈�
+		solveRateRouter.GET("list", solveRateApi.List)            // 鑾峰彇閿�鍞樁娈靛垪琛�
+	}
+}
\ No newline at end of file
diff --git a/service/dataServer.go b/service/dataServer.go
index 15d2d04..8af4b8c 100644
--- a/service/dataServer.go
+++ b/service/dataServer.go
@@ -88,7 +88,12 @@
 	timelyRateList, _ := ServiceGroup.GetTimelyRateList()
 	data.TimelyRate = timelyRateList
 
+	// get SolveRate list
+	solveRateList, _ := ServiceGroup.GetSolveRateList()
+	data.SolveRate = solveRateList
+
+
 	errCode = ecode.OK
 
 	return
-}
+}
\ No newline at end of file
diff --git a/service/index.go b/service/index.go
index 6655a5f..cd34420 100644
--- a/service/index.go
+++ b/service/index.go
@@ -47,6 +47,7 @@
 	VettingService
 	SatisfactionService
 	TimelyRateService
+	SolveRateService
 }
 
 var ServiceGroup = new(Group)
diff --git a/service/solveRate.go b/service/solveRate.go
new file mode 100644
index 0000000..2cc2807
--- /dev/null
+++ b/service/solveRate.go
@@ -0,0 +1,69 @@
+
+package service
+
+import (
+	"aps_crm/model"
+	"aps_crm/model/request"
+	"aps_crm/pkg/ecode"
+)
+
+type SolveRateService struct{}
+
+func (SolveRateService) AddSolveRate(solveRate *model.SolveRate) int {
+	err := model.NewSolveRateSearch().Create(solveRate)
+	if err != nil {
+		return ecode.SolveRateExist
+	}
+
+	return ecode.OK
+}
+
+func (SolveRateService) DeleteSolveRate(id int) int {
+	_, err := model.NewSolveRateSearch().SetId(id).Find()
+	if err != nil {
+		return ecode.SolveRateNotExist
+	}
+
+	err = model.NewSolveRateSearch().SetId(id).Delete()
+	if err != nil {
+		return ecode.SolveRateNotExist
+	}
+	return ecode.OK
+}
+
+func (SolveRateService) GetSolveRateList() ([]*model.SolveRate, int) {
+	list, err := model.NewSolveRateSearch().FindAll()
+	if err != nil {
+		return nil, ecode.SolveRateListErr
+	}
+
+	return list, ecode.OK
+}
+
+func (SolveRateService) UpdateSolveRate(solveRates []*request.UpdateSolveRate) int {
+	for _, v := range solveRates {
+		// check solveRate exist
+		_, err := model.NewSolveRateSearch().SetId(v.Id).Find()
+		if err != nil {
+			return ecode.SolveRateNotExist
+		}
+
+		err = model.NewSolveRateSearch().SetId(v.Id).Updates(map[string]interface{}{
+			"name": v.Name,
+		})
+		if err != nil {
+			return ecode.SolveRateSetErr
+		}
+	}
+
+	return ecode.OK
+}
+
+func (SolveRateService) GetSolveRateDetail(id int) (*model.SolveRate, int) {
+	solveRate, err := model.NewSolveRateSearch().SetId(id).Find()
+	if err != nil {
+		return nil, ecode.SolveRateNotExist
+	}
+
+	return solveRate, ecode.OK
+}

--
Gitblit v1.8.0