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

---
 api/v1/index.go                        |    2 
 api/v1/serviceContracts.go             |    2 
 model/request/serviceContractStatus.go |   15 +
 model/serviceContractStatus.go         |   85 +++++
 service/dataServer.go                  |    5 
 pkg/ecode/code.go                      |    9 
 docs/swagger.yaml                      |  122 ++++++++
 model/serviceContracts.go              |   36 +-
 docs/docs.go                           |  194 ++++++++++++
 service/serviceContractStatus.go       |   69 ++++
 docs/swagger.json                      |  194 ++++++++++++
 model/response/response.go             |    8 
 model/serviceFollowup.go               |    1 
 router/serviceContractStatus.go        |   20 +
 service/index.go                       |    1 
 model/index.go                         |    1 
 router/index.go                        |    2 
 api/v1/serviceContractStatus.go        |  113 +++++++
 18 files changed, 850 insertions(+), 29 deletions(-)

diff --git a/api/v1/index.go b/api/v1/index.go
index a2f82eb..de368c7 100644
--- a/api/v1/index.go
+++ b/api/v1/index.go
@@ -5,6 +5,7 @@
 )
 
 type Group struct {
+    ServiceContractStatusApi
     OrderTypeApi
     ReportSourceApi
 	IsVisitApi
@@ -110,4 +111,5 @@
 	isVisitService              = service.ServiceGroup.IsVisitService
    reportSourceService    = service.ServiceGroup.ReportSourceService
    orderTypeService    = service.ServiceGroup.OrderTypeService
+   serviceContractStatusService    = service.ServiceGroup.ServiceContractStatusService
 )
\ No newline at end of file
diff --git a/api/v1/serviceContractStatus.go b/api/v1/serviceContractStatus.go
new file mode 100644
index 0000000..ffbf8bd
--- /dev/null
+++ b/api/v1/serviceContractStatus.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 ServiceContractStatusApi struct{}
+
+// Add
+//
+//	@Tags		ServiceContractStatus
+//	@Summary	娣诲姞鏈嶅姟鍚堝悓鐘舵��
+//	@Produce	application/json
+//	@Param		object	body		request.AddServiceContractStatus	true	"鏌ヨ鍙傛暟"
+//	@Success	200		{object}	contextx.Response{}
+//	@Router		/api/serviceContractStatus/add [post]
+func (s *ServiceContractStatusApi) Add(c *gin.Context) {
+	var params request.AddServiceContractStatus
+	ctx, ok := contextx.NewContext(c, &params)
+	if !ok {
+		return
+	}
+
+	serviceContractStatus := new(model.ServiceContractStatus)
+	serviceContractStatus.Name = params.Name
+
+	errCode := serviceContractStatusService.AddServiceContractStatus(serviceContractStatus)
+	if errCode != ecode.OK {
+		ctx.Fail(errCode)
+		return
+	}
+
+	ctx.Ok()
+}
+
+// Delete
+//
+//	@Tags		ServiceContractStatus
+//	@Summary	鍒犻櫎鏈嶅姟鍚堝悓鐘舵��
+//	@Produce	application/json
+//	@Param		id	path		int	true	"鏌ヨ鍙傛暟"
+//	@Success	200	{object}	contextx.Response{}
+//	@Router		/api/serviceContractStatus/delete/{id} [delete]
+func (s *ServiceContractStatusApi) Delete(c *gin.Context) {
+	ctx, ok := contextx.NewContext(c, nil)
+	if !ok {
+		return
+	}
+
+	id, _ := strconv.Atoi(c.Param("id"))
+	errCode := serviceContractStatusService.DeleteServiceContractStatus(id)
+	if errCode != ecode.OK {
+		ctx.Fail(errCode)
+		return
+	}
+
+	ctx.Ok()
+}
+
+// Update
+//
+//	@Tags		ServiceContractStatus
+//	@Summary	鏇存柊鏈嶅姟鍚堝悓鐘舵��
+//	@Produce	application/json
+//	@Param		object	body		request.UpdateServiceContractStatuss	true	"鏌ヨ鍙傛暟"
+//	@Success	200		{object}	contextx.Response{}
+//	@Router		/api/serviceContractStatus/update [put]
+func (s *ServiceContractStatusApi) Update(c *gin.Context) {
+	var params request.UpdateServiceContractStatuss
+	ctx, ok := contextx.NewContext(c, &params)
+	if !ok {
+		return
+	}
+
+	errCode := serviceContractStatusService.UpdateServiceContractStatus(params.ServiceContractStatuss)
+	if errCode != ecode.OK {
+		ctx.Fail(errCode)
+		return
+	}
+
+	ctx.Ok()
+}
+
+// List
+//
+//	@Tags		ServiceContractStatus
+//	@Summary	鑾峰彇鏈嶅姟鍚堝悓鐘舵�佸垪琛�
+//	@Produce	application/json
+//	@Success	200	{object}	contextx.Response{data=response.ServiceContractStatusResponse}
+//	@Router		/api/serviceContractStatus/list [get]
+func (s *ServiceContractStatusApi) List(c *gin.Context) {
+	ctx, ok := contextx.NewContext(c, nil)
+	if !ok {
+		return
+	}
+
+	serviceContractStatuss, errCode := serviceContractStatusService.GetServiceContractStatusList()
+	if errCode != ecode.OK {
+		ctx.Fail(errCode)
+		return
+	}
+
+	ctx.OkWithDetailed(response.ServiceContractStatusResponse{
+		List: serviceContractStatuss,
+	})
+}
diff --git a/api/v1/serviceContracts.go b/api/v1/serviceContracts.go
index 092c1e2..71461ec 100644
--- a/api/v1/serviceContracts.go
+++ b/api/v1/serviceContracts.go
@@ -165,7 +165,7 @@
 	result.SaleChanceId = serviceContract.SaleChanceId
 	result.QuotationId = serviceContract.QuotationId
 	result.TypeId = serviceContract.TypeId
