add
add the push function to slaeChance
| | |
| | | // @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
|
| | |
| | | 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, ¶ms) |
| | | if !ok { |
| | | ctx.Fail(ecode.InvalidParams) |
| | | return |
| | | } |
| | | |
| | | errCode := saleChanceService.PushSaleChance(params.Id, params.Step) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/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": [ |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.PushSaleChance": { |
| | | "type": "object", |
| | | "required": [ |
| | | "id", |
| | | "step" |
| | | ], |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "step": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "request.PushSalesLeads": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/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": [ |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.PushSaleChance": { |
| | | "type": "object", |
| | | "required": [ |
| | | "id", |
| | | "step" |
| | | ], |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "step": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "request.PushSalesLeads": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | subOrderId: |
| | | type: integer |
| | | type: object |
| | | request.PushSaleChance: |
| | | properties: |
| | | id: |
| | | type: integer |
| | | step: |
| | | type: integer |
| | | required: |
| | | - id |
| | | - step |
| | | type: object |
| | | request.PushSalesLeads: |
| | | properties: |
| | | id: |
| | |
| | | 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: |
| | |
| | | PageInfo |
| | | Keyword string `json:"keyword"` |
| | | } |
| | | |
| | | type PushSaleChance struct { |
| | | Id int `json:"id" binding:"required"` |
| | | Step int `json:"step" binding:"required"` |
| | | } |
| | |
| | | saleChanceRouter.DELETE("delete/:id", saleChanceApi.Delete) // 删除销售机会 |
| | | saleChanceRouter.PUT("update", saleChanceApi.Update) // 更新销售机会 |
| | | saleChanceRouter.POST("list", saleChanceApi.List) // 获取销售机会列表 |
| | | saleChanceRouter.PUT("push", saleChanceApi.Push) // 推进销售机会 |
| | | } |
| | | } |
| | |
| | | } |
| | | 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 |
| | | } |