add
wangpengfei
2023-07-21 54f4078e9462871995cf4b241df217b18cdd6e08
add

ReportSource 报修来源模块
add, Delete, update, list
5个文件已添加
12个文件已修改
867 ■■■■■ 已修改文件
api/v1/index.go 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/orderManage.go 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/reportSource.go 113 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 196 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 196 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 126 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/index.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/reportSource.go 85 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/reportSource.go 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/response/response.go 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/serviceFollowup.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pkg/ecode/code.go 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/index.go 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/reportSource.go 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/dataServer.go 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/index.go 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/reportSource.go 69 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/index.go
@@ -5,6 +5,7 @@
)
type Group struct {
    ReportSourceApi
    IsVisitApi
    SolveRateApi
    TimelyRateApi
@@ -106,4 +107,5 @@
    timelyRateService           = service.ServiceGroup.TimelyRateService
    solveRateService            = service.ServiceGroup.SolveRateService
    isVisitService              = service.ServiceGroup.IsVisitService
)
   reportSourceService    = service.ServiceGroup.ReportSourceService
)
api/v1/orderManage.go
@@ -15,7 +15,7 @@
// Add
//
//    @Tags        OrderManage
//    @Summary    添加订单
//    @Summary    添加工单
//    @Produce    application/json
//    @Param        object    body        request.AddOrderManage    true    "查询参数"
//    @Success    200        {object}    contextx.Response{}
@@ -45,7 +45,7 @@
// Delete
//
//    @Tags        OrderManage
//    @Summary    删除订单
//    @Summary    删除工单
//    @Produce    application/json
//    @Param        id    path        int    true    "查询参数"
//    @Success    200    {object}    contextx.Response{}
@@ -69,7 +69,7 @@
// Update
//
//    @Tags        OrderManage
//    @Summary    更新订单
//    @Summary    更新工单
//    @Produce    application/json
//    @Param        object    body        request.UpdateOrderManage    true    "查询参数"
//    @Success    200        {object}    contextx.Response{}
@@ -101,7 +101,7 @@
// List
//
//    @Tags        OrderManage
//    @Summary    订单列表
//    @Summary    工单列表
//    @Produce    application/json
//    @Success    200    {object}    contextx.Response{}
//    @Router        /api/orderManage/list [get]
api/v1/reportSource.go
New file
@@ -0,0 +1,113 @@
package v1
import (
    "aps_crm/model"
    "aps_crm/model/request"
    "aps_crm/model/response"
    "aps_crm/pkg/contextx"
    "aps_crm/pkg/ecode"
    "github.com/gin-gonic/gin"
    "strconv"
)
type ReportSourceApi struct{}
// Add
//
//    @Tags        ReportSource
//    @Summary    添加报表来源
//    @Produce    application/json
//    @Param        object    body        request.AddReportSource    true    "查询参数"
//    @Success    200        {object}    contextx.Response{}
//    @Router        /api/reportSource/add [post]
func (s *ReportSourceApi) Add(c *gin.Context) {
    var params request.AddReportSource
    ctx, ok := contextx.NewContext(c, &params)
    if !ok {
        return
    }
    reportSource := new(model.ReportSource)
    reportSource.Name = params.Name
    errCode := reportSourceService.AddReportSource(reportSource)
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
    }
    ctx.Ok()
}
// Delete
//
//    @Tags        ReportSource
//    @Summary    删除报表来源
//    @Produce    application/json
//    @Param        id    path        int    true    "查询参数"
//    @Success    200    {object}    contextx.Response{}
//    @Router        /api/reportSource/delete/{id} [delete]
func (s *ReportSourceApi) Delete(c *gin.Context) {
    ctx, ok := contextx.NewContext(c, nil)
    if !ok {
        return
    }
    id, _ := strconv.Atoi(c.Param("id"))
    errCode := reportSourceService.DeleteReportSource(id)
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
    }
    ctx.Ok()
}
// Update
//
//    @Tags        ReportSource
//    @Summary    更新报表来源
//    @Produce    application/json
//    @Param        object    body        request.UpdateReportSources    true    "查询参数"
//    @Success    200        {object}    contextx.Response{}
//    @Router        /api/reportSource/update [put]
func (s *ReportSourceApi) Update(c *gin.Context) {
    var params request.UpdateReportSources
    ctx, ok := contextx.NewContext(c, &params)
    if !ok {
        return
    }
    errCode := reportSourceService.UpdateReportSource(params.ReportSources)
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
    }
    ctx.Ok()
}
// List
//
//    @Tags        ReportSource
//    @Summary    获取报表来源列表
//    @Produce    application/json
//    @Success    200    {object}    contextx.Response{data=response.ReportSourceResponse}
//    @Router        /api/reportSource/list [get]
func (s *ReportSourceApi) List(c *gin.Context) {
    ctx, ok := contextx.NewContext(c, nil)
    if !ok {
        return
    }
    reportSources, errCode := reportSourceService.GetReportSourceList()
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
    }
    ctx.OkWithDetailed(response.ReportSourceResponse{
        List: reportSources,
    })
}
docs/docs.go
@@ -2331,7 +2331,7 @@
                "tags": [
                    "OrderManage"
                ],
                "summary": "添加订单",
                "summary": "添加工单",
                "parameters": [
                    {
                        "description": "查询参数",
@@ -2361,7 +2361,7 @@
                "tags": [
                    "OrderManage"
                ],
                "summary": "删除订单",
                "summary": "删除工单",
                "parameters": [
                    {
                        "type": "integer",
@@ -2389,7 +2389,7 @@
                "tags": [
                    "OrderManage"
                ],
                "summary": "订单列表",
                "summary": "工单列表",
                "responses": {
                    "200": {
                        "description": "OK",
@@ -2408,7 +2408,7 @@
                "tags": [
                    "OrderManage"
                ],
                "summary": "更新订单",
                "summary": "更新工单",
                "parameters": [
                    {
                        "description": "查询参数",
@@ -3316,6 +3316,125 @@
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.UpdateRegularCustomersList"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/contextx.Response"
                        }
                    }
                }
            }
        },
        "/api/reportSource/add": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "ReportSource"
                ],
                "summary": "添加报表来源",
                "parameters": [
                    {
                        "description": "查询参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.AddReportSource"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/contextx.Response"
                        }
                    }
                }
            }
        },
        "/api/reportSource/delete/{id}": {
            "delete": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "ReportSource"
                ],
                "summary": "删除报表来源",
                "parameters": [
                    {
                        "type": "integer",
                        "description": "查询参数",
                        "name": "id",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/contextx.Response"
                        }
                    }
                }
            }
        },
        "/api/reportSource/list": {
            "get": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "ReportSource"
                ],
                "summary": "获取报表来源列表",
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/contextx.Response"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/definitions/response.ReportSourceResponse"
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        },
        "/api/reportSource/update": {
            "put": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "ReportSource"
                ],
                "summary": "更新报表来源",
                "parameters": [
                    {
                        "description": "查询参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.UpdateReportSources"
                        }
                    }
                ],