-	result.StatusId = serviceContract.StatusId
+	result.ServiceContractStatusId = serviceContract.StatusId
 	result.ServiceTimes = serviceContract.ServiceTimes
 	result.Terms = serviceContract.Terms
 	result.Products = serviceContract.Products
diff --git a/docs/docs.go b/docs/docs.go
index c4b1657..0fb9be2 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -4757,6 +4757,125 @@
                 }
             }
         },
+        "/api/serviceContractStatus/add": {
+            "post": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "ServiceContractStatus"
+                ],
+                "summary": "娣诲姞鏈嶅姟鍚堝悓鐘舵��",
+                "parameters": [
+                    {
+                        "description": "鏌ヨ鍙傛暟",
+                        "name": "object",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/request.AddServiceContractStatus"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/contextx.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/api/serviceContractStatus/delete/{id}": {
+            "delete": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "ServiceContractStatus"
+                ],
+                "summary": "鍒犻櫎鏈嶅姟鍚堝悓鐘舵��",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "鏌ヨ鍙傛暟",
+                        "name": "id",
+                        "in": "path",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/contextx.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/api/serviceContractStatus/list": {
+            "get": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "ServiceContractStatus"
+                ],
+                "summary": "鑾峰彇鏈嶅姟鍚堝悓鐘舵�佸垪琛�",
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "allOf": [
+                                {
+                                    "$ref": "#/definitions/contextx.Response"
+                                },
+                                {
+                                    "type": "object",
+                                    "properties": {
+                                        "data": {
+                                            "$ref": "#/definitions/response.ServiceContractStatusResponse"
+                                        }
+                                    }
+                                }
+                            ]
+                        }
+                    }
+                }
+            }
+        },
+        "/api/serviceContractStatus/update": {
+            "put": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "ServiceContractStatus"
+                ],
+                "summary": "鏇存柊鏈嶅姟鍚堝悓鐘舵��",
+                "parameters": [
+                    {
+                        "description": "鏌ヨ鍙傛暟",
+                        "name": "object",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/request.UpdateServiceContractStatuss"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/contextx.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/api/serviceFeeManage/add": {
             "post": {
                 "produces": [
@@ -7007,6 +7126,9 @@
                 "saleChanceId": {
                     "type": "integer"
                 },
+                "serviceContractStatusId": {
+                    "type": "integer"
+                },
                 "serviceTimes": {
                     "type": "integer"
                 },
@@ -7016,14 +7138,22 @@
                 "startTime": {
                     "type": "string"
                 },
-                "statusId": {
-                    "type": "integer"
-                },
                 "terms": {
                     "type": "string"
                 },
                 "typeId": {
                     "type": "integer"
+                }
+            }
+        },
+        "model.ServiceContractStatus": {
+            "type": "object",
+            "properties": {
+                "id": {
+                    "type": "integer"
+                },
+                "name": {
+                    "type": "string"
                 }
             }
         },
@@ -7987,6 +8117,17 @@
                 },
                 "typeId": {
                     "type": "integer"
+                }
+            }
+        },
+        "request.AddServiceContractStatus": {
+            "type": "object",
+            "required": [
+                "name"
+            ],
+            "properties": {
+                "name": {
+                    "type": "string"
                 }
             }
         },
