add
wangpengfei
2023-08-11 69ac5c4605f340144144a4b0954c7768697e95e6
add

add the push function to slaeChance
7个文件已修改
174 ■■■■■ 已修改文件
api/v1/saleChance.go 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/saleChance.go 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/saleChance.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/saleChance.go 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/saleChance.go
@@ -190,7 +190,9 @@
//    @Summary    销售机会列表
//    @Produce    application/json
//    @Param        object    body        request.GetSaleChanceList    true    "参数"
//
// @Success    200        {object}    contextx.Response{data=response.SaleChanceResponse}
//
//    @Router        /api/saleChance/list [post]
func (con *SaleChanceApi) List(c *gin.Context) {
    var params request.GetSaleChanceList
@@ -210,3 +212,28 @@
        Count: int(total),
    })
}
// Push
//
//    @Tags        SaleChance
//    @Summary    推进销售机会
//    @Produce    application/json
//    @Param        object    body        request.PushSaleChance  true    "查询参数"
//    @Success    200    {object}    contextx.Response{}
//    @Router        /api/saleChance/push [put]
func (s *SaleChanceApi) Push(c *gin.Context) {
    var params request.PushSaleChance
    ctx, ok := contextx.NewContext(c, &params)
    if !ok {
        ctx.Fail(ecode.InvalidParams)
        return
    }
    errCode := saleChanceService.PushSaleChance(params.Id, params.Step)
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
    }
    ctx.Ok()
}
docs/docs.go
@@ -6388,6 +6388,36 @@
                }
            }
        },
        "/api/saleChance/push": {
            "put": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "SaleChance"
                ],
                "summary": "推进销售机会",
                "parameters": [
                    {
                        "description": "查询参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.PushSaleChance"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/contextx.Response"
                        }
                    }
                }
            }
        },
        "/api/saleChance/update": {
            "put": {
                "produces": [
@@ -14863,6 +14893,21 @@
                }
            }
        },
        "request.PushSaleChance": {
            "type": "object",
            "required": [
                "id",
                "step"
            ],
            "properties": {
                "id": {
                    "type": "integer"
                },
                "step": {
                    "type": "integer"
                }
            }
        },
        "request.PushSalesLeads": {
            "type": "object",
            "properties": {
docs/swagger.json
@@ -6376,6 +6376,36 @@
                }
            }
        },
        "/api/saleChance/push": {
            "put": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "SaleChance"
                ],
                "summary": "推进销售机会",
                "parameters": [
                    {
                        "description": "查询参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.PushSaleChance"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/contextx.Response"
                        }
                    }
                }
            }
        },
        "/api/saleChance/update": {
            "put": {
                "produces": [
@@ -14851,6 +14881,21 @@
                }
            }
        },
        "request.PushSaleChance": {
            "type": "object",
            "required": [
                "id",
                "step"
            ],
            "properties": {
                "id": {
                    "type": "integer"
                },
                "step": {
                    "type": "integer"
                }
            }
        },
        "request.PushSalesLeads": {
            "type": "object",
            "properties": {
docs/swagger.yaml
@@ -3365,6 +3365,16 @@
      subOrderId:
        type: integer
    type: object
  request.PushSaleChance:
    properties:
      id:
        type: integer
      step:
        type: integer
    required:
    - id
    - step
    type: object
  request.PushSalesLeads:
    properties:
      id:
@@ -9528,6 +9538,25 @@
      summary: 销售机会列表
      tags:
      - SaleChance
  /api/saleChance/push:
    put:
      parameters:
      - description: 查询参数
        in: body
        name: object
        required: true
        schema:
          $ref: '#/definitions/request.PushSaleChance'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/contextx.Response'
      summary: 推进销售机会
      tags:
      - SaleChance
  /api/saleChance/update:
    put:
      parameters:
model/request/saleChance.go
@@ -46,3 +46,8 @@
    PageInfo
    Keyword string `json:"keyword"`
}
type PushSaleChance struct {
    Id   int `json:"id" binding:"required"`
    Step int `json:"step" binding:"required"`
}
router/saleChance.go
@@ -15,5 +15,6 @@
        saleChanceRouter.DELETE("delete/:id", saleChanceApi.Delete) // 删除销售机会
        saleChanceRouter.PUT("update", saleChanceApi.Update)        // 更新销售机会
        saleChanceRouter.POST("list", saleChanceApi.List)            // 获取销售机会列表
        saleChanceRouter.PUT("push", saleChanceApi.Push)            // 推进销售机会
    }
}
service/saleChance.go
@@ -62,3 +62,25 @@
    }
    return contacts, total, ecode.OK
}
// push
func (SaleChanceService) PushSaleChance(id, step int) int {
    // check saleChange exist
    errCode := CheckSaleChangeExist(id)
    if errCode != ecode.OK {
        return errCode
    }
    // check step
    _, err := model.NewSaleStageSearch().SetId(step).Find()
    if err != nil {
        return ecode.SaleStageNotExist
    }
    // push saleChange
    err = model.NewSaleChanceSearch().SetId(id).Update(&model.SaleChance{SaleStageId: step})
    if err != nil {
        return ecode.SaleChanceUpdateErr
    }
    return ecode.OK
}