@@ -6342,6 +6461,17 @@
                }
            }
        },
        "model.ReportSource": {
            "type": "object",
            "properties": {
                "id": {
                    "type": "integer"
                },
                "name": {
                    "type": "string"
                }
            }
        },
        "model.SaleChance": {
            "type": "object",
            "properties": {
@@ -7421,6 +7551,17 @@
            }
        },
        "request.AddRegularCustomers": {
            "type": "object",
            "required": [
                "name"
            ],
            "properties": {
                "name": {
                    "type": "string"
                }
            }
        },
        "request.AddReportSource": {
            "type": "object",
            "required": [
                "name"
@@ -9180,6 +9321,35 @@
                }
            }
        },
        "request.UpdateReportSource": {
            "type": "object",
            "required": [
                "id",
                "name"
            ],
            "properties": {
                "id": {
                    "type": "integer"
                },
                "name": {
                    "type": "string"
                }
            }
        },
        "request.UpdateReportSources": {
            "type": "object",
            "required": [
                "report_source"
            ],
            "properties": {
                "report_source": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/request.UpdateReportSource"
                    }
                }
            }
        },
        "request.UpdateSaleChance": {
            "type": "object",
            "required": [
@@ -10024,6 +10194,13 @@
                        "$ref": "#/definitions/model.RegularCustomers"
                    }
                },
                "reportSource": {
                    "description": "报表来源",
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/model.ReportSource"
                    }
                },
                "sale_stage": {
                    "description": "销售阶段",
                    "type": "array",
@@ -10251,6 +10428,17 @@
                }
            }
        },
        "response.ReportSourceResponse": {
            "type": "object",
            "properties": {
                "list": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/model.ReportSource"
                    }
                }
            }
        },
        "response.SaleChanceResponse": {
            "type": "object",
            "properties": {
docs/swagger.json
@@ -2319,7 +2319,7 @@
                "tags": [
                    "OrderManage"
                ],
                "summary": "添加订单",
                "summary": "添加工单",
                "parameters": [
                    {
                        "description": "查询参数",
@@ -2349,7 +2349,7 @@
                "tags": [
                    "OrderManage"
                ],
                "summary": "删除订单",
                "summary": "删除工单",
                "parameters": [
                    {
                        "type": "integer",
@@ -2377,7 +2377,7 @@
                "tags": [
                    "OrderManage"
                ],
                "summary": "订单列表",
                "summary": "工单列表",
                "responses": {
                    "200": {
                        "description": "OK",
@@ -2396,7 +2396,7 @@
                "tags": [
                    "OrderManage"
                ],
                "summary": "更新订单",
                "summary": "更新工单",
                "parameters": [
                    {
                        "description": "查询参数",
@@ -3304,6 +3304,125 @@
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.UpdateRegularCustomersList"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/contextx.Response"
                        }
                    }
                }
            }
        },
        "/api/reportSource/add": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "ReportSource"
                ],
                "summary": "添加报表来源",
                "parameters": [
                    {
                        "description": "查询参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.AddReportSource"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/contextx.Response"
                        }
                    }
                }
            }
        },
        "/api/reportSource/delete/{id}": {
            "delete": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "ReportSource"
                ],
                "summary": "删除报表来源",
                "parameters": [
                    {
                        "type": "integer",
                        "description": "查询参数",
                        "name": "id",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/contextx.Response"
                        }
                    }
                }
            }
        },
        "/api/reportSource/list": {
            "get": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "ReportSource"
                ],
                "summary": "获取报表来源列表",
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/contextx.Response"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/definitions/response.ReportSourceResponse"
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        },
        "/api/reportSource/update": {
            "put": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "ReportSource"
                ],
                "summary": "更新报表来源",
                "parameters": [
                    {
                        "description": "查询参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.UpdateReportSources"
                        }
                    }
                ],