@@ -9887,6 +10028,35 @@
                 }
             }
         },
+        "request.UpdateServiceContractStatus": {
+            "type": "object",
+            "required": [
+                "id",
+                "name"
+            ],
+            "properties": {
+                "id": {
+                    "type": "integer"
+                },
+                "name": {
+                    "type": "string"
+                }
+            }
+        },
+        "request.UpdateServiceContractStatuss": {
+            "type": "object",
+            "required": [
+                "service_contract_status"
+            ],
+            "properties": {
+                "service_contract_status": {
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/request.UpdateServiceContractStatus"
+                    }
+                }
+            }
+        },
         "request.UpdateServiceFeeManage": {
             "type": "object",
             "properties": {
@@ -10406,6 +10576,13 @@
                         "$ref": "#/definitions/model.Satisfaction"
                     }
                 },
+                "serviceContractStatus": {
+                    "description": "鏈嶅姟鍚堝悓鐘舵��",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.ServiceContractStatus"
+                    }
+                },
                 "solve_rate": {
                     "description": "瑙e喅鐜�",
                     "type": "array",
@@ -10726,6 +10903,17 @@
                 }
             }
         },
+        "response.ServiceContractStatusResponse": {
+            "type": "object",
+            "properties": {
+                "list": {
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.ServiceContractStatus"
+                    }
+                }
+            }
+        },
         "response.ServiceContractsResponse": {
             "type": "object",
             "properties": {
diff --git a/docs/swagger.json b/docs/swagger.json
index 8775d73..cc5ad71 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -4745,6 +4745,125 @@
                 }
             }
         },
+        "/api/serviceContractStatus/add": {
+            "post": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "ServiceContractStatus"
+                ],
+                "summary": "娣诲姞鏈嶅姟鍚堝悓鐘舵��",
+                "parameters": [
+                    {
+                        "description": "鏌ヨ鍙傛暟",
+                        "name": "object",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/request.AddServiceContractStatus"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/contextx.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/api/serviceContractStatus/delete/{id}": {
+            "delete": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "ServiceContractStatus"
+                ],
+                "summary": "鍒犻櫎鏈嶅姟鍚堝悓鐘舵��",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "鏌ヨ鍙傛暟",
+                        "name": "id",
+                        "in": "path",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/contextx.Response"
+                        }
+                    }
+                }
+            }
+        },
+        "/api/serviceContractStatus/list": {
+            "get": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "ServiceContractStatus"
+                ],
+                "summary": "鑾峰彇鏈嶅姟鍚堝悓鐘舵�佸垪琛�",
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "allOf": [
+                                {
+                                    "$ref": "#/definitions/contextx.Response"
+                                },
+                                {
+                                    "type": "object",
+                                    "properties": {
+                                        "data": {
+                                            "$ref": "#/definitions/response.ServiceContractStatusResponse"
+                                        }
+                                    }
+                                }
+                            ]
+                        }
+                    }
+                }
+            }
+        },
+        "/api/serviceContractStatus/update": {
+            "put": {
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "ServiceContractStatus"
+                ],
+                "summary": "鏇存柊鏈嶅姟鍚堝悓鐘舵��",
+                "parameters": [
+                    {
+                        "description": "鏌ヨ鍙傛暟",
+                        "name": "object",
+                        "in": "body",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/request.UpdateServiceContractStatuss"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/contextx.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/api/serviceFeeManage/add": {
             "post": {
                 "produces": [
@@ -6995,6 +7114,9 @@
                 "saleChanceId": {
                     "type": "integer"
                 },
+                "serviceContractStatusId": {
+                    "type": "integer"
+                },
                 "serviceTimes": {
                     "type": "integer"
                 },
@@ -7004,14 +7126,22 @@
                 "startTime": {
                     "type": "string"
                 },
-                "statusId": {
-                    "type": "integer"
-                },
                 "terms": {
                     "type": "string"
                 },
                 "typeId": {
                     "type": "integer"
+                }
+            }
+        },
+        "model.ServiceContractStatus": {
+            "type": "object",
+            "properties": {
+                "id": {
+                    "type": "integer"
+                },
+                "name": {
+                    "type": "string"
                 }
             }
         },
@@ -7975,6 +8105,17 @@
                 },
                 "typeId": {
                     "type": "integer"
+                }
+            }
+        },
+        "request.AddServiceContractStatus": {
+            "type": "object",
+            "required": [
+                "name"
+            ],
+            "properties": {
+                "name": {
+                    "type": "string"
                 }
             }
         },
@@ -9875,6 +10016,35 @@
                 }
             }
         },
