fix
wangpengfei
2023-08-03 38427bd1931107447652cde2ccd69eb0c1ebd4cf
fix

add batch assign function to followRecord, salesLeads, contact, client module
12个文件已修改
107 ■■■■ 已修改文件
api/v1/assign.go 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/followRecord.go 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/assign.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pkg/ecode/code.go 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/assign.go 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/client.go 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/contact.go 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/followRecord.go 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/salesLeads.go 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/assign.go
@@ -12,7 +12,7 @@
// Assign
//
//    @Tags        Assign
//    @Summary    审核
//    @Summary    分配
//    @Produce    application/json
//    @Param        object    body        request.Assign true    "查询参数"
//    @Success    200        {object}    contextx.Response{}
@@ -29,7 +29,7 @@
        return
    }
    if params.Id == 0 {
    if len(params.Ids) == 0 {
        ctx.Fail(ecode.AssignWrongId)
        return
    }
@@ -39,7 +39,7 @@
        return
    }
    errCode := assignService.Assign(params.MemberId, params.Id, params.Type)
    errCode := assignService.Assign(params.MemberId, params.Ids, params.Type)
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
docs/docs.go
@@ -143,7 +143,7 @@
                "tags": [
                    "Assign"
                ],
                "summary": "审核",
                "summary": "分配",
                "parameters": [
                    {
                        "description": "查询参数",
@@ -9803,8 +9803,11 @@
        "request.Assign": {
            "type": "object",
            "properties": {
                "id": {
                "ids": {
                    "type": "array",
                    "items": {
                    "type": "integer"
                    }
                },
                "member_id": {
                    "type": "integer"
docs/swagger.json
@@ -131,7 +131,7 @@
                "tags": [
                    "Assign"
                ],
                "summary": "审核",
                "summary": "分配",
                "parameters": [
                    {
                        "description": "查询参数",
@@ -9791,8 +9791,11 @@
        "request.Assign": {
            "type": "object",
            "properties": {
                "id": {
                "ids": {
                    "type": "array",
                    "items": {
                    "type": "integer"
                    }
                },
                "member_id": {
                    "type": "integer"
docs/swagger.yaml
@@ -1803,8 +1803,10 @@
    type: object
  request.Assign:
    properties:
      id:
      ids:
        items:
        type: integer
        type: array
      member_id:
        type: integer
      type:
@@ -4223,7 +4225,7 @@
          description: OK
          schema:
            $ref: '#/definitions/contextx.Response'
      summary: 审核
      summary: 分配
      tags:
      - Assign
  /api/authority/add:
model/followRecord.go
@@ -187,3 +187,8 @@
    slf.Orm = slf.Orm.Where("id in (?)", ids)
    return slf
}
func (slf *FollowRecordSearch) UpdateMap(data map[string]interface{}) error {
    var db = slf.build()
    return db.Updates(data).Error
}
model/request/assign.go
@@ -3,5 +3,5 @@
type Assign struct {
    MemberId int    `json:"member_id"`
    Type     string `json:"type"`
    Id       int    `json:"id"`
    Ids      []int  `json:"ids"`
}
pkg/ecode/code.go
@@ -65,6 +65,7 @@
    ContactListErr   = 600003 // 获取联系人列表失败
    ContactDeleteErr = 600004 // 删除联系人失败
    ContactUpdateErr = 600005 // 更新联系人失败
    ContactAssignErr = 600006 // 分配联系人失败
    ClientExist     = 700001 // 客户已存在
    ClientNotExist  = 700002 // 客户不存在
@@ -136,6 +137,7 @@
    FollowRecordSetErr    = 1800004 // 设置跟进记录失败
    FollowRecordUpdateErr = 1800005 // 更新跟进记录失败
    FollowRecordDeleteErr = 1800006 // 删除跟进记录失败
    FollowRecordAssignErr = 1800007 // 分配跟进记录失败
    SaleChanceExist     = 1900001 // 销售机会已存在
    SaleChanceNotExist  = 1900002 // 销售机会不存在
service/assign.go
@@ -11,7 +11,7 @@
    Assign(id int) error
}
func (AssignService) Assign(memberId, id int, modelType string) int {
func (AssignService) Assign(memberId int, ids []int, modelType string) int {
    // check member exist
    _, err := model.NewUserSearch(nil).SetUserId(memberId).First()
    if err != nil {
@@ -21,9 +21,14 @@
    var errCode int
    switch modelType {
    case "client":
        errCode = ClientService{}.Assign(id, memberId)
        errCode = ClientService{}.Assign(ids, memberId)
    case "salesLead":
        errCode = SalesLeadsService{}.Assign(id, memberId)
        errCode = SalesLeadsService{}.Assign(ids, memberId)
    case "contact":
        errCode = ContactService{}.Assign(ids, memberId)
    case "followRecord":
        errCode = FollowRecordService{}.Assign(ids, memberId)
    default:
        errCode = ecode.AssignWrongModelType
    }
service/client.go
@@ -50,15 +50,15 @@
    return contacts, total, ecode.OK
}
func (ClientService) Assign(id, memberId int) int {
func (ClientService) Assign(ids []int, memberId int) int {
    // check client exist
    errCode := CheckClientExist(id)
    if errCode != ecode.OK {
        return errCode
    }
    //errCode := CheckClientExist(id)
    //if errCode != ecode.OK {
    //    return errCode
    //}
    // assign client
    err := model.NewClientSearch(nil).SetId(id).UpdateByMap(map[string]interface{}{
    err := model.NewClientSearch(nil).SetIds(ids).UpdateByMap(map[string]interface{}{
        "member_id": memberId,
    })
    if err != nil {
service/contact.go
@@ -33,7 +33,6 @@
    return ecode.OK
}
func (ContactService) UpdateContact(contact *model.Contact) int {
    // check contact exist
    _, err := model.NewContactSearch(nil).SetId(contact.Id).First()
@@ -120,3 +119,21 @@
    }
    return ecode.OK
}
func (ContactService) Assign(ids []int, memberId int) int {
    // check contact exist
    //errCode := CheckContactExist(id)
    //if errCode != ecode.OK {
    //    return errCode
    //}
    // assign contact
    err := model.NewContactSearch(nil).SetIds(ids).UpdateByMap(map[string]interface{}{
        "member_id": memberId,
    })
    if err != nil {
        return ecode.ContactAssignErr
    }
    return ecode.OK
}
service/followRecord.go
@@ -57,3 +57,21 @@
    }
    return ecode.OK
}
func (FollowRecordService) Assign(ids []int, memberId int) int {
    // check followRecord exist
    //errCode := checkFollowRecordExist(id)
    //if errCode != ecode.OK {
    //    return errCode
    //}
    // assign followRecord
    err := model.NewFollowRecordSearch().SetIds(ids).UpdateMap(map[string]interface{}{
        "member_id": memberId,
    })
    if err != nil {
        return ecode.FollowRecordAssignErr
    }
    return ecode.OK
}
service/salesLeads.go
@@ -48,15 +48,15 @@
    return contacts, total, ecode.OK
}
func (SalesLeadsService) Assign(id, memberId int) int {
func (SalesLeadsService) Assign(ids []int, memberId int) int {
    // check salesLeads exist
    errCode := CheckSalesLeadsExist(id)
    if errCode != ecode.OK {
        return errCode
    }
    //errCode := CheckSalesLeadsExist(id)
    //if errCode != ecode.OK {
    //    return errCode
    //}
    // update salesLeads
    err := model.NewSalesLeadsSearch().SetId(id).UpdateMap(map[string]interface{}{
    err := model.NewSalesLeadsSearch().SetIds(ids).UpdateMap(map[string]interface{}{
        "member_id": memberId,
    })
    if err != nil {