add
wangpengfei
2023-07-13 642b32ac1e86f596a0348ba230d3ba6822832e96
add

add

ServiceFollowup 服务回访单
add, Delete, update, list
5个文件已添加
10个文件已修改
1056 ■■■■■ 已修改文件
api/v1/index.go 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/serviceFollowup.go 150 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 268 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 268 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 171 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
logs/aps-admin.err.log 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/index.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/serviceFollowup.go 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/response/response.go 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/serviceFollowup.go 83 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pkg/ecode/code.go 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/index.go 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/serviceFollowup.go 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/index.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/serviceFollowup.go 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/index.go
@@ -41,6 +41,7 @@
    PlanApi
    ServiceContractApi
    OrderManageApi
    ServiceFollowupApi
}
var ApiGroup = new(Group)
@@ -81,4 +82,5 @@
    planService              = service.ServiceGroup.PlanService
    serviceContractService   = service.ServiceGroup.SContractService
    orderManageService       = service.ServiceGroup.OrderManageService
    serviceFollowupService   = service.ServiceGroup.FollowupService
)
api/v1/serviceFollowup.go
New file
@@ -0,0 +1,150 @@
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 ServiceFollowupApi struct{}
// Add
//
//    @Tags        ServiceFollowup
//    @Summary    添加服务跟进
//    @Produce    application/json
//    @Param        object    body        request.AddServiceFollowup    true    "查询参数"
//    @Success    200        {object}    contextx.Response{}
//    @Router        /api/serviceFollowup/add [post]
func (s *ServiceFollowupApi) Add(c *gin.Context) {
    var params request.AddServiceFollowup
    ctx, ok := contextx.NewContext(c, &params)
    if !ok {
        return
    }
    errCode, serviceFollowup := checkServiceFollowupParams(params.ServiceFollowup)
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
    }
    errCode = serviceFollowupService.AddServiceFollowup(&serviceFollowup)
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
    }
    ctx.Ok()
}
// Delete
//
//    @Tags        ServiceFollowup
//    @Summary    删除服务跟进
//    @Produce    application/json
//    @Param        id    path        int    true    "查询参数"
//    @Success    200    {object}    contextx.Response{}
//    @Router        /api/serviceFollowup/delete/{id} [delete]
func (s *ServiceFollowupApi) Delete(c *gin.Context) {
    ctx, ok := contextx.NewContext(c, nil)
    if !ok {
        return
    }
    id, _ := strconv.Atoi(c.Param("id"))
    errCode := serviceFollowupService.DeleteServiceFollowup(id)
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
    }
    ctx.Ok()
}
// Update
//
//    @Tags        ServiceFollowup
//    @Summary    更新服务跟进
//    @Produce    application/json
//    @Param        object    body        request.UpdateServiceFollowup true    "查询参数"
//    @Success    200    {object}    contextx.Response{}
//    @Router        /api/serviceFollowup/update [put]
func (s *ServiceFollowupApi) Update(c *gin.Context) {
    var params request.UpdateServiceFollowup
    ctx, ok := contextx.NewContext(c, &params)
    if !ok {
        return
    }
    errCode, serviceFollowup := checkServiceFollowupParams(params.ServiceFollowup)
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
    }
    errCode = serviceFollowupService.UpdateServiceFollowup(&serviceFollowup)
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
    }
    ctx.Ok()
}
// List
//
//    @Tags        ServiceFollowup
//    @Summary    服务跟进列表
//    @Produce    application/json
//    @Success    200    {object}    contextx.Response{data=response.ServiceFollowupResponse}
//    @Router        /api/serviceFollowup/list [get]
func (s *ServiceFollowupApi) List(c *gin.Context) {
    ctx, ok := contextx.NewContext(c, nil)
    if !ok {
        return
    }
    list, errCode := serviceFollowupService.GetServiceFollowupList()
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
    }
    ctx.OkWithDetailed(response.ServiceFollowupResponse{
        List: list,
    })
}
// checkServiceFollowupParams
func checkServiceFollowupParams(serviceFollowup request.ServiceFollowup) (errCode int, serviceFollowupModel model.ServiceFollowup) {
    if serviceFollowup.Number == "" {
        return ecode.InvalidParams, serviceFollowupModel
    }
    if serviceFollowup.MemberId == 0 {
        return ecode.InvalidParams, serviceFollowupModel
    }
    serviceFollowupModel = model.ServiceFollowup{
        ClientId:     serviceFollowup.ClientId,
        Number:       serviceFollowup.Number,
        ContactId:    serviceFollowup.ContactId,
        ServiceId:    serviceFollowup.ServiceId,
        MemberId:     serviceFollowup.MemberId,
        PlanId:       serviceFollowup.PlanId,
        Satisfaction: serviceFollowup.Satisfaction,
        TimelyRate:   serviceFollowup.TimelyRate,
        SolveRate:    serviceFollowup.SolveRate,
        IsVisit:      serviceFollowup.IsVisit,
        OldMemberId:  serviceFollowup.OldMemberId,
        Remark:       serviceFollowup.Remark,
        File:         serviceFollowup.File,
    }
    return ecode.OK, serviceFollowupModel
}
docs/docs.go
@@ -3865,6 +3865,125 @@
                }
            }
        },
        "/api/serviceFollowup/add": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "ServiceFollowup"
                ],
                "summary": "添加服务跟进",
                "parameters": [
                    {
                        "description": "查询参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.AddServiceFollowup"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/contextx.Response"
                        }
                    }
                }
            }
        },
        "/api/serviceFollowup/delete/{id}": {
            "delete": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "ServiceFollowup"
                ],
                "summary": "删除服务跟进",
                "parameters": [
                    {
                        "type": "integer",
                        "description": "查询参数",
                        "name": "id",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/contextx.Response"
                        }
                    }
                }
            }
        },
        "/api/serviceFollowup/list": {
            "get": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "ServiceFollowup"
                ],
                "summary": "服务跟进列表",
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/contextx.Response"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/definitions/response.ServiceFollowupResponse"
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        },
        "/api/serviceFollowup/update": {
            "put": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "ServiceFollowup"
                ],
                "summary": "更新服务跟进",
                "parameters": [
                    {
                        "description": "查询参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.UpdateServiceFollowup"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/contextx.Response"
                        }
                    }
                }
            }
        },
        "/api/status/add": {
            "post": {
                "produces": [
@@ -5433,6 +5552,53 @@
                }
            }
        },
        "model.ServiceFollowup": {
            "type": "object",
            "properties": {
                "clientId": {
                    "type": "integer"
                },
                "contactId": {
                    "type": "integer"
                },
                "file": {
                    "type": "string"
                },
                "id": {
                    "type": "integer"
                },
                "isVisit": {
                    "type": "integer"
                },
                "memberId": {
                    "type": "integer"
                },
                "number": {
                    "type": "string"
                },
                "oldMemberId": {
                    "type": "integer"
                },
                "planId": {
                    "type": "integer"
                },
                "remark": {
                    "type": "string"
                },
                "satisfaction": {
                    "type": "integer"
                },
                "serviceId": {
                    "type": "integer"
                },
                "solveRate": {
                    "type": "integer"
                },
                "timelyRate": {
                    "type": "integer"
                }
            }
        },
        "model.SubOrder": {
            "type": "object",
            "properties": {
@@ -6209,6 +6375,50 @@
                    "type": "string"
                },
                "typeId": {
                    "type": "integer"
                }
            }
        },
        "request.AddServiceFollowup": {
            "type": "object",
            "properties": {
                "clientId": {
                    "type": "integer"
                },
                "contactId": {
                    "type": "integer"
                },
                "file": {
                    "type": "string"
                },
                "isVisit": {
                    "type": "integer"
                },
                "memberId": {
                    "type": "integer"
                },
                "number": {
                    "type": "string"
                },
                "oldMemberId": {
                    "type": "integer"
                },
                "planId": {
                    "type": "integer"
                },
                "remark": {
                    "type": "string"
                },
                "satisfaction": {
                    "type": "integer"
                },
                "serviceId": {
                    "type": "integer"
                },
                "solveRate": {
                    "type": "integer"
                },
                "timelyRate": {
                    "type": "integer"
                }
            }
@@ -7729,6 +7939,53 @@
                }
            }
        },
        "request.UpdateServiceFollowup": {
            "type": "object",
            "properties": {
                "clientId": {
                    "type": "integer"
                },
                "contactId": {
                    "type": "integer"
                },
                "file": {
                    "type": "string"
                },
                "id": {
                    "type": "integer"
                },
                "isVisit": {
                    "type": "integer"
                },
                "memberId": {
                    "type": "integer"
                },
                "number": {
                    "type": "string"
                },
                "oldMemberId": {
                    "type": "integer"
                },
                "planId": {
                    "type": "integer"
                },
                "remark": {
                    "type": "string"
                },
                "satisfaction": {
                    "type": "integer"
                },
                "serviceId": {
                    "type": "integer"
                },
                "solveRate": {
                    "type": "integer"
                },
                "timelyRate": {
                    "type": "integer"
                }
            }
        },
        "request.UpdateStatus": {
            "type": "object",
            "required": [
@@ -8121,6 +8378,17 @@
                }
            }
        },
        "response.ServiceFollowupResponse": {
            "type": "object",
            "properties": {
                "list": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/model.ServiceFollowup"
                    }
                }
            }
        },
        "response.SubOrderResponse": {
            "type": "object",
            "properties": {
docs/swagger.json
@@ -3853,6 +3853,125 @@
                }
            }
        },
        "/api/serviceFollowup/add": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "ServiceFollowup"
                ],
                "summary": "添加服务跟进",
                "parameters": [
                    {
                        "description": "查询参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.AddServiceFollowup"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/contextx.Response"
                        }
                    }
                }
            }
        },
        "/api/serviceFollowup/delete/{id}": {
            "delete": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "ServiceFollowup"
                ],
                "summary": "删除服务跟进",
                "parameters": [
                    {
                        "type": "integer",
                        "description": "查询参数",
                        "name": "id",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/contextx.Response"
                        }
                    }
                }
            }
        },
        "/api/serviceFollowup/list": {
            "get": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "ServiceFollowup"
                ],
                "summary": "服务跟进列表",
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/contextx.Response"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/definitions/response.ServiceFollowupResponse"
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        },
        "/api/serviceFollowup/update": {
            "put": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "ServiceFollowup"
                ],
                "summary": "更新服务跟进",
                "parameters": [
                    {
                        "description": "查询参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.UpdateServiceFollowup"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/contextx.Response"
                        }
                    }
                }
            }
        },
        "/api/status/add": {
            "post": {
                "produces": [
@@ -5421,6 +5540,53 @@
                }
            }
        },
        "model.ServiceFollowup": {
            "type": "object",
            "properties": {
                "clientId": {
                    "type": "integer"
                },
                "contactId": {
                    "type": "integer"
                },
                "file": {
                    "type": "string"
                },
                "id": {
                    "type": "integer"
                },
                "isVisit": {
                    "type": "integer"
                },
                "memberId": {
                    "type": "integer"
                },
                "number": {
                    "type": "string"
                },
                "oldMemberId": {
                    "type": "integer"
                },
                "planId": {
                    "type": "integer"
                },
                "remark": {
                    "type": "string"
                },
                "satisfaction": {
                    "type": "integer"
                },
                "serviceId": {
                    "type": "integer"
                },
                "solveRate": {
                    "type": "integer"
                },
                "timelyRate": {
                    "type": "integer"
                }
            }
        },
        "model.SubOrder": {
            "type": "object",
            "properties": {
@@ -6197,6 +6363,50 @@
                    "type": "string"
                },
                "typeId": {
                    "type": "integer"
                }
            }
        },
        "request.AddServiceFollowup": {
            "type": "object",
            "properties": {
                "clientId": {
                    "type": "integer"
                },
                "contactId": {
                    "type": "integer"
                },
                "file": {
                    "type": "string"
                },
                "isVisit": {
                    "type": "integer"
                },
                "memberId": {
                    "type": "integer"
                },
                "number": {
                    "type": "string"
                },
                "oldMemberId": {
                    "type": "integer"
                },
                "planId": {
                    "type": "integer"
                },
                "remark": {
                    "type": "string"
                },
                "satisfaction": {
                    "type": "integer"
                },
                "serviceId": {
                    "type": "integer"
                },
                "solveRate": {
                    "type": "integer"
                },
                "timelyRate": {
                    "type": "integer"
                }
            }
@@ -7717,6 +7927,53 @@
                }
            }
        },
        "request.UpdateServiceFollowup": {
            "type": "object",
            "properties": {
                "clientId": {
                    "type": "integer"
                },
                "contactId": {
                    "type": "integer"
                },
                "file": {
                    "type": "string"
                },
                "id": {
                    "type": "integer"
                },
                "isVisit": {
                    "type": "integer"
                },
                "memberId": {
                    "type": "integer"
                },
                "number": {
                    "type": "string"
                },
                "oldMemberId": {
                    "type": "integer"
                },
                "planId": {
                    "type": "integer"
                },
                "remark": {
                    "type": "string"
                },
                "satisfaction": {
                    "type": "integer"
                },
                "serviceId": {
                    "type": "integer"
                },
                "solveRate": {
                    "type": "integer"
                },
                "timelyRate": {
                    "type": "integer"
                }
            }
        },
        "request.UpdateStatus": {
            "type": "object",
            "required": [
@@ -8109,6 +8366,17 @@
                }
            }
        },
        "response.ServiceFollowupResponse": {
            "type": "object",
            "properties": {
                "list": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/model.ServiceFollowup"
                    }
                }
            }
        },
        "response.SubOrderResponse": {
            "type": "object",
            "properties": {
docs/swagger.yaml
@@ -723,6 +723,37 @@
      typeId:
        type: integer
    type: object
  model.ServiceFollowup:
    properties:
      clientId:
        type: integer
      contactId:
        type: integer
      file:
        type: string
      id:
        type: integer
      isVisit:
        type: integer
      memberId:
        type: integer
      number:
        type: string
      oldMemberId:
        type: integer
      planId:
        type: integer
      remark:
        type: string
      satisfaction:
        type: integer
      serviceId:
        type: integer
      solveRate:
        type: integer
      timelyRate:
        type: integer
    type: object
  model.SubOrder:
    properties:
      clientId:
@@ -1247,6 +1278,35 @@
      terms:
        type: string
      typeId:
        type: integer
    type: object
  request.AddServiceFollowup:
    properties:
      clientId:
        type: integer
      contactId:
        type: integer
      file:
        type: string
      isVisit:
        type: integer
      memberId:
        type: integer
      number:
        type: string
      oldMemberId:
        type: integer
      planId:
        type: integer
      remark:
        type: string
      satisfaction:
        type: integer
      serviceId:
        type: integer
      solveRate:
        type: integer
      timelyRate:
        type: integer
    type: object
  request.AddStatus:
@@ -2275,6 +2335,37 @@
      typeId:
        type: integer
    type: object
  request.UpdateServiceFollowup:
    properties:
      clientId:
        type: integer
      contactId:
        type: integer
      file:
        type: string
      id:
        type: integer
      isVisit:
        type: integer
      memberId:
        type: integer
      number:
        type: string
      oldMemberId:
        type: integer
      planId:
        type: integer
      remark:
        type: string
      satisfaction:
        type: integer
      serviceId:
        type: integer
      solveRate:
        type: integer
      timelyRate:
        type: integer
    type: object
  request.UpdateStatus:
    properties:
      id:
@@ -2524,6 +2615,13 @@
      list:
        items:
          $ref: '#/definitions/model.ServiceContract'
        type: array
    type: object
  response.ServiceFollowupResponse:
    properties:
      list:
        items:
          $ref: '#/definitions/model.ServiceFollowup'
        type: array
    type: object
  response.SubOrderResponse:
@@ -4905,6 +5003,79 @@
      summary: 更新服务合同
      tags:
      - ServiceContract
  /api/serviceFollowup/add:
    post:
      parameters:
      - description: 查询参数
        in: body
        name: object
        required: true
        schema:
          $ref: '#/definitions/request.AddServiceFollowup'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/contextx.Response'
      summary: 添加服务跟进
      tags:
      - ServiceFollowup
  /api/serviceFollowup/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:
      - ServiceFollowup
  /api/serviceFollowup/list:
    get:
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            allOf:
            - $ref: '#/definitions/contextx.Response'
            - properties:
                data:
                  $ref: '#/definitions/response.ServiceFollowupResponse'
              type: object
      summary: 服务跟进列表
      tags:
      - ServiceFollowup
  /api/serviceFollowup/update:
    put:
      parameters:
      - description: 查询参数
        in: body
        name: object
        required: true
        schema:
          $ref: '#/definitions/request.UpdateServiceFollowup'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/contextx.Response'
      summary: 更新服务跟进
      tags:
      - ServiceFollowup
  /api/status/add:
    post:
      parameters:
logs/aps-admin.err.log
@@ -348,3 +348,4 @@
[2023-07-12 15:23:10]    [error]    [aps_crm/model.(*ContractSearch).Create:46]    trace    {"error": "Error 1146 (42S02): Table 'aps_crm.contract' doesn't exist", "elapsed": 0.003547, "rows": 0, "sql": "INSERT INTO `contract` (`client_id`,`member_id`,`number`,`quotation_id`,`status_id`,`file`) VALUES (11,11,'ZDYB02-2',0,0,'string')"}
[2023-07-13 10:55:49]    [error]    [aps_crm/model.(*ServiceContractSearch).FindAll:80]    trace    {"error": ": unsupported relations for schema ServiceContract", "elapsed": 0.001442, "rows": 2, "sql": "SELECT * FROM `service_contract`"}
[2023-07-13 10:57:45]    [error]    [aps_crm/model.(*ServiceContractSearch).FindAll:80]    trace    {"error": ": unsupported relations for schema ServiceContract", "elapsed": 0.0011591, "rows": 2, "sql": "SELECT * FROM `service_contract`"}
[2023-07-13 14:11:03]    [error]    [aps_crm/model.(*ServiceFollowupSearch).Create:53]    trace    {"error": "Error 1146 (42S02): Table 'aps_crm.service_followup' doesn't exist", "elapsed": 0.0024191, "rows": 0, "sql": "INSERT INTO `service_followup` (`client_id`,`number`,`contact_id`,`service_id`,`member_id`,`plan_id`,`satisfaction`,`timely_rate`,`solve_rate`,`is_visit`,`old_member_id`,`remark`,`file`) VALUES (0,'HF21',0,0,110,0,0,0,0,0,0,'string','string')"}
model/index.go
@@ -57,6 +57,7 @@
        Plan{},
        ServiceContract{},
        OrderManage{},
        ServiceFollowup{},
    )
    return err
}
model/request/serviceFollowup.go
New file
@@ -0,0 +1,26 @@
package request
type AddServiceFollowup struct {
    ServiceFollowup
}
type ServiceFollowup struct {
    ClientId     int    `json:"clientId"`
    Number       string `json:"number"`
    ContactId    int    `json:"contactId"`
    ServiceId    int    `json:"serviceId"`
    MemberId     int    `json:"memberId"`
    PlanId       int    `json:"planId"`
    Satisfaction int    `json:"satisfaction"`
    TimelyRate   int    `json:"timelyRate"`
    SolveRate    int    `json:"solveRate"`
    IsVisit      int    `json:"isVisit"`
    OldMemberId  int    `json:"oldMemberId"`
    Remark       string `json:"remark"`
    File         string `json:"file"`
}
type UpdateServiceFollowup struct {
    Id int `json:"id"`
    ServiceFollowup
}
model/response/response.go
@@ -161,4 +161,8 @@
    OrderManageResponse struct {
        List []*model.OrderManage `json:"list"`
    }
    ServiceFollowupResponse struct {
        List []*model.ServiceFollowup `json:"list"`
    }
)
model/serviceFollowup.go
New file
@@ -0,0 +1,83 @@
package model
import (
    "aps_crm/pkg/mysqlx"
    "gorm.io/gorm"
)
type (
    ServiceFollowup 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:合同编号"`
        ContactId    int    `json:"contactId" gorm:"column:contact_id;type:int;comment:联系人id"`
        ServiceId    int    `json:"serviceId" gorm:"column:service_id;type:int;comment:客户服务单id"`
        MemberId     int    `json:"memberId" gorm:"column:member_id;type:int;comment:服务人员id"`
        PlanId       int    `json:"planId" gorm:"column:plan_id;type:int;comment:服务计划id"`
        Satisfaction int    `json:"satisfaction" gorm:"column:satisfaction;type:int;comment:满意度"`
        TimelyRate   int    `json:"timelyRate" gorm:"column:timely_rate;type:int;comment:及时率"`
        SolveRate    int    `json:"solveRate" gorm:"column:solve_rate;type:int;comment:解决率"`
        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:备注"`
        File         string `json:"file" gorm:"column:file;type:varchar(255);comment:附件"`
    }
    ServiceFollowupSearch struct {
        ServiceFollowup
        Orm *gorm.DB
    }
)
func (ServiceFollowup) TableName() string {
    return "service_followup"
}
func NewServiceFollowupSearch() *ServiceFollowupSearch {
    return &ServiceFollowupSearch{
        Orm: mysqlx.GetDB(),
    }
}
func (slf *ServiceFollowupSearch) build() *gorm.DB {
    var db = slf.Orm.Model(&ServiceFollowup{})
    if slf.Id != 0 {
        db = db.Where("id = ?", slf.Id)
    }
    return db
}
func (slf *ServiceFollowupSearch) Create(record *ServiceFollowup) error {
    var db = slf.build()
    return db.Create(record).Error
}
func (slf *ServiceFollowupSearch) Update(record *ServiceFollowup) error {
    var db = slf.build()
    return db.Updates(record).Error
}
func (slf *ServiceFollowupSearch) Delete() error {
    var db = slf.build()
    return db.Delete(&ServiceFollowup{}).Error
}
func (slf *ServiceFollowupSearch) Find() (*ServiceFollowup, error) {
    var db = slf.build()
    var record = &ServiceFollowup{}
    err := db.First(record).Error
    return record, err
}
func (slf *ServiceFollowupSearch) FindAll() ([]*ServiceFollowup, error) {
    var db = slf.build()
    var records = make([]*ServiceFollowup, 0)
    err := db.Find(&records).Error
    return records, err
}
func (slf *ServiceFollowupSearch) SetId(id int) *ServiceFollowupSearch {
    slf.Id = id
    return slf
}
pkg/ecode/code.go
@@ -247,4 +247,10 @@
    OrderManageUpdateErr = 3400005 // 更新订单管理失败
    OrderManageDeleteErr = 3400006 // 删除订单管理失败
    ServiceFollowupExist     = 3500001 // 服务跟进已存在
    ServiceFollowupNotExist  = 3500002 // 服务跟进不存在
    ServiceFollowupListErr   = 3500003 // 获取服务跟进列表失败
    ServiceFollowupSetErr    = 3500004 // 设置服务跟进失败
    ServiceFollowupUpdateErr = 3500005 // 更新服务跟进失败
    ServiceFollowupDeleteErr = 3500006 // 删除服务跟进失败
)
router/index.go
@@ -47,6 +47,7 @@
    PlanRouter
    ServiceContractRouter
    OrderManageRouter
    ServiceFollowupRouter
}
func InitRouter() *gin.Engine {
@@ -111,6 +112,7 @@
        routerGroup.InitPlanRouter(PrivateGroup)              // 注册plan路由
        routerGroup.InitServiceContractRouter(PrivateGroup)   // 注册serviceContract路由
        routerGroup.InitOrderManageRouter(PrivateGroup)       // 注册orderManage路由
        routerGroup.InitServiceFollowupRouter(PrivateGroup)   // 注册serviceFollowup路由
    }
    return Router
}
router/serviceFollowup.go
New file
@@ -0,0 +1,19 @@
package router
import (
    v1 "aps_crm/api/v1"
    "github.com/gin-gonic/gin"
)
type ServiceFollowupRouter struct{}
func (s *ServiceFollowupRouter) InitServiceFollowupRouter(router *gin.RouterGroup) {
    serviceFollowupRouter := router.Group("serviceFollowup")
    serviceFollowupApi := v1.ApiGroup.ServiceFollowupApi
    {
        serviceFollowupRouter.POST("add", serviceFollowupApi.Add)             // 添加服务跟进
        serviceFollowupRouter.DELETE("delete/:id", serviceFollowupApi.Delete) // 删除服务跟进
        serviceFollowupRouter.PUT("update", serviceFollowupApi.Update)        // 更新服务跟进
        serviceFollowupRouter.GET("list", serviceFollowupApi.List)            // 获取服务跟进列表
    }
}
service/index.go
@@ -36,6 +36,7 @@
    PlanService
    SContractService
    OrderManageService
    FollowupService
}
var ServiceGroup = new(Group)
service/serviceFollowup.go
New file
@@ -0,0 +1,54 @@
package service
import (
    "aps_crm/model"
    "aps_crm/pkg/ecode"
)
type FollowupService struct{}
func (FollowupService) AddServiceFollowup(serviceFollowup *model.ServiceFollowup) int {
    err := model.NewServiceFollowupSearch().Create(serviceFollowup)
    if err != nil {
        return ecode.ServiceFollowupExist
    }
    return ecode.OK
}
func (FollowupService) DeleteServiceFollowup(id int) int {
    _, err := model.NewServiceFollowupSearch().SetId(id).Find()
    if err != nil {
        return ecode.ServiceFollowupNotExist
    }
    err = model.NewServiceFollowupSearch().SetId(id).Delete()
    if err != nil {
        return ecode.ServiceFollowupNotExist
    }
    return ecode.OK
}
func (FollowupService) GetServiceFollowupList() ([]*model.ServiceFollowup, int) {
    list, err := model.NewServiceFollowupSearch().FindAll()
    if err != nil {
        return nil, ecode.ServiceFollowupListErr
    }
    return list, ecode.OK
}
func (FollowupService) UpdateServiceFollowup(serviceFollowup *model.ServiceFollowup) int {
    // check serviceFollowup exist
    _, err := model.NewServiceFollowupSearch().SetId(serviceFollowup.Id).Find()
    if err != nil {
        return ecode.ServiceFollowupNotExist
    }
    err = model.NewServiceFollowupSearch().SetId(serviceFollowup.Id).Update(serviceFollowup)
    if err != nil {
        return ecode.ServiceFollowupSetErr
    }
    return ecode.OK
}