add
solveRate 解决率模块
add, Delete, update, list
| | |
| | | ) |
| | | |
| | | type Group struct { |
| | | SolveRateApi |
| | | TimelyRateApi |
| | | BaseApi |
| | | JwtApi |
| | |
| | | vettingService = service.ServiceGroup.VettingService |
| | | satisfactionService = service.ServiceGroup.SatisfactionService |
| | | timelyRateService = service.ServiceGroup.TimelyRateService |
| | | solveRateService = service.ServiceGroup.SolveRateService |
| | | ) |
| | |
| | | PlanId: serviceFollowup.PlanId, |
| | | SatisfactionId: serviceFollowup.Satisfaction, |
| | | TimelyRateId: serviceFollowup.TimelyRate, |
| | | SolveRate: serviceFollowup.SolveRate, |
| | | SolveRateId: serviceFollowup.SolveRate, |
| | | IsVisit: serviceFollowup.IsVisit, |
| | | OldMemberId: serviceFollowup.OldMemberId, |
| | | Remark: serviceFollowup.Remark, |
New file |
| | |
| | | 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 SolveRateApi struct{} |
| | | |
| | | // Add |
| | | // |
| | | // @Tags SolveRate |
| | | // @Summary 添加解决率 |
| | | // @Produce application/json |
| | | // @Param object body request.AddSolveRate true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/solveRate/add [post] |
| | | func (s *SolveRateApi) Add(c *gin.Context) { |
| | | var params request.AddSolveRate |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | solveRate := new(model.SolveRate) |
| | | solveRate.Name = params.Name |
| | | |
| | | errCode := solveRateService.AddSolveRate(solveRate) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // Delete |
| | | // |
| | | // @Tags SolveRate |
| | | // @Summary 删除解决率 |
| | | // @Produce application/json |
| | | // @Param id path int true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/solveRate/delete/{id} [delete] |
| | | func (s *SolveRateApi) Delete(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | id, _ := strconv.Atoi(c.Param("id")) |
| | | errCode := solveRateService.DeleteSolveRate(id) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // Update |
| | | // |
| | | // @Tags SolveRate |
| | | // @Summary 更新解决率 |
| | | // @Produce application/json |
| | | // @Param object body request.UpdateSolveRates true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/solveRate/update [put] |
| | | func (s *SolveRateApi) Update(c *gin.Context) { |
| | | var params request.UpdateSolveRates |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | errCode := solveRateService.UpdateSolveRate(params.SolveRates) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // List |
| | | // |
| | | // @Tags SolveRate |
| | | // @Summary 获取解决率列表 |
| | | // @Produce application/json |
| | | // @Success 200 {object} contextx.Response{data=response.SolveRateResponse} |
| | | // @Router /api/solveRate/list [get] |
| | | func (s *SolveRateApi) List(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | solveRates, errCode := solveRateService.GetSolveRateList() |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.OkWithDetailed(response.SolveRateResponse{ |
| | | List: solveRates, |
| | | }) |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/solveRate/add": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SolveRate" |
| | | ], |
| | | "summary": "添加解决率", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddSolveRate" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/solveRate/delete/{id}": { |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SolveRate" |
| | | ], |
| | | "summary": "删除解决率", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "查询参数", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/solveRate/list": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SolveRate" |
| | | ], |
| | | "summary": "获取解决率列表", |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/response.SolveRateResponse" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/solveRate/update": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SolveRate" |
| | | ], |
| | | "summary": "更新解决率", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateSolveRates" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/status/add": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | "serviceId": { |
| | | "type": "integer" |
| | | }, |
| | | "solveRate": { |
| | | "solveRateId": { |
| | | "type": "integer" |
| | | }, |
| | | "timelyRateId": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "model.SolveRate": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | |
| | | }, |
| | | "timelyRate": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "request.AddSolveRate": { |
| | | "type": "object", |
| | | "required": [ |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateSolveRate": { |
| | | "type": "object", |
| | | "required": [ |
| | | "id", |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateSolveRates": { |
| | | "type": "object", |
| | | "required": [ |
| | | "solve_rate" |
| | | ], |
| | | "properties": { |
| | | "solve_rate": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/request.UpdateSolveRate" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateStatus": { |
| | | "type": "object", |
| | | "required": [ |
| | |
| | | "items": { |
| | | "$ref": "#/definitions/model.Satisfaction" |
| | | } |
| | | }, |
| | | "solve_rate": { |
| | | "description": "解决率", |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.SolveRate" |
| | | } |
| | | }, |
| | | "timely_rate": { |
| | | "description": "及时率", |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.TimelyRate" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.SolveRateResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.SolveRate" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "response.SubOrderResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/solveRate/add": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SolveRate" |
| | | ], |
| | | "summary": "添加解决率", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddSolveRate" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/solveRate/delete/{id}": { |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SolveRate" |
| | | ], |
| | | "summary": "删除解决率", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "查询参数", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/solveRate/list": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SolveRate" |
| | | ], |
| | | "summary": "获取解决率列表", |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/response.SolveRateResponse" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/solveRate/update": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "SolveRate" |
| | | ], |
| | | "summary": "更新解决率", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateSolveRates" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/status/add": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | "serviceId": { |
| | | "type": "integer" |
| | | }, |
| | | "solveRate": { |
| | | "solveRateId": { |
| | | "type": "integer" |
| | | }, |
| | | "timelyRateId": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "model.SolveRate": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | |
| | | }, |
| | | "timelyRate": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "request.AddSolveRate": { |
| | | "type": "object", |
| | | "required": [ |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateSolveRate": { |
| | | "type": "object", |
| | | "required": [ |
| | | "id", |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateSolveRates": { |
| | | "type": "object", |
| | | "required": [ |
| | | "solve_rate" |
| | | ], |
| | | "properties": { |
| | | "solve_rate": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/request.UpdateSolveRate" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateStatus": { |
| | | "type": "object", |
| | | "required": [ |
| | |
| | | "items": { |
| | | "$ref": "#/definitions/model.Satisfaction" |
| | | } |
| | | }, |
| | | "solve_rate": { |
| | | "description": "解决率", |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.SolveRate" |
| | | } |
| | | }, |
| | | "timely_rate": { |
| | | "description": "及时率", |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.TimelyRate" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.SolveRateResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.SolveRate" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "response.SubOrderResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | type: integer |
| | | serviceId: |
| | | type: integer |
| | | solveRate: |
| | | solveRateId: |
| | | type: integer |
| | | timelyRateId: |
| | | type: integer |
| | | type: object |
| | | model.SolveRate: |
| | | properties: |
| | | id: |
| | | type: integer |
| | | name: |
| | | type: string |
| | | type: object |
| | | model.SubOrder: |
| | | properties: |
| | |
| | | type: integer |
| | | timelyRate: |
| | | type: integer |
| | | type: object |
| | | request.AddSolveRate: |
| | | properties: |
| | | name: |
| | | type: string |
| | | required: |
| | | - name |
| | | type: object |
| | | request.AddStatus: |
| | | properties: |
| | |
| | | timelyRate: |
| | | type: integer |
| | | type: object |
| | | request.UpdateSolveRate: |
| | | properties: |
| | | id: |
| | | type: integer |
| | | name: |
| | | type: string |
| | | required: |
| | | - id |
| | | - name |
| | | type: object |
| | | request.UpdateSolveRates: |
| | | properties: |
| | | solve_rate: |
| | | items: |
| | | $ref: '#/definitions/request.UpdateSolveRate' |
| | | type: array |
| | | required: |
| | | - solve_rate |
| | | type: object |
| | | request.UpdateStatus: |
| | | properties: |
| | | id: |
| | |
| | | items: |
| | | $ref: '#/definitions/model.Satisfaction' |
| | | type: array |
| | | solve_rate: |
| | | description: 解决率 |
| | | items: |
| | | $ref: '#/definitions/model.SolveRate' |
| | | type: array |
| | | timely_rate: |
| | | description: 及时率 |
| | | items: |
| | | $ref: '#/definitions/model.TimelyRate' |
| | | type: array |
| | | type: object |
| | | response.DepartmentResponse: |
| | | properties: |
| | |
| | | list: |
| | | items: |
| | | $ref: '#/definitions/model.ServiceFollowup' |
| | | type: array |
| | | type: object |
| | | response.SolveRateResponse: |
| | | properties: |
| | | list: |
| | | items: |
| | | $ref: '#/definitions/model.SolveRate' |
| | | type: array |
| | | type: object |
| | | response.SubOrderResponse: |
| | |
| | | summary: 更新服务跟进 |
| | | tags: |
| | | - ServiceFollowup |
| | | /api/solveRate/add: |
| | | post: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.AddSolveRate' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 添加解决率 |
| | | tags: |
| | | - SolveRate |
| | | /api/solveRate/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: |
| | | - SolveRate |
| | | /api/solveRate/list: |
| | | get: |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | allOf: |
| | | - $ref: '#/definitions/contextx.Response' |
| | | - properties: |
| | | data: |
| | | $ref: '#/definitions/response.SolveRateResponse' |
| | | type: object |
| | | summary: 获取解决率列表 |
| | | tags: |
| | | - SolveRate |
| | | /api/solveRate/update: |
| | | put: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.UpdateSolveRates' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 更新解决率 |
| | | tags: |
| | | - SolveRate |
| | | /api/status/add: |
| | | post: |
| | | parameters: |
| | |
| | | Department{}, |
| | | Satisfaction{}, |
| | | TimelyRate{}, |
| | | SolveRate{}, |
| | | ) |
| | | return err |
| | | } |
New file |
| | |
| | | |
| | | package request |
| | | |
| | | type AddSolveRate struct { |
| | | Name string ` json:"name" binding:"required"` |
| | | } |
| | | |
| | | type UpdateSolveRate struct { |
| | | Id int `json:"id" binding:"required"` |
| | | Name string `json:"name" binding:"required"` |
| | | } |
| | | |
| | | type UpdateSolveRates struct { |
| | | SolveRates []*UpdateSolveRate `json:"solve_rate" binding:"required"` |
| | | } |
| | |
| | | Satisfaction []*model.Satisfaction `json:"satisfaction"` |
| | | // 及时率 |
| | | TimelyRate []*model.TimelyRate `json:"timely_rate"` |
| | | // 解决率 |
| | | SolveRate []*model.SolveRate `json:"solve_rate"` |
| | | } |
| | | |
| | | DepartmentResponse struct { |
| | |
| | | TimelyRateResponse struct { |
| | | List []*model.TimelyRate `json:"list"` |
| | | } |
| | | |
| | | SolveRateResponse struct { |
| | | List []*model.SolveRate `json:"list"` |
| | | } |
| | | ) |
| | |
| | | PlanId int `json:"planId" gorm:"column:plan_id;type:int;comment:服务计划id"` |
| | | 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"` |
| | | SolveRate int `json:"solveRate" gorm:"column:solve_rate;type:int;comment:解决率"` |
| | | SolveRateId int `json:"solveRateId" gorm:"column:solve_rate_id;type:int;comment:解决率id"` |
| | | IsVisit int `json:"isVisit" gorm:"column:is_visit;type:int;comment:服务人员是否来过"` |
| | | OldMemberId int `json:"oldMemberId" gorm:"column:old_member_id;type:int;comment:原服务人员"` |
| | | Remark string `json:"remark" gorm:"column:remark;type:text;comment:备注"` |
New file |
| | |
| | | package model |
| | | |
| | | import ( |
| | | "aps_crm/pkg/mysqlx" |
| | | "gorm.io/gorm" |
| | | ) |
| | | |
| | | type ( |
| | | // SolveRate 商机阶段 |
| | | SolveRate struct { |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | Name string `json:"name" gorm:"column:name;type:varchar(255);comment:商机阶段名称"` |
| | | } |
| | | |
| | | SolveRateSearch struct { |
| | | SolveRate |
| | | Orm *gorm.DB |
| | | } |
| | | ) |
| | | |
| | | func (SolveRate) TableName() string { |
| | | return "solve_rate" |
| | | } |
| | | |
| | | func NewSolveRateSearch() *SolveRateSearch { |
| | | return &SolveRateSearch{ |
| | | Orm: mysqlx.GetDB(), |
| | | } |
| | | } |
| | | |
| | | func (slf *SolveRateSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&SolveRate{}) |
| | | if slf.Id != 0 { |
| | | db = db.Where("id = ?", slf.Id) |
| | | } |
| | | if slf.Name != "" { |
| | | db = db.Where("name = ?", slf.Name) |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |
| | | func (slf *SolveRateSearch) Create(record *SolveRate) error { |
| | | var db = slf.build() |
| | | return db.Create(record).Error |
| | | } |
| | | |
| | | func (slf *SolveRateSearch) Delete() error { |
| | | var db = slf.build() |
| | | return db.Delete(&SolveRate{}).Error |
| | | } |
| | | |
| | | func (slf *SolveRateSearch) Update(record *SolveRate) error { |
| | | var db = slf.build() |
| | | return db.Updates(record).Error |
| | | } |
| | | |
| | | func (slf *SolveRateSearch) Find() (*SolveRate, error) { |
| | | var db = slf.build() |
| | | var record = new(SolveRate) |
| | | err := db.First(record).Error |
| | | return record, err |
| | | } |
| | | |
| | | func (slf *SolveRateSearch) FindAll() ([]*SolveRate, error) { |
| | | var db = slf.build() |
| | | var records = make([]*SolveRate, 0) |
| | | err := db.Find(&records).Error |
| | | return records, err |
| | | } |
| | | |
| | | func (slf *SolveRateSearch) SetId(id int) *SolveRateSearch { |
| | | slf.Id = id |
| | | return slf |
| | | } |
| | | |
| | | func (slf *SolveRateSearch) SetName(name string) *SolveRateSearch { |
| | | slf.Name = name |
| | | return slf |
| | | } |
| | | |
| | | func (slf *SolveRateSearch) Updates(data map[string]interface{}) error { |
| | | var db = slf.build() |
| | | return db.Updates(data).Error |
| | | } |
| | |
| | | TimelyRateSetErr = 4300004 // 设置及时率失败 |
| | | TimelyRateUpdateErr = 4300005 // 更新及时率失败 |
| | | |
| | | SolveRateExist = 4400001 // 解决率已存在 |
| | | SolveRateNotExist = 4400002 // 解决率不存在 |
| | | SolveRateListErr = 4400003 // 获取解决率列表失败 |
| | | SolveRateSetErr = 4400004 // 设置解决率失败 |
| | | SolveRateUpdateErr = 4400005 // 更新解决率失败 |
| | | ) |
| | |
| | | ) |
| | | |
| | | type Group struct { |
| | | SolveRateRouter |
| | | TimelyRateRouter |
| | | BaseRouter |
| | | UserRouter |
| | |
| | | routerGroup.InitDepartmentRouter(PrivateGroup) // 注册department路由 |
| | | routerGroup.InitSatisfactionRouter(PrivateGroup) // 注册satisfaction路由 |
| | | routerGroup.InitTimelyRateRouter(PrivateGroup) |
| | | routerGroup.InitSolveRateRouter(PrivateGroup) |
| | | } |
| | | return Router |
| | | } |
New file |
| | |
| | | |
| | | package router |
| | | |
| | | import ( |
| | | v1 "aps_crm/api/v1" |
| | | "github.com/gin-gonic/gin" |
| | | ) |
| | | |
| | | type SolveRateRouter struct{} |
| | | |
| | | func (s *SolveRateRouter) InitSolveRateRouter(router *gin.RouterGroup) { |
| | | solveRateRouter := router.Group("solveRate") |
| | | solveRateApi := v1.ApiGroup.SolveRateApi |
| | | { |
| | | solveRateRouter.POST("add", solveRateApi.Add) // 添加销售阶段 |
| | | solveRateRouter.DELETE("delete/:id", solveRateApi.Delete) // 删除销售阶段 |
| | | solveRateRouter.PUT("update", solveRateApi.Update) // 更新销售阶段 |
| | | solveRateRouter.GET("list", solveRateApi.List) // 获取销售阶段列表 |
| | | } |
| | | } |
| | |
| | | timelyRateList, _ := ServiceGroup.GetTimelyRateList() |
| | | data.TimelyRate = timelyRateList |
| | | |
| | | // get SolveRate list |
| | | solveRateList, _ := ServiceGroup.GetSolveRateList() |
| | | data.SolveRate = solveRateList |
| | | |
| | | |
| | | errCode = ecode.OK |
| | | |
| | | return |
| | | } |
| | | } |
| | |
| | | VettingService |
| | | SatisfactionService |
| | | TimelyRateService |
| | | SolveRateService |
| | | } |
| | | |
| | | var ServiceGroup = new(Group) |
New file |
| | |
| | | |
| | | package service |
| | | |
| | | import ( |
| | | "aps_crm/model" |
| | | "aps_crm/model/request" |
| | | "aps_crm/pkg/ecode" |
| | | ) |
| | | |
| | | type SolveRateService struct{} |
| | | |
| | | func (SolveRateService) AddSolveRate(solveRate *model.SolveRate) int { |
| | | err := model.NewSolveRateSearch().Create(solveRate) |
| | | if err != nil { |
| | | return ecode.SolveRateExist |
| | | } |
| | | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (SolveRateService) DeleteSolveRate(id int) int { |
| | | _, err := model.NewSolveRateSearch().SetId(id).Find() |
| | | if err != nil { |
| | | return ecode.SolveRateNotExist |
| | | } |
| | | |
| | | err = model.NewSolveRateSearch().SetId(id).Delete() |
| | | if err != nil { |
| | | return ecode.SolveRateNotExist |
| | | } |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (SolveRateService) GetSolveRateList() ([]*model.SolveRate, int) { |
| | | list, err := model.NewSolveRateSearch().FindAll() |
| | | if err != nil { |
| | | return nil, ecode.SolveRateListErr |
| | | } |
| | | |
| | | return list, ecode.OK |
| | | } |
| | | |
| | | func (SolveRateService) UpdateSolveRate(solveRates []*request.UpdateSolveRate) int { |
| | | for _, v := range solveRates { |
| | | // check solveRate exist |
| | | _, err := model.NewSolveRateSearch().SetId(v.Id).Find() |
| | | if err != nil { |
| | | return ecode.SolveRateNotExist |
| | | } |
| | | |
| | | err = model.NewSolveRateSearch().SetId(v.Id).Updates(map[string]interface{}{ |
| | | "name": v.Name, |
| | | }) |
| | | if err != nil { |
| | | return ecode.SolveRateSetErr |
| | | } |
| | | } |
| | | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (SolveRateService) GetSolveRateDetail(id int) (*model.SolveRate, int) { |
| | | solveRate, err := model.NewSolveRateSearch().SetId(id).Find() |
| | | if err != nil { |
| | | return nil, ecode.SolveRateNotExist |
| | | } |
| | | |
| | | return solveRate, ecode.OK |
| | | } |