+        "request.UpdateServiceContractStatus": {
+            "type": "object",
+            "required": [
+                "id",
+                "name"
+            ],
+            "properties": {
+                "id": {
+                    "type": "integer"
+                },
+                "name": {
+                    "type": "string"
+                }
+            }
+        },
+        "request.UpdateServiceContractStatuss": {
+            "type": "object",
+            "required": [
+                "service_contract_status"
+            ],
+            "properties": {
+                "service_contract_status": {
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/request.UpdateServiceContractStatus"
+                    }
+                }
+            }
+        },
         "request.UpdateServiceFeeManage": {
             "type": "object",
             "properties": {
@@ -10394,6 +10564,13 @@
                         "$ref": "#/definitions/model.Satisfaction"
                     }
                 },
+                "serviceContractStatus": {
+                    "description": "鏈嶅姟鍚堝悓鐘舵��",
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.ServiceContractStatus"
+                    }
+                },
                 "solve_rate": {
                     "description": "瑙e喅鐜�",
                     "type": "array",
@@ -10714,6 +10891,17 @@
                 }
             }
         },
+        "response.ServiceContractStatusResponse": {
+            "type": "object",
+            "properties": {
+                "list": {
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/model.ServiceContractStatus"
+                    }
+                }
+            }
+        },
         "response.ServiceContractsResponse": {
             "type": "object",
             "properties": {
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index 44987a4..ba59af5 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -839,18 +839,25 @@
         type: string
       saleChanceId:
         type: integer
+      serviceContractStatusId:
+        type: integer
       serviceTimes:
         type: integer
       signTime:
         type: string
       startTime:
         type: string
-      statusId:
-        type: integer
       terms:
         type: string
       typeId:
         type: integer
+    type: object
+  model.ServiceContractStatus:
+    properties:
+      id:
+        type: integer
+      name:
+        type: string
     type: object
   model.ServiceFeeManage:
     properties:
@@ -1495,6 +1502,13 @@
         type: string
       typeId:
         type: integer
+    type: object
+  request.AddServiceContractStatus:
+    properties:
+      name:
+        type: string
+    required:
+    - name
     type: object
   request.AddServiceFeeManage:
     properties:
@@ -2779,6 +2793,25 @@
       typeId:
         type: integer
     type: object
+  request.UpdateServiceContractStatus:
+    properties:
+      id:
+        type: integer
+      name:
+        type: string
+    required:
+    - id
+    - name
+    type: object
+  request.UpdateServiceContractStatuss:
+    properties:
+      service_contract_status:
+        items:
+          $ref: '#/definitions/request.UpdateServiceContractStatus'
+        type: array
+    required:
+    - service_contract_status
+    type: object
   request.UpdateServiceFeeManage:
     properties:
       business_scope:
@@ -3133,6 +3166,11 @@
         items:
           $ref: '#/definitions/model.Satisfaction'
         type: array
+      serviceContractStatus:
+        description: 鏈嶅姟鍚堝悓鐘舵��
+        items:
+          $ref: '#/definitions/model.ServiceContractStatus'
+        type: array
       solve_rate:
         description: 瑙e喅鐜�
         items:
@@ -3336,6 +3374,13 @@
       list:
         items:
           $ref: '#/definitions/model.Satisfaction'
+        type: array
+    type: object
+  response.ServiceContractStatusResponse:
+    properties:
+      list:
+        items:
+          $ref: '#/definitions/model.ServiceContractStatus'
         type: array
     type: object
   response.ServiceContractsResponse:
@@ -6295,6 +6340,79 @@
       summary: 鏇存柊鏈嶅姟鍚堝悓
       tags:
       - ServiceContract
+  /api/serviceContractStatus/add:
+    post:
+      parameters:
+      - description: 鏌ヨ鍙傛暟
+        in: body
+        name: object
+        required: true
+        schema:
+          $ref: '#/definitions/request.AddServiceContractStatus'
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/contextx.Response'
+      summary: 娣诲姞鏈嶅姟鍚堝悓鐘舵��
+      tags:
+      - ServiceContractStatus
+  /api/serviceContractStatus/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:
+      - ServiceContractStatus
+  /api/serviceContractStatus/list:
+    get:
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            allOf:
+            - $ref: '#/definitions/contextx.Response'
+            - properties:
+                data:
+                  $ref: '#/definitions/response.ServiceContractStatusResponse'
+              type: object
+      summary: 鑾峰彇鏈嶅姟鍚堝悓鐘舵�佸垪琛�
+      tags:
+      - ServiceContractStatus
+  /api/serviceContractStatus/update:
+    put:
+      parameters:
+      - description: 鏌ヨ鍙傛暟
+        in: body
+        name: object
+        required: true
+        schema:
+          $ref: '#/definitions/request.UpdateServiceContractStatuss'
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/contextx.Response'
+      summary: 鏇存柊鏈嶅姟鍚堝悓鐘舵��
+      tags:
+      - ServiceContractStatus
   /api/serviceFeeManage/add:
     post:
       parameters:
diff --git a/model/index.go b/model/index.go
index bb92b2e..887f1e6 100644
--- a/model/index.go
+++ b/model/index.go
@@ -70,6 +70,7 @@
         IsVisit{},
         ReportSource{},
         OrderType{},
+        ServiceContractStatus{},
 	)
 	return err
 }
