add
wangpengfei
2023-07-21 c4cc5a54d61b05d98d28b21710b3c1531bc05302
add

isVisit 服务人员来访模块
add, Delete, update, list
5个文件已添加
12个文件已修改
835 ■■■■■ 已修改文件
api/v1/index.go 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/isVisit.go 113 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/serviceFollowup.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 190 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 190 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 120 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/index.go 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/isVisit.go 85 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/isVisit.go 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/response/response.go 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/serviceFollowup.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pkg/ecode/code.go 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/index.go 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/isVisit.go 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/dataServer.go 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/index.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/isVisit.go 69 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/index.go
@@ -5,6 +5,7 @@
)
type Group struct {
    IsVisitApi
    SolveRateApi
    TimelyRateApi
    BaseApi
@@ -104,4 +105,5 @@
    satisfactionService         = service.ServiceGroup.SatisfactionService
    timelyRateService           = service.ServiceGroup.TimelyRateService
    solveRateService            = service.ServiceGroup.SolveRateService
    isVisitService              = service.ServiceGroup.IsVisitService
)
api/v1/isVisit.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 IsVisitApi struct{}
// Add
//
//    @Tags        IsVisit
//    @Summary    添加服务人员是否来过
//    @Produce    application/json
//    @Param        object    body        request.AddIsVisit    true    "查询参数"
//    @Success    200        {object}    contextx.Response{}
//    @Router        /api/isVisit/add [post]
func (s *IsVisitApi) Add(c *gin.Context) {
    var params request.AddIsVisit
    ctx, ok := contextx.NewContext(c, &params)
    if !ok {
        return
    }
    isVisit := new(model.IsVisit)
    isVisit.Name = params.Name
    errCode := isVisitService.AddIsVisit(isVisit)
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
    }
    ctx.Ok()
}
// Delete
//
//    @Tags        IsVisit
//    @Summary    删除服务人员是否来过
//    @Produce    application/json
//    @Param        id    path        int    true    "查询参数"
//    @Success    200    {object}    contextx.Response{}
//    @Router        /api/isVisit/delete/{id} [delete]
func (s *IsVisitApi) Delete(c *gin.Context) {
    ctx, ok := contextx.NewContext(c, nil)
    if !ok {
        return
    }
    id, _ := strconv.Atoi(c.Param("id"))
    errCode := isVisitService.DeleteIsVisit(id)
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
    }
    ctx.Ok()
}
// Update
//
//    @Tags        IsVisit
//    @Summary    更新服务人员是否来过
//    @Produce    application/json
//    @Param        object    body        request.UpdateIsVisits    true    "查询参数"
//    @Success    200        {object}    contextx.Response{}
//    @Router        /api/isVisit/update [put]
func (s *IsVisitApi) Update(c *gin.Context) {
    var params request.UpdateIsVisits
    ctx, ok := contextx.NewContext(c, &params)
    if !ok {
        return
    }
    errCode := isVisitService.UpdateIsVisit(params.IsVisits)
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
    }
    ctx.Ok()
}
// List
//
//    @Tags        IsVisit
//    @Summary    获取服务人员是否来过列表
//    @Produce    application/json
//    @Success    200    {object}    contextx.Response{data=response.IsVisitResponse}
//    @Router        /api/isVisit/list [get]
func (s *IsVisitApi) List(c *gin.Context) {
    ctx, ok := contextx.NewContext(c, nil)
    if !ok {
        return
    }
    isVisits, errCode := isVisitService.GetIsVisitList()
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
    }
    ctx.OkWithDetailed(response.IsVisitResponse{
        List: isVisits,
    })
}
api/v1/serviceFollowup.go
@@ -142,7 +142,7 @@
        SatisfactionId: serviceFollowup.Satisfaction,
        TimelyRateId:   serviceFollowup.TimelyRate,
        SolveRateId:    serviceFollowup.SolveRate,
        IsVisit:        serviceFollowup.IsVisit,
        IsVisitId:      serviceFollowup.IsVisit,
        OldMemberId:    serviceFollowup.OldMemberId,
        Remark:         serviceFollowup.Remark,
        File:           serviceFollowup.File,
