New file |
| | |
| | | package v1 |
| | | |
| | | import ( |
| | | "aps_crm/model/request" |
| | | "aps_crm/pkg/contextx" |
| | | "aps_crm/pkg/ecode" |
| | | "github.com/gin-gonic/gin" |
| | | ) |
| | | |
| | | type AssignApi struct{} |
| | | |
| | | // Assign |
| | | // |
| | | // @Tags Assign |
| | | // @Summary 审核 |
| | | // @Produce application/json |
| | | // @Param object body request.Assign true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/assign/assign [post] |
| | | func (au *AssignApi) Assign(c *gin.Context) { |
| | | var params request.Assign |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | if params.MemberId == 0 { |
| | | ctx.Fail(ecode.AssignWrongMemberId) |
| | | return |
| | | } |
| | | |
| | | if params.Id == 0 { |
| | | ctx.Fail(ecode.AssignWrongId) |
| | | return |
| | | } |
| | | |
| | | if params.Type == "" { |
| | | ctx.Fail(ecode.AssignWrongModelType) |
| | | return |
| | | } |
| | | |
| | | errCode := assignService.Assign(params.MemberId, params.Id, params.Type) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | |
| | | DepartmentApi |
| | | VettingApi |
| | | SatisfactionApi |
| | | AssignApi |
| | | } |
| | | |
| | | var ApiGroup = new(Group) |
| | |
| | | repositoryService = service.ServiceGroup.RepositoryService |
| | | quotationStatusService = service.ServiceGroup.QuotationStatusService |
| | | currencyService = service.ServiceGroup.CurrencyService |
| | | assignService = service.ServiceGroup.AssignService |
| | | ) |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/assign/assign": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "Assign" |
| | | ], |
| | | "summary": "审核", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.Assign" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/authority/add": { |
| | | "post": { |
| | | "security": [ |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.Assign": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "member_id": { |
| | | "type": "integer" |
| | | }, |
| | | "type": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.CasbinInfo": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/assign/assign": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "Assign" |
| | | ], |
| | | "summary": "审核", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.Assign" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/authority/add": { |
| | | "post": { |
| | | "security": [ |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.Assign": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "member_id": { |
| | | "type": "integer" |
| | | }, |
| | | "type": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.CasbinInfo": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | - vettingId |
| | | - vettingType |
| | | type: object |
| | | request.Assign: |
| | | properties: |
| | | id: |
| | | type: integer |
| | | member_id: |
| | | type: integer |
| | | type: |
| | | type: string |
| | | type: object |
| | | request.CasbinInfo: |
| | | properties: |
| | | method: |
| | |
| | | summary: 更新账户 |
| | | tags: |
| | | - AccountId |
| | | /api/assign/assign: |
| | | post: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.Assign' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 审核 |
| | | tags: |
| | | - Assign |
| | | /api/authority/add: |
| | | post: |
| | | consumes: |
New file |
| | |
| | | package request |
| | | |
| | | type Assign struct { |
| | | MemberId int `json:"member_id"` |
| | | Type string `json:"type"` |
| | | Id int `json:"id"` |
| | | } |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *UserSearch) SetUserId(userId int) *UserSearch { |
| | | slf.ID = userId |
| | | return slf |
| | | } |
| | | |
| | | func (slf *UserSearch) SetUserName(username string) *UserSearch { |
| | | slf.Username = username |
| | | return slf |
| | |
| | | CurrencySetErr = 5600004 // 设置币种失败 |
| | | CurrencyUpdateErr = 5600005 // 更新币种失败 |
| | | |
| | | AssignErr = 5700001 // 分配失败 |
| | | AssignWrongMemberId = 5700002 // 分配失败,分配人为空 |
| | | AssignWrongId = 5700003 // 分配失败,分配对象为空 |
| | | AssignWrongModelType = 5700004 // 分配失败,分配对象类型为空 |
| | | |
| | | ) |
New file |
| | |
| | | package router |
| | | |
| | | import ( |
| | | v1 "aps_crm/api/v1" |
| | | "github.com/gin-gonic/gin" |
| | | ) |
| | | |
| | | type AssignRouter struct{} |
| | | |
| | | func (a *AssignRouter) InitAssignRouter(router *gin.RouterGroup) { |
| | | assignRouter := router.Group("assign") |
| | | assignApi := v1.ApiGroup.AssignApi |
| | | { |
| | | assignRouter.POST("assign", assignApi.Assign) // 分配 |
| | | } |
| | | } |
| | |
| | | DataRouter |
| | | DepartmentRouter |
| | | SatisfactionRouter |
| | | AssignRouter |
| | | } |
| | | |
| | | func InitRouter() *gin.Engine { |
| | |
| | | routerGroup.InitRepositoryRouter(PrivateGroup) |
| | | routerGroup.InitQuotationStatusRouter(PrivateGroup) |
| | | routerGroup.InitCurrencyRouter(PrivateGroup) |
| | | routerGroup.InitAssignRouter(PrivateGroup) |
| | | } |
| | | return Router |
| | | } |
New file |
| | |
| | | package service |
| | | |
| | | import "aps_crm/pkg/ecode" |
| | | |
| | | type AssignService struct{} |
| | | |
| | | type Assign interface { |
| | | Assign(id int) error |
| | | } |
| | | |
| | | func (AssignService) Assign(memberId, id int, modelType string) int { |
| | | var errCode int |
| | | switch modelType { |
| | | case "client": |
| | | errCode = ClientService{}.Assign(id, memberId) |
| | | default: |
| | | errCode = ecode.AssignWrongModelType |
| | | } |
| | | |
| | | if errCode != ecode.OK { |
| | | return errCode |
| | | } |
| | | |
| | | return ecode.OK |
| | | } |
| | |
| | | } |
| | | return contacts, total, ecode.OK |
| | | } |
| | | |
| | | func (ClientService) Assign(id, memberId int) int { |
| | | // check member exist |
| | | _, err := model.NewUserSearch(nil).SetUserId(memberId).First() |
| | | if err != nil { |
| | | return ecode.UserNotExist |
| | | } |
| | | // check client exist |
| | | errCode := CheckClientExist(id) |
| | | if errCode != ecode.OK { |
| | | return errCode |
| | | } |
| | | |
| | | // assign client |
| | | err = model.NewClientSearch(nil).SetId(id).UpdateByMap(map[string]interface{}{ |
| | | "member_id": memberId, |
| | | }) |
| | | if err != nil { |
| | | return ecode.AssignErr |
| | | } |
| | | |
| | | return ecode.OK |
| | | } |
| | |
| | | RepositoryService |
| | | QuotationStatusService |
| | | CurrencyService |
| | | AssignService |
| | | } |
| | | |
| | | var ServiceGroup = new(Group) |