\ No newline at end of file
diff --git a/model/request/serviceContractStatus.go b/model/request/serviceContractStatus.go
new file mode 100644
index 0000000..98ec257
--- /dev/null
+++ b/model/request/serviceContractStatus.go
@@ -0,0 +1,15 @@
+
+package request
+
+type AddServiceContractStatus struct {
+	Name string `  json:"name" binding:"required"`
+}
+
+type UpdateServiceContractStatus struct {
+	Id   int    `json:"id" binding:"required"`
+	Name string `json:"name" binding:"required"`
+}
+
+type UpdateServiceContractStatuss struct {
+	ServiceContractStatuss []*UpdateServiceContractStatus `json:"service_contract_status" binding:"required"`
+}
diff --git a/model/response/response.go b/model/response/response.go
index d24bd16..dc71ab1 100644
--- a/model/response/response.go
+++ b/model/response/response.go
@@ -180,6 +180,10 @@
 
 	DataResponse struct {
 
+		// 鏈嶅姟鍚堝悓鐘舵��
+		ServiceContractStatus []*model.ServiceContractStatus `json:"serviceContractStatus"`
+
+
 		// 宸ュ崟绫诲瀷
 		OrderType []*model.OrderType `json:"orderType"`
 
@@ -262,4 +266,8 @@
 	OrderTypeResponse struct {
 		List []*model.OrderType `json:"list"`
 	}
+
+	ServiceContractStatusResponse struct {
+		List []*model.ServiceContractStatus `json:"list"`
+	}
 )