@@ -6330,6 +6449,17 @@
                }
            }
        },
        "model.ReportSource": {
            "type": "object",
            "properties": {
                "id": {
                    "type": "integer"
                },
                "name": {
                    "type": "string"
                }
            }
        },
        "model.SaleChance": {
            "type": "object",
            "properties": {
@@ -7409,6 +7539,17 @@
            }
        },
        "request.AddRegularCustomers": {
            "type": "object",
            "required": [
                "name"
            ],
            "properties": {
                "name": {
                    "type": "string"
                }
            }
        },
        "request.AddReportSource": {
            "type": "object",
            "required": [
                "name"
@@ -9168,6 +9309,35 @@
                }
            }
        },
        "request.UpdateReportSource": {
            "type": "object",
            "required": [
                "id",
                "name"
            ],
            "properties": {
                "id": {
                    "type": "integer"
                },
                "name": {
                    "type": "string"
                }
            }
        },
        "request.UpdateReportSources": {
            "type": "object",
            "required": [
                "report_source"
            ],
            "properties": {
                "report_source": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/request.UpdateReportSource"
                    }
                }
            }
        },
        "request.UpdateSaleChance": {
            "type": "object",
            "required": [
@@ -10012,6 +10182,13 @@
                        "$ref": "#/definitions/model.RegularCustomers"
                    }
                },
                "reportSource": {
                    "description": "报表来源",
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/model.ReportSource"
                    }
                },
                "sale_stage": {
                    "description": "销售阶段",
                    "type": "array",
@@ -10239,6 +10416,17 @@
                }
            }
        },
        "response.ReportSourceResponse": {
            "type": "object",
            "properties": {
                "list": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/model.ReportSource"
                    }
                }
            }
        },
        "response.SaleChanceResponse": {
            "type": "object",
            "properties": {
docs/swagger.yaml
@@ -558,6 +558,13 @@
      name:
        type: string
    type: object
  model.ReportSource:
    properties:
      id:
        type: integer
      name:
        type: string
    type: object
  model.SaleChance:
    properties:
      advantages:
@@ -1278,6 +1285,13 @@
    - name
    type: object
  request.AddRegularCustomers:
    properties:
      name:
        type: string
    required:
    - name
    type: object
  request.AddReportSource:
    properties:
      name:
        type: string
@@ -2469,6 +2483,25 @@
    required:
    - regularCustomers
    type: object
  request.UpdateReportSource:
    properties:
      id:
        type: integer
      name:
        type: string
    required:
    - id
    - name
    type: object
  request.UpdateReportSources:
    properties:
      report_source:
        items:
          $ref: '#/definitions/request.UpdateReportSource'
        type: array
    required:
    - report_source
    type: object
  request.UpdateSaleChance:
    properties:
      advantages:
@@ -3037,6 +3070,11 @@
        items:
          $ref: '#/definitions/model.RegularCustomers'
        type: array
      reportSource:
        description: 报表来源
        items:
          $ref: '#/definitions/model.ReportSource'
        type: array
      sale_stage:
        description: 销售阶段
        items:
@@ -3183,6 +3221,13 @@
      list:
        items:
          $ref: '#/definitions/model.RegularCustomers'
        type: array
    type: object
  response.ReportSourceResponse:
    properties:
      list:
        items:
          $ref: '#/definitions/model.ReportSource'
        type: array
    type: object
  response.SaleChanceResponse:
@@ -4721,7 +4766,7 @@
          description: OK
          schema:
            $ref: '#/definitions/contextx.Response'
      summary: 添加订单
      summary: 添加工单
      tags:
      - OrderManage
  /api/orderManage/delete/{id}:
@@ -4739,7 +4784,7 @@
          description: OK
          schema:
            $ref: '#/definitions/contextx.Response'
      summary: 删除订单
      summary: 删除工单
      tags:
      - OrderManage
  /api/orderManage/list:
@@ -4751,7 +4796,7 @@
          description: OK
          schema:
            $ref: '#/definitions/contextx.Response'
      summary: 订单列表
      summary: 工单列表
      tags:
      - OrderManage
  /api/orderManage/update:
@@ -4770,7 +4815,7 @@
          description: OK
          schema:
            $ref: '#/definitions/contextx.Response'
      summary: 更新订单
      summary: 更新工单
      tags:
      - OrderManage
  /api/plan/add:
@@ -5329,6 +5374,79 @@
      summary: 更新常客
      tags:
      - RegularCustomers
  /api/reportSource/add:
    post:
      parameters:
      - description: 查询参数
        in: body
        name: object
        required: true
        schema:
          $ref: '#/definitions/request.AddReportSource'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/contextx.Response'
      summary: 添加报表来源
      tags:
      - ReportSource
  /api/reportSource/delete/{id}:
    delete:
      parameters:
      - description: 查询参数
        in: path
        name: id
        required: true
        type: integer
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/contextx.Response'
      summary: 删除报表来源
      tags:
      - ReportSource
  /api/reportSource/list:
    get:
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            allOf:
            - $ref: '#/definitions/contextx.Response'
            - properties:
                data:
                  $ref: '#/definitions/response.ReportSourceResponse'
              type: object
      summary: 获取报表来源列表
      tags:
      - ReportSource
  /api/reportSource/update:
    put:
      parameters:
      - description: 查询参数
        in: body
        name: object
        required: true
        schema:
          $ref: '#/definitions/request.UpdateReportSources'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/contextx.Response'
      summary: 更新报表来源
      tags:
      - ReportSource
  /api/saleChance/add:
    post:
      parameters:
model/index.go
@@ -68,6 +68,7 @@
        SolveRate{},
        IsVisit{},
        IsVisit{},
        ReportSource{},
    )
    return err
}
model/reportSource.go
New file
@@ -0,0 +1,85 @@
package model
import (
    "aps_crm/pkg/mysqlx"
    "gorm.io/gorm"
)
type (
    // ReportSource 商机阶段
    ReportSource struct {
        Id   int    `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
        Name string `json:"name" gorm:"column:name;type:varchar(255);comment:商机阶段名称"`
    }
    ReportSourceSearch struct {
        ReportSource
        Orm *gorm.DB
    }
)
func (ReportSource) TableName() string {
    return "report_source"
}
func NewReportSourceSearch() *ReportSourceSearch {
    return &ReportSourceSearch{
        Orm: mysqlx.GetDB(),
    }
}
func (slf *ReportSourceSearch) build() *gorm.DB {
    var db = slf.Orm.Model(&ReportSource{})
    if slf.Id != 0 {
        db = db.Where("id = ?", slf.Id)
    }
    if slf.Name != "" {
        db = db.Where("name = ?", slf.Name)
    }
    return db
}
func (slf *ReportSourceSearch) Create(record *ReportSource) error {
    var db = slf.build()
    return db.Create(record).Error
}
func (slf *ReportSourceSearch) Delete() error {
    var db = slf.build()
    return db.Delete(&ReportSource{}).Error
}
func (slf *ReportSourceSearch) Update(record *ReportSource) error {
    var db = slf.build()
    return db.Updates(record).Error
}
func (slf *ReportSourceSearch) Find() (*ReportSource, error) {
    var db = slf.build()
    var record = new(ReportSource)
    err := db.First(record).Error
    return record, err
}
func (slf *ReportSourceSearch) FindAll() ([]*ReportSource, error) {
    var db = slf.build()
    var records = make([]*ReportSource, 0)
    err := db.Find(&records).Error
    return records, err
}
func (slf *ReportSourceSearch) SetId(id int) *ReportSourceSearch {
    slf.Id = id
    return slf
}
func (slf *ReportSourceSearch) SetName(name string) *ReportSourceSearch {
    slf.Name = name
    return slf
}
func (slf *ReportSourceSearch) Updates(data map[string]interface{}) error {
    var db = slf.build()
    return db.Updates(data).Error
}
model/request/reportSource.go
New file
@@ -0,0 +1,15 @@
package request
type AddReportSource struct {
    Name string `  json:"name" binding:"required"`
}
type UpdateReportSource struct {
    Id   int    `json:"id" binding:"required"`
    Name string `json:"name" binding:"required"`
}
type UpdateReportSources struct {
    ReportSources []*UpdateReportSource `json:"report_source" binding:"required"`
}
model/response/response.go
@@ -180,6 +180,10 @@
    DataResponse struct {
        // 报表来源
        ReportSource []*model.ReportSource `json:"reportSource"`
        // 服务人员是否来过
        IsVisit []*model.IsVisit `json:"isVisit"`
@@ -246,4 +250,8 @@
    IsVisitResponse struct {
        List []*model.IsVisit `json:"list"`
    }
)
    ReportSourceResponse struct {
        List []*model.ReportSource `json:"list"`
    }
)
model/serviceFollowup.go
@@ -85,7 +85,6 @@
    return slf
}
// 及时率 解决率 满意度 服务人员是否来过 (服务回访单)
// 工单类型 报修来源(工单管理)
// 合同类型 合同状态(服务合同)
// 付款方式 是否开票 账户(销售退款单)
pkg/ecode/code.go
@@ -316,4 +316,11 @@
    IsVisitSetErr    = 4500004 // 设置服务人员是否来过失败
    IsVisitUpdateErr = 4500005 // 更新服务人员是否来过失败
)
    ReportSourceExist     = 4400001 // 报表来源已存在
    ReportSourceNotExist  = 4400002 // 报表来源不存在
    ReportSourceListErr   = 4400003 // 获取报表来源列表失败
    ReportSourceSetErr    = 4400004 // 设置报表来源失败
    ReportSourceUpdateErr = 4400005 // 更新报表来源失败
)
router/index.go
@@ -11,6 +11,7 @@
)
type Group struct {
    ReportSourceRouter
    IsVisitRouter
    SolveRateRouter
    TimelyRateRouter
@@ -135,6 +136,7 @@
        routerGroup.InitTimelyRateRouter(PrivateGroup)
        routerGroup.InitSolveRateRouter(PrivateGroup)
        routerGroup.InitIsVisitRouter(PrivateGroup)
        routerGroup.InitReportSourceRouter(PrivateGroup)
    }
    return Router
}
}
router/reportSource.go
New file
@@ -0,0 +1,20 @@
package router
import (
    v1 "aps_crm/api/v1"
    "github.com/gin-gonic/gin"
)
type ReportSourceRouter struct{}
func (s *ReportSourceRouter) InitReportSourceRouter(router *gin.RouterGroup) {
    reportSourceRouter := router.Group("reportSource")
    reportSourceApi := v1.ApiGroup.ReportSourceApi
    {
        reportSourceRouter.POST("add", reportSourceApi.Add)             // 添加$CName$
        reportSourceRouter.DELETE("delete/:id", reportSourceApi.Delete) // 删除$CName$
        reportSourceRouter.PUT("update", reportSourceApi.Update)        // 更新$CName$
        reportSourceRouter.GET("list", reportSourceApi.List)            // 获取$CName$列表
    }
}
service/dataServer.go
@@ -96,7 +96,12 @@
    isVisitList, _ := ServiceGroup.GetIsVisitList()
    data.IsVisit = isVisitList
    // get ReportSource list
    reportSourceList, _ := ServiceGroup.GetReportSourceList()
    data.ReportSource = reportSourceList
    errCode = ecode.OK
    return
}
}
service/index.go
@@ -49,6 +49,7 @@
    TimelyRateService
    SolveRateService
    IsVisitService
    ReportSourceService
}
var ServiceGroup = new(Group)
var ServiceGroup = new(Group)
service/reportSource.go
New file
@@ -0,0 +1,69 @@
package service
import (
    "aps_crm/model"
    "aps_crm/model/request"
    "aps_crm/pkg/ecode"
)
type ReportSourceService struct{}
func (ReportSourceService) AddReportSource(reportSource *model.ReportSource) int {
    err := model.NewReportSourceSearch().Create(reportSource)
    if err != nil {
        return ecode.ReportSourceExist
    }
    return ecode.OK
}
func (ReportSourceService) DeleteReportSource(id int) int {
    _, err := model.NewReportSourceSearch().SetId(id).Find()
    if err != nil {
        return ecode.ReportSourceNotExist
    }
    err = model.NewReportSourceSearch().SetId(id).Delete()
    if err != nil {
        return ecode.ReportSourceNotExist
    }
    return ecode.OK
}
func (ReportSourceService) GetReportSourceList() ([]*model.ReportSource, int) {
    list, err := model.NewReportSourceSearch().FindAll()
    if err != nil {
        return nil, ecode.ReportSourceListErr
    }
    return list, ecode.OK
}
func (ReportSourceService) UpdateReportSource(reportSources []*request.UpdateReportSource) int {
    for _, v := range reportSources {
        // check reportSource exist
        _, err := model.NewReportSourceSearch().SetId(v.Id).Find()
        if err != nil {
            return ecode.ReportSourceNotExist
        }
        err = model.NewReportSourceSearch().SetId(v.Id).Updates(map[string]interface{}{
            "name": v.Name,
        })
        if err != nil {
            return ecode.ReportSourceSetErr
        }
    }
    return ecode.OK
}
func (ReportSourceService) GetReportSourceDetail(id int) (*model.ReportSource, int) {
    reportSource, err := model.NewReportSourceSearch().SetId(id).Find()
    if err != nil {
        return nil, ecode.ReportSourceNotExist
    }
    return reportSource, ecode.OK
}