docs/docs.go
@@ -2040,6 +2040,125 @@
                }
            }
        },
        "/api/isVisit/add": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "IsVisit"
                ],
                "summary": "添加服务人员是否来过",
                "parameters": [
                    {
                        "description": "查询参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.AddIsVisit"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/contextx.Response"
                        }
                    }
                }
            }
        },
        "/api/isVisit/delete/{id}": {
            "delete": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "IsVisit"
                ],
                "summary": "删除服务人员是否来过",
                "parameters": [
                    {
                        "type": "integer",
                        "description": "查询参数",
                        "name": "id",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/contextx.Response"
                        }
                    }
                }
            }
        },
        "/api/isVisit/list": {
            "get": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "IsVisit"
                ],
                "summary": "获取服务人员是否来过列表",
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/contextx.Response"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/definitions/response.IsVisitResponse"
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        },
        "/api/isVisit/update": {
            "put": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "IsVisit"
                ],
                "summary": "更新服务人员是否来过",
                "parameters": [
                    {
                        "description": "查询参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.UpdateIsVisits"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/contextx.Response"
                        }
                    }
                }
            }
        },
        "/api/masterOrder/add": {
            "post": {
                "produces": [
@@ -5984,6 +6103,17 @@
                }
            }
        },
        "model.IsVisit": {
            "type": "object",
            "properties": {
                "id": {
                    "type": "integer"
                },
                "name": {
                    "type": "string"
                }
            }
        },
        "model.MasterOrder": {
            "type": "object",
            "properties": {
@@ -6681,7 +6811,7 @@
                "id": {
                    "type": "integer"
                },
                "isVisit": {
                "isVisitId": {
                    "type": "integer"
                },
                "memberId": {
@@ -7134,6 +7264,17 @@
            }
        },
        "request.AddIndustry": {
            "type": "object",
            "required": [
                "name"
            ],
            "properties": {
                "name": {
                    "type": "string"
                }
            }
        },
        "request.AddIsVisit": {
            "type": "object",
            "required": [
                "name"
@@ -8769,6 +8910,35 @@
                }
            }
        },
        "request.UpdateIsVisit": {
            "type": "object",
            "required": [
                "id",
                "name"
            ],
            "properties": {
                "id": {
                    "type": "integer"
                },
                "name": {
                    "type": "string"
                }
            }
        },
        "request.UpdateIsVisits": {
            "type": "object",
            "required": [
                "is_visit"
            ],
            "properties": {
                "is_visit": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/request.UpdateIsVisit"
                    }
                }
            }
        },
        "request.UpdateMasterOrder": {
            "type": "object",
            "properties": {
@@ -9812,6 +9982,13 @@
                        "$ref": "#/definitions/model.Industry"
                    }
                },
                "isVisit": {
                    "description": "服务人员是否来过",
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/model.IsVisit"
                    }
                },
                "member": {
                    "description": "Member",
                    "type": "array",
@@ -9946,6 +10123,17 @@
                }
            }
        },
        "response.IsVisitResponse": {
            "type": "object",
            "properties": {
                "list": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/model.IsVisit"
                    }
                }
            }
        },
        "response.LoginResponse": {
            "type": "object",
            "properties": {
docs/swagger.json
@@ -2028,6 +2028,125 @@
                }
            }
        },
        "/api/isVisit/add": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "IsVisit"
                ],
                "summary": "添加服务人员是否来过",
                "parameters": [
                    {
                        "description": "查询参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.AddIsVisit"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/contextx.Response"
                        }
                    }
                }
            }
        },
        "/api/isVisit/delete/{id}": {
            "delete": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "IsVisit"
                ],
                "summary": "删除服务人员是否来过",
                "parameters": [
                    {
                        "type": "integer",
                        "description": "查询参数",
                        "name": "id",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/contextx.Response"
                        }
                    }
                }
            }
        },
        "/api/isVisit/list": {
            "get": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "IsVisit"
                ],
                "summary": "获取服务人员是否来过列表",
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/contextx.Response"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/definitions/response.IsVisitResponse"
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        },
        "/api/isVisit/update": {
            "put": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "IsVisit"
                ],
                "summary": "更新服务人员是否来过",
                "parameters": [
                    {
                        "description": "查询参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.UpdateIsVisits"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/contextx.Response"
                        }
                    }
                }
            }
        },
        "/api/masterOrder/add": {
            "post": {
                "produces": [
@@ -5972,6 +6091,17 @@
                }
            }
        },
        "model.IsVisit": {
            "type": "object",
            "properties": {
                "id": {
                    "type": "integer"
                },
                "name": {
                    "type": "string"
                }
            }
        },
        "model.MasterOrder": {
            "type": "object",
            "properties": {
@@ -6669,7 +6799,7 @@
                "id": {
                    "type": "integer"
                },
                "isVisit": {
                "isVisitId": {
                    "type": "integer"
                },
                "memberId": {
@@ -7122,6 +7252,17 @@
            }
        },
        "request.AddIndustry": {
            "type": "object",
            "required": [
                "name"
            ],
            "properties": {
                "name": {
                    "type": "string"
                }
            }
        },
        "request.AddIsVisit": {
            "type": "object",
            "required": [
                "name"
@@ -8757,6 +8898,35 @@
                }
            }
        },
        "request.UpdateIsVisit": {
            "type": "object",
            "required": [
                "id",
                "name"
            ],
            "properties": {
                "id": {
                    "type": "integer"
                },
                "name": {
                    "type": "string"
                }
            }
        },
        "request.UpdateIsVisits": {
            "type": "object",
            "required": [
                "is_visit"
            ],
            "properties": {
                "is_visit": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/request.UpdateIsVisit"
                    }
                }
            }
        },
        "request.UpdateMasterOrder": {
            "type": "object",
            "properties": {
@@ -9800,6 +9970,13 @@
                        "$ref": "#/definitions/model.Industry"
                    }
                },
                "isVisit": {
                    "description": "服务人员是否来过",
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/model.IsVisit"
                    }
                },
                "member": {
                    "description": "Member",
                    "type": "array",
@@ -9934,6 +10111,17 @@
                }
            }
        },
        "response.IsVisitResponse": {
            "type": "object",
            "properties": {
                "list": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/model.IsVisit"
                    }
                }
            }
        },
        "response.LoginResponse": {
            "type": "object",
            "properties": {
docs/swagger.yaml
@@ -402,6 +402,13 @@
      name:
        type: string
    type: object
  model.IsVisit:
    properties:
      id:
        type: integer
      name:
        type: string
    type: object
  model.MasterOrder:
    properties:
      client:
@@ -860,7 +867,7 @@
        type: string
      id:
        type: integer
      isVisit:
      isVisitId:
        type: integer
      memberId:
        type: integer
@@ -1169,6 +1176,13 @@
    - follow_record
    type: object
  request.AddIndustry:
    properties:
      name:
        type: string
    required:
    - name
    type: object
  request.AddIsVisit:
    properties:
      name:
        type: string
@@ -2277,6 +2291,25 @@
    - id
    - name
    type: object
  request.UpdateIsVisit:
    properties:
      id:
        type: integer
      name:
        type: string
    required:
    - id
    - name
    type: object
  request.UpdateIsVisits:
    properties:
      is_visit:
        items:
          $ref: '#/definitions/request.UpdateIsVisit'
        type: array
    required:
    - is_visit
    type: object
  request.UpdateMasterOrder:
    properties:
      client_id:
@@ -2974,6 +3007,11 @@
        items:
          $ref: '#/definitions/model.Industry'
        type: array
      isVisit:
        description: 服务人员是否来过
        items:
          $ref: '#/definitions/model.IsVisit'
        type: array
      member:
        description: Member
        items:
@@ -3063,6 +3101,13 @@
      list:
        items:
          $ref: '#/definitions/model.Industry'
        type: array
    type: object
  response.IsVisitResponse:
    properties:
      list:
        items:
          $ref: '#/definitions/model.IsVisit'
        type: array
    type: object
  response.LoginResponse:
@@ -4489,6 +4534,79 @@
      summary: 更新行业
      tags:
      - Industry
  /api/isVisit/add:
    post:
      parameters:
      - description: 查询参数
        in: body
        name: object
        required: true
        schema:
          $ref: '#/definitions/request.AddIsVisit'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/contextx.Response'
      summary: 添加服务人员是否来过
      tags:
      - IsVisit
  /api/isVisit/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:
      - IsVisit
  /api/isVisit/list:
    get:
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            allOf:
            - $ref: '#/definitions/contextx.Response'
            - properties:
                data:
                  $ref: '#/definitions/response.IsVisitResponse'
              type: object
      summary: 获取服务人员是否来过列表
      tags:
      - IsVisit
  /api/isVisit/update:
    put:
      parameters:
      - description: 查询参数
        in: body
        name: object
        required: true
        schema:
          $ref: '#/definitions/request.UpdateIsVisits'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/contextx.Response'
      summary: 更新服务人员是否来过
      tags:
      - IsVisit
  /api/masterOrder/add:
    post:
      parameters:
model/index.go
@@ -66,6 +66,8 @@
        Satisfaction{},
        TimelyRate{},
        SolveRate{},
        IsVisit{},
        IsVisit{},
    )
    return err
}
}
model/isVisit.go
New file
@@ -0,0 +1,85 @@
package model
import (
    "aps_crm/pkg/mysqlx"
    "gorm.io/gorm"
)
type (
    // IsVisit 商机阶段
    IsVisit struct {
        Id   int    `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
        Name string `json:"name" gorm:"column:name;type:varchar(255);comment:商机阶段名称"`
    }
    IsVisitSearch struct {
        IsVisit
        Orm *gorm.DB
    }
)
func (IsVisit) TableName() string {
    return "is_visit"
}
func NewIsVisitSearch() *IsVisitSearch {
    return &IsVisitSearch{
        Orm: mysqlx.GetDB(),
    }
}
func (slf *IsVisitSearch) build() *gorm.DB {
    var db = slf.Orm.Model(&IsVisit{})
    if slf.Id != 0 {
        db = db.Where("id = ?", slf.Id)
    }
    if slf.Name != "" {
        db = db.Where("name = ?", slf.Name)
    }
    return db
}
func (slf *IsVisitSearch) Create(record *IsVisit) error {
    var db = slf.build()
    return db.Create(record).Error
}
func (slf *IsVisitSearch) Delete() error {
    var db = slf.build()
    return db.Delete(&IsVisit{}).Error
}
func (slf *IsVisitSearch) Update(record *IsVisit) error {
    var db = slf.build()
    return db.Updates(record).Error
}
func (slf *IsVisitSearch) Find() (*IsVisit, error) {
    var db = slf.build()
    var record = new(IsVisit)
    err := db.First(record).Error
    return record, err
}
func (slf *IsVisitSearch) FindAll() ([]*IsVisit, error) {
    var db = slf.build()
    var records = make([]*IsVisit, 0)
    err := db.Find(&records).Error
    return records, err
}
func (slf *IsVisitSearch) SetId(id int) *IsVisitSearch {
    slf.Id = id
    return slf
}
func (slf *IsVisitSearch) SetName(name string) *IsVisitSearch {
    slf.Name = name
    return slf
}
func (slf *IsVisitSearch) Updates(data map[string]interface{}) error {
    var db = slf.build()
    return db.Updates(data).Error
}
model/request/isVisit.go
New file
@@ -0,0 +1,15 @@
package request
type AddIsVisit struct {
    Name string `  json:"name" binding:"required"`
}
type UpdateIsVisit struct {
    Id   int    `json:"id" binding:"required"`
    Name string `json:"name" binding:"required"`
}
type UpdateIsVisits struct {
    IsVisits []*UpdateIsVisit `json:"is_visit" binding:"required"`
}
model/response/response.go
@@ -179,6 +179,10 @@
    }
    DataResponse struct {
        // 服务人员是否来过
        IsVisit []*model.IsVisit `json:"isVisit"`
        // 国家数据
        Country []*model.Country `json:"country"`
        // 省份数据
@@ -238,4 +242,8 @@
    SolveRateResponse struct {
        List []*model.SolveRate `json:"list"`
    }
    IsVisitResponse struct {
        List []*model.IsVisit `json:"list"`
    }
)
model/serviceFollowup.go
@@ -18,7 +18,7 @@
        SatisfactionId       int                  `json:"satisfactionId" gorm:"column:satisfaction_id;type:int;comment:满意度id"`
        TimelyRateId         int                  `json:"timelyRateId" gorm:"column:timely_rate_id;type:int;comment:及时率id"`
        SolveRateId          int                  `json:"solveRateId" gorm:"column:solve_rate_id;type:int;comment:解决率id"`
        IsVisit              int                  `json:"isVisit" gorm:"column:is_visit;type:int;comment:服务人员是否来过"`
        IsVisitId            int                  `json:"isVisitId" gorm:"column:is_visit_id;type:int;comment:服务人员是否来过id"`
        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:附件"`
pkg/ecode/code.go
@@ -309,4 +309,11 @@
    SolveRateListErr   = 4400003 // 获取解决率列表失败
    SolveRateSetErr    = 4400004 // 设置解决率失败
    SolveRateUpdateErr = 4400005 // 更新解决率失败
    IsVisitExist     = 4500001 // 服务人员是否来过已存在
    IsVisitNotExist  = 4500002 // 服务人员是否来过不存在
    IsVisitListErr   = 4500003 // 获取服务人员是否来过列表失败
    IsVisitSetErr    = 4500004 // 设置服务人员是否来过失败
    IsVisitUpdateErr = 4500005 // 更新服务人员是否来过失败
)
router/index.go
@@ -11,6 +11,7 @@
)
type Group struct {
    IsVisitRouter
    SolveRateRouter
    TimelyRateRouter
    BaseRouter
@@ -133,6 +134,7 @@
        routerGroup.InitSatisfactionRouter(PrivateGroup)         // 注册satisfaction路由
        routerGroup.InitTimelyRateRouter(PrivateGroup)
        routerGroup.InitSolveRateRouter(PrivateGroup)
        routerGroup.InitIsVisitRouter(PrivateGroup)
    }
    return Router
}
router/isVisit.go
New file
@@ -0,0 +1,20 @@
package router
import (
    v1 "aps_crm/api/v1"
    "github.com/gin-gonic/gin"
)
type IsVisitRouter struct{}
func (s *IsVisitRouter) InitIsVisitRouter(router *gin.RouterGroup) {
    isVisitRouter := router.Group("isVisit")
    isVisitApi := v1.ApiGroup.IsVisitApi
    {
        isVisitRouter.POST("add", isVisitApi.Add)             // 添加$CName$
        isVisitRouter.DELETE("delete/:id", isVisitApi.Delete) // 删除$CName$
        isVisitRouter.PUT("update", isVisitApi.Update)        // 更新$CName$
        isVisitRouter.GET("list", isVisitApi.List)            // 获取$CName$列表
    }
}
service/dataServer.go
@@ -92,8 +92,11 @@
    solveRateList, _ := ServiceGroup.GetSolveRateList()
    data.SolveRate = solveRateList
    // get IsVisit list
    isVisitList, _ := ServiceGroup.GetIsVisitList()
    data.IsVisit = isVisitList
    errCode = ecode.OK
    return
}
}
service/index.go
@@ -48,6 +48,7 @@
    SatisfactionService
    TimelyRateService
    SolveRateService
    IsVisitService
}
var ServiceGroup = new(Group)
service/isVisit.go
New file
@@ -0,0 +1,69 @@
package service
import (
    "aps_crm/model"
    "aps_crm/model/request"
    "aps_crm/pkg/ecode"
)
type IsVisitService struct{}
func (IsVisitService) AddIsVisit(isVisit *model.IsVisit) int {
    err := model.NewIsVisitSearch().Create(isVisit)
    if err != nil {
        return ecode.IsVisitExist
    }
    return ecode.OK
}
func (IsVisitService) DeleteIsVisit(id int) int {
    _, err := model.NewIsVisitSearch().SetId(id).Find()
    if err != nil {
        return ecode.IsVisitNotExist
    }
    err = model.NewIsVisitSearch().SetId(id).Delete()
    if err != nil {
        return ecode.IsVisitNotExist
    }
    return ecode.OK
}
func (IsVisitService) GetIsVisitList() ([]*model.IsVisit, int) {
    list, err := model.NewIsVisitSearch().FindAll()
    if err != nil {
        return nil, ecode.IsVisitListErr
    }
    return list, ecode.OK
}
func (IsVisitService) UpdateIsVisit(isVisits []*request.UpdateIsVisit) int {
    for _, v := range isVisits {
        // check isVisit exist
        _, err := model.NewIsVisitSearch().SetId(v.Id).Find()
        if err != nil {
            return ecode.IsVisitNotExist
        }
        err = model.NewIsVisitSearch().SetId(v.Id).Updates(map[string]interface{}{
            "name": v.Name,
        })
        if err != nil {
            return ecode.IsVisitSetErr
        }
    }
    return ecode.OK
}
func (IsVisitService) GetIsVisitDetail(id int) (*model.IsVisit, int) {
    isVisit, err := model.NewIsVisitSearch().SetId(id).Find()
    if err != nil {
        return nil, ecode.IsVisitNotExist
    }
    return isVisit, ecode.OK
}