\ No newline at end of file
diff --git a/model/serviceContractStatus.go b/model/serviceContractStatus.go
new file mode 100644
index 0000000..f3631c4
--- /dev/null
+++ b/model/serviceContractStatus.go
@@ -0,0 +1,85 @@
+package model
+
+import (
+	"aps_crm/pkg/mysqlx"
+	"gorm.io/gorm"
+)
+
+type (
+	// ServiceContractStatus 鍟嗘満闃舵
+	ServiceContractStatus struct {
+		Id   int    `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
+		Name string `json:"name" gorm:"column:name;type:varchar(255);comment:鍟嗘満闃舵鍚嶇О"`
+	}
+   
+	ServiceContractStatusSearch struct {
+		ServiceContractStatus
+		Orm *gorm.DB
+	}
+)
+
+func (ServiceContractStatus) TableName() string {
+	return "service_contract_status"
+}
+
+func NewServiceContractStatusSearch() *ServiceContractStatusSearch {
+	return &ServiceContractStatusSearch{
+		Orm: mysqlx.GetDB(),
+	}
+}
+
+func (slf *ServiceContractStatusSearch) build() *gorm.DB {
+	var db = slf.Orm.Model(&ServiceContractStatus{})
+	if slf.Id != 0 {
+		db = db.Where("id = ?", slf.Id)
+	}
+	if slf.Name != "" {
+		db = db.Where("name = ?", slf.Name)
+	}
+
+	return db
+}
+
+func (slf *ServiceContractStatusSearch) Create(record *ServiceContractStatus) error {
+	var db = slf.build()
+	return db.Create(record).Error
+}
+
+func (slf *ServiceContractStatusSearch) Delete() error {
+	var db = slf.build()
+	return db.Delete(&ServiceContractStatus{}).Error
+}
+
+func (slf *ServiceContractStatusSearch) Update(record *ServiceContractStatus) error {
+	var db = slf.build()
+	return db.Updates(record).Error
+}
+
+func (slf *ServiceContractStatusSearch) Find() (*ServiceContractStatus, error) {
+	var db = slf.build()
+	var record = new(ServiceContractStatus)
+	err := db.First(record).Error
+	return record, err
+}
+
+func (slf *ServiceContractStatusSearch) FindAll() ([]*ServiceContractStatus, error) {
+	var db = slf.build()
+	var records = make([]*ServiceContractStatus, 0)
+	err := db.Find(&records).Error
+	return records, err
+}
+
+func (slf *ServiceContractStatusSearch) SetId(id int) *ServiceContractStatusSearch {
+	slf.Id = id
+	return slf
+}
+
+func (slf *ServiceContractStatusSearch) SetName(name string) *ServiceContractStatusSearch {
+	slf.Name = name
+	return slf
+}
+
+func (slf *ServiceContractStatusSearch) Updates(data map[string]interface{}) error {
+	var db = slf.build()
+	return db.Updates(data).Error
+}
diff --git a/model/serviceContracts.go b/model/serviceContracts.go
index 38a24e9..e4a5eac 100644
--- a/model/serviceContracts.go
+++ b/model/serviceContracts.go
@@ -8,24 +8,24 @@
 
 type (
 	ServiceContract struct {
-		Id           int       `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
-		ClientId     int       `json:"clientId" gorm:"column:client_id;type:int;comment:瀹㈡埛id"`
-		Number       string    `json:"number" gorm:"column:number;type:varchar(255);comment:鍚堝悓缂栧彿"`
-		MemberId     int       `json:"memberId" gorm:"column:member_id;type:int;comment:璐熻矗浜篿d"`
-		ContactId    int       `json:"contactId" gorm:"column:contact_id;type:int;comment:鑱旂郴浜篿d"`
-		SaleChanceId int       `json:"saleChanceId" gorm:"column:sale_chance_id;type:int;comment:閿�鍞満浼歩d"`
-		ContractId   int       `json:"contractId" gorm:"column:contract_id;type:int;comment:鍚堝悓id"`
-		QuotationId  int       `json:"quotationId" gorm:"column:quotation_id;type:int;comment:鎶ヤ环鍗昳d"`
-		TypeId       int       `json:"typeId" gorm:"column:type_id;type:int;comment:鍚堝悓绫诲瀷id"`
-		SignTime     time.Time `json:"signTime" gorm:"column:sign_time;type:datetime;comment:绛剧害鏃堕棿"`
-		StartTime    time.Time `json:"startTime" gorm:"column:start_time;type:datetime;comment:寮�濮嬫椂闂�"`
-		EndTime      time.Time `json:"endTime" gorm:"column:end_time;type:datetime;comment:缁撴潫鏃堕棿"`
-		StatusId     int       `json:"statusId" gorm:"column:status_id;type:int;comment:鍚堝悓鐘舵�乮d"`
-		ServiceTimes int       `json:"serviceTimes" gorm:"column:service_times;type:int;comment:鏈嶅姟娆℃暟"`
-		Terms        string    `json:"terms" gorm:"column:terms;type:text;comment:鏉℃"`
-		Remark       string    `json:"remark" gorm:"column:remark;type:text;comment:澶囨敞"`
-		Products     []Product `json:"products" gorm:"many2many:serviceContract_product;"`
-		gorm.Model   `json:"-"`
+		Id                      int       `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
+		ClientId                int       `json:"clientId" gorm:"column:client_id;type:int;comment:瀹㈡埛id"`
+		Number                  string    `json:"number" gorm:"column:number;type:varchar(255);comment:鍚堝悓缂栧彿"`
+		MemberId                int       `json:"memberId" gorm:"column:member_id;type:int;comment:璐熻矗浜篿d"`
+		ContactId               int       `json:"contactId" gorm:"column:contact_id;type:int;comment:鑱旂郴浜篿d"`
+		SaleChanceId            int       `json:"saleChanceId" gorm:"column:sale_chance_id;type:int;comment:閿�鍞満浼歩d"`
+		ContractId              int       `json:"contractId" gorm:"column:contract_id;type:int;comment:鍚堝悓id"`
+		QuotationId             int       `json:"quotationId" gorm:"column:quotation_id;type:int;comment:鎶ヤ环鍗昳d"`
+		TypeId                  int       `json:"typeId" gorm:"column:type_id;type:int;comment:鍚堝悓绫诲瀷id"`
+		SignTime                time.Time `json:"signTime" gorm:"column:sign_time;type:datetime;comment:绛剧害鏃堕棿"`
+		StartTime               time.Time `json:"startTime" gorm:"column:start_time;type:datetime;comment:寮�濮嬫椂闂�"`
+		EndTime                 time.Time `json:"endTime" gorm:"column:end_time;type:datetime;comment:缁撴潫鏃堕棿"`
+		ServiceContractStatusId int       `json:"serviceContractStatusId" gorm:"column:service_contract_status_id;type:int;comment:鍚堝悓鐘舵�乮d"`
+		ServiceTimes            int       `json:"serviceTimes" gorm:"column:service_times;type:int;comment:鏈嶅姟娆℃暟"`
+		Terms                   string    `json:"terms" gorm:"column:terms;type:text;comment:鏉℃"`
+		Remark                  string    `json:"remark" gorm:"column:remark;type:text;comment:澶囨敞"`
+		Products                []Product `json:"products" gorm:"many2many:serviceContract_product;"`
+		gorm.Model              `json:"-"`
 	}
 
 	ServiceContractSearch struct {
diff --git a/model/serviceFollowup.go b/model/serviceFollowup.go
index 6a3fc37..0372909 100644
--- a/model/serviceFollowup.go
+++ b/model/serviceFollowup.go
@@ -85,7 +85,6 @@
 	return slf
 }
 
-// 宸ュ崟绫诲瀷 鎶ヤ慨鏉ユ簮锛堝伐鍗曠鐞嗭級
 // 鍚堝悓绫诲瀷 鍚堝悓鐘舵�侊紙鏈嶅姟鍚堝悓锛�
 // 浠樻鏂瑰紡 鏄惁寮�绁� 璐︽埛锛堥攢鍞��娆惧崟锛�
 // 閫�鍏ヤ粨搴� 鐘舵�侊紙閿�鍞��璐у崟锛�
diff --git a/pkg/ecode/code.go b/pkg/ecode/code.go
index a8ac5d0..4edaaa3 100644
--- a/pkg/ecode/code.go
+++ b/pkg/ecode/code.go
@@ -328,4 +328,11 @@
 	OrderTypeSetErr    = 4700004 // 璁剧疆宸ュ崟绫诲瀷澶辫触
 	OrderTypeUpdateErr = 4700005 // 鏇存柊宸ュ崟绫诲瀷澶辫触
 
-)
+
+	ServiceContractStatusExist     = 4400001 // 鏈嶅姟鍚堝悓鐘舵�佸凡瀛樺湪
+	ServiceContractStatusNotExist  = 4400002 // 鏈嶅姟鍚堝悓鐘舵�佷笉瀛樺湪
+	ServiceContractStatusListErr   = 4400003 // 鑾峰彇鏈嶅姟鍚堝悓鐘舵�佸垪琛ㄥけ璐�
+	ServiceContractStatusSetErr    = 4400004 // 璁剧疆鏈嶅姟鍚堝悓鐘舵�佸け璐�
+	ServiceContractStatusUpdateErr = 4400005 // 鏇存柊鏈嶅姟鍚堝悓鐘舵�佸け璐�
+
+)
\ No newline at end of file
diff --git a/router/index.go b/router/index.go
index b69c936..4adef30 100644
--- a/router/index.go
+++ b/router/index.go
@@ -11,6 +11,7 @@
 )
 
 type Group struct {
+    ServiceContractStatusRouter
     OrderTypeRouter
     ReportSourceRouter
 	IsVisitRouter
@@ -139,6 +140,7 @@
 		routerGroup.InitIsVisitRouter(PrivateGroup)
         routerGroup.InitReportSourceRouter(PrivateGroup)
         routerGroup.InitOrderTypeRouter(PrivateGroup)
+        routerGroup.InitServiceContractStatusRouter(PrivateGroup)
 	}
 	return Router
 }
\ No newline at end of file
diff --git a/router/serviceContractStatus.go b/router/serviceContractStatus.go
new file mode 100644
index 0000000..0f0d48e
--- /dev/null
+++ b/router/serviceContractStatus.go
@@ -0,0 +1,20 @@
+
+package router
+
+import (
+	v1 "aps_crm/api/v1"
+	"github.com/gin-gonic/gin"
+)
+
+type ServiceContractStatusRouter struct{}
+
+func (s *ServiceContractStatusRouter) InitServiceContractStatusRouter(router *gin.RouterGroup) {
+	serviceContractStatusRouter := router.Group("serviceContractStatus")
+	serviceContractStatusApi := v1.ApiGroup.ServiceContractStatusApi
+	{
+		serviceContractStatusRouter.POST("add", serviceContractStatusApi.Add)             // 娣诲姞$CName$
+		serviceContractStatusRouter.DELETE("delete/:id", serviceContractStatusApi.Delete) // 鍒犻櫎$CName$
+		serviceContractStatusRouter.PUT("update", serviceContractStatusApi.Update)        // 鏇存柊$CName$
+		serviceContractStatusRouter.GET("list", serviceContractStatusApi.List)            // 鑾峰彇$CName$鍒楄〃
+	}
+}
\ No newline at end of file
diff --git a/service/dataServer.go b/service/dataServer.go
index 14ca846..d14e783 100644
--- a/service/dataServer.go
+++ b/service/dataServer.go
@@ -106,6 +106,11 @@
 	data.OrderType = orderTypeList
 
 
+	// get ServiceContractStatus list
+	serviceContractStatusList, _ := ServiceGroup.GetServiceContractStatusList()
+	data.ServiceContractStatus = serviceContractStatusList
+
+
 	errCode = ecode.OK
 
 	return
diff --git a/service/index.go b/service/index.go
index e0434f8..013dce5 100644
--- a/service/index.go
+++ b/service/index.go
@@ -51,6 +51,7 @@
 	IsVisitService
     ReportSourceService
     OrderTypeService
+    ServiceContractStatusService
 }
 
 var ServiceGroup = new(Group)
\ No newline at end of file
diff --git a/service/serviceContractStatus.go b/service/serviceContractStatus.go
new file mode 100644
index 0000000..93cced0
--- /dev/null
+++ b/service/serviceContractStatus.go
@@ -0,0 +1,69 @@
+
+package service
+
+import (
+	"aps_crm/model"
+	"aps_crm/model/request"
+	"aps_crm/pkg/ecode"
+)
+
+type ServiceContractStatusService struct{}
+
+func (ServiceContractStatusService) AddServiceContractStatus(serviceContractStatus *model.ServiceContractStatus) int {
+	err := model.NewServiceContractStatusSearch().Create(serviceContractStatus)
+	if err != nil {
+		return ecode.ServiceContractStatusExist
+	}
+
+	return ecode.OK
+}
+
+func (ServiceContractStatusService) DeleteServiceContractStatus(id int) int {
+	_, err := model.NewServiceContractStatusSearch().SetId(id).Find()
+	if err != nil {
+		return ecode.ServiceContractStatusNotExist
+	}
+
+	err = model.NewServiceContractStatusSearch().SetId(id).Delete()
+	if err != nil {
+		return ecode.ServiceContractStatusNotExist
+	}
+	return ecode.OK
+}
+
+func (ServiceContractStatusService) GetServiceContractStatusList() ([]*model.ServiceContractStatus, int) {
+	list, err := model.NewServiceContractStatusSearch().FindAll()
+	if err != nil {
+		return nil, ecode.ServiceContractStatusListErr
+	}
+
+	return list, ecode.OK
+}
+
+func (ServiceContractStatusService) UpdateServiceContractStatus(serviceContractStatuss []*request.UpdateServiceContractStatus) int {
+	for _, v := range serviceContractStatuss {
+		// check serviceContractStatus exist
+		_, err := model.NewServiceContractStatusSearch().SetId(v.Id).Find()
+		if err != nil {
+			return ecode.ServiceContractStatusNotExist
+		}
+
+		err = model.NewServiceContractStatusSearch().SetId(v.Id).Updates(map[string]interface{}{
+			"name": v.Name,
+		})
+		if err != nil {
+			return ecode.ServiceContractStatusSetErr
+		}
+	}
+
+	return ecode.OK
+}
+
+func (ServiceContractStatusService) GetServiceContractStatusDetail(id int) (*model.ServiceContractStatus, int) {
+	serviceContractStatus, err := model.NewServiceContractStatusSearch().SetId(id).Find()
+	if err != nil {
+		return nil, ecode.ServiceContractStatusNotExist
+	}
+
+	return serviceContractStatus, ecode.OK
+}

--
Gitblit v1.8.0