add
ServiceContractStatus 服务合同状态
add, Delete, update, list
| | |
| | | ) |
| | | |
| | | type Group struct { |
| | | ServiceContractStatusApi |
| | | OrderTypeApi |
| | | ReportSourceApi |
| | | IsVisitApi |
| | |
| | | isVisitService = service.ServiceGroup.IsVisitService |
| | | reportSourceService = service.ServiceGroup.ReportSourceService |
| | | orderTypeService = service.ServiceGroup.OrderTypeService |
| | | serviceContractStatusService = service.ServiceGroup.ServiceContractStatusService |
| | | ) |
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 ServiceContractStatusApi struct{} |
| | | |
| | | // Add |
| | | // |
| | | // @Tags ServiceContractStatus |
| | | // @Summary 添加服务合同状态 |
| | | // @Produce application/json |
| | | // @Param object body request.AddServiceContractStatus true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/serviceContractStatus/add [post] |
| | | func (s *ServiceContractStatusApi) Add(c *gin.Context) { |
| | | var params request.AddServiceContractStatus |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | serviceContractStatus := new(model.ServiceContractStatus) |
| | | serviceContractStatus.Name = params.Name |
| | | |
| | | errCode := serviceContractStatusService.AddServiceContractStatus(serviceContractStatus) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // Delete |
| | | // |
| | | // @Tags ServiceContractStatus |
| | | // @Summary 删除服务合同状态 |
| | | // @Produce application/json |
| | | // @Param id path int true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/serviceContractStatus/delete/{id} [delete] |
| | | func (s *ServiceContractStatusApi) Delete(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | id, _ := strconv.Atoi(c.Param("id")) |
| | | errCode := serviceContractStatusService.DeleteServiceContractStatus(id) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // Update |
| | | // |
| | | // @Tags ServiceContractStatus |
| | | // @Summary 更新服务合同状态 |
| | | // @Produce application/json |
| | | // @Param object body request.UpdateServiceContractStatuss true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/serviceContractStatus/update [put] |
| | | func (s *ServiceContractStatusApi) Update(c *gin.Context) { |
| | | var params request.UpdateServiceContractStatuss |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | errCode := serviceContractStatusService.UpdateServiceContractStatus(params.ServiceContractStatuss) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // List |
| | | // |
| | | // @Tags ServiceContractStatus |
| | | // @Summary 获取服务合同状态列表 |
| | | // @Produce application/json |
| | | // @Success 200 {object} contextx.Response{data=response.ServiceContractStatusResponse} |
| | | // @Router /api/serviceContractStatus/list [get] |
| | | func (s *ServiceContractStatusApi) List(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | serviceContractStatuss, errCode := serviceContractStatusService.GetServiceContractStatusList() |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.OkWithDetailed(response.ServiceContractStatusResponse{ |
| | | List: serviceContractStatuss, |
| | | }) |
| | | } |
| | |
| | | result.SaleChanceId = serviceContract.SaleChanceId |
| | | result.QuotationId = serviceContract.QuotationId |
| | | result.TypeId = serviceContract.TypeId |
| | | result.StatusId = serviceContract.StatusId |
| | | result.ServiceContractStatusId = serviceContract.StatusId |
| | | result.ServiceTimes = serviceContract.ServiceTimes |
| | | result.Terms = serviceContract.Terms |
| | | result.Products = serviceContract.Products |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/serviceContractStatus/add": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "ServiceContractStatus" |
| | | ], |
| | | "summary": "添加服务合同状态", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddServiceContractStatus" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/serviceContractStatus/delete/{id}": { |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "ServiceContractStatus" |
| | | ], |
| | | "summary": "删除服务合同状态", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "查询参数", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/serviceContractStatus/list": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "ServiceContractStatus" |
| | | ], |
| | | "summary": "获取服务合同状态列表", |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/response.ServiceContractStatusResponse" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/serviceContractStatus/update": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "ServiceContractStatus" |
| | | ], |
| | | "summary": "更新服务合同状态", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateServiceContractStatuss" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/serviceFeeManage/add": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | "saleChanceId": { |
| | | "type": "integer" |
| | | }, |
| | | "serviceContractStatusId": { |
| | | "type": "integer" |
| | | }, |
| | | "serviceTimes": { |
| | | "type": "integer" |
| | | }, |
| | |
| | | "startTime": { |
| | | "type": "string" |
| | | }, |
| | | "statusId": { |
| | | "type": "integer" |
| | | }, |
| | | "terms": { |
| | | "type": "string" |
| | | }, |
| | | "typeId": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "model.ServiceContractStatus": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | |
| | | }, |
| | | "typeId": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "request.AddServiceContractStatus": { |
| | | "type": "object", |
| | | "required": [ |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateServiceContractStatus": { |
| | | "type": "object", |
| | | "required": [ |
| | | "id", |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateServiceContractStatuss": { |
| | | "type": "object", |
| | | "required": [ |
| | | "service_contract_status" |
| | | ], |
| | | "properties": { |
| | | "service_contract_status": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/request.UpdateServiceContractStatus" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateServiceFeeManage": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "$ref": "#/definitions/model.Satisfaction" |
| | | } |
| | | }, |
| | | "serviceContractStatus": { |
| | | "description": "服务合同状态", |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.ServiceContractStatus" |
| | | } |
| | | }, |
| | | "solve_rate": { |
| | | "description": "解决率", |
| | | "type": "array", |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.ServiceContractStatusResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.ServiceContractStatus" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "response.ServiceContractsResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/serviceContractStatus/add": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "ServiceContractStatus" |
| | | ], |
| | | "summary": "添加服务合同状态", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddServiceContractStatus" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/serviceContractStatus/delete/{id}": { |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "ServiceContractStatus" |
| | | ], |
| | | "summary": "删除服务合同状态", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "查询参数", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/serviceContractStatus/list": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "ServiceContractStatus" |
| | | ], |
| | | "summary": "获取服务合同状态列表", |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/response.ServiceContractStatusResponse" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/serviceContractStatus/update": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "ServiceContractStatus" |
| | | ], |
| | | "summary": "更新服务合同状态", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateServiceContractStatuss" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/serviceFeeManage/add": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | "saleChanceId": { |
| | | "type": "integer" |
| | | }, |
| | | "serviceContractStatusId": { |
| | | "type": "integer" |
| | | }, |
| | | "serviceTimes": { |
| | | "type": "integer" |
| | | }, |
| | |
| | | "startTime": { |
| | | "type": "string" |
| | | }, |
| | | "statusId": { |
| | | "type": "integer" |
| | | }, |
| | | "terms": { |
| | | "type": "string" |
| | | }, |
| | | "typeId": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "model.ServiceContractStatus": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | |
| | | }, |
| | | "typeId": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "request.AddServiceContractStatus": { |
| | | "type": "object", |
| | | "required": [ |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateServiceContractStatus": { |
| | | "type": "object", |
| | | "required": [ |
| | | "id", |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateServiceContractStatuss": { |
| | | "type": "object", |
| | | "required": [ |
| | | "service_contract_status" |
| | | ], |
| | | "properties": { |
| | | "service_contract_status": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/request.UpdateServiceContractStatus" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateServiceFeeManage": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "$ref": "#/definitions/model.Satisfaction" |
| | | } |
| | | }, |
| | | "serviceContractStatus": { |
| | | "description": "服务合同状态", |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.ServiceContractStatus" |
| | | } |
| | | }, |
| | | "solve_rate": { |
| | | "description": "解决率", |
| | | "type": "array", |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.ServiceContractStatusResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.ServiceContractStatus" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "response.ServiceContractsResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | type: string |
| | | saleChanceId: |
| | | type: integer |
| | | serviceContractStatusId: |
| | | type: integer |
| | | serviceTimes: |
| | | type: integer |
| | | signTime: |
| | | type: string |
| | | startTime: |
| | | type: string |
| | | statusId: |
| | | type: integer |
| | | terms: |
| | | type: string |
| | | typeId: |
| | | type: integer |
| | | type: object |
| | | model.ServiceContractStatus: |
| | | properties: |
| | | id: |
| | | type: integer |
| | | name: |
| | | type: string |
| | | type: object |
| | | model.ServiceFeeManage: |
| | | properties: |
| | |
| | | type: string |
| | | typeId: |
| | | type: integer |
| | | type: object |
| | | request.AddServiceContractStatus: |
| | | properties: |
| | | name: |
| | | type: string |
| | | required: |
| | | - name |
| | | type: object |
| | | request.AddServiceFeeManage: |
| | | properties: |
| | |
| | | typeId: |
| | | type: integer |
| | | type: object |
| | | request.UpdateServiceContractStatus: |
| | | properties: |
| | | id: |
| | | type: integer |
| | | name: |
| | | type: string |
| | | required: |
| | | - id |
| | | - name |
| | | type: object |
| | | request.UpdateServiceContractStatuss: |
| | | properties: |
| | | service_contract_status: |
| | | items: |
| | | $ref: '#/definitions/request.UpdateServiceContractStatus' |
| | | type: array |
| | | required: |
| | | - service_contract_status |
| | | type: object |
| | | request.UpdateServiceFeeManage: |
| | | properties: |
| | | business_scope: |
| | |
| | | items: |
| | | $ref: '#/definitions/model.Satisfaction' |
| | | type: array |
| | | serviceContractStatus: |
| | | description: 服务合同状态 |
| | | items: |
| | | $ref: '#/definitions/model.ServiceContractStatus' |
| | | type: array |
| | | solve_rate: |
| | | description: 解决率 |
| | | items: |
| | |
| | | list: |
| | | items: |
| | | $ref: '#/definitions/model.Satisfaction' |
| | | type: array |
| | | type: object |
| | | response.ServiceContractStatusResponse: |
| | | properties: |
| | | list: |
| | | items: |
| | | $ref: '#/definitions/model.ServiceContractStatus' |
| | | type: array |
| | | type: object |
| | | response.ServiceContractsResponse: |
| | |
| | | summary: 更新服务合同 |
| | | tags: |
| | | - ServiceContract |
| | | /api/serviceContractStatus/add: |
| | | post: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.AddServiceContractStatus' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 添加服务合同状态 |
| | | tags: |
| | | - ServiceContractStatus |
| | | /api/serviceContractStatus/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: |
| | | - ServiceContractStatus |
| | | /api/serviceContractStatus/list: |
| | | get: |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | allOf: |
| | | - $ref: '#/definitions/contextx.Response' |
| | | - properties: |
| | | data: |
| | | $ref: '#/definitions/response.ServiceContractStatusResponse' |
| | | type: object |
| | | summary: 获取服务合同状态列表 |
| | | tags: |
| | | - ServiceContractStatus |
| | | /api/serviceContractStatus/update: |
| | | put: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.UpdateServiceContractStatuss' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 更新服务合同状态 |
| | | tags: |
| | | - ServiceContractStatus |
| | | /api/serviceFeeManage/add: |
| | | post: |
| | | parameters: |
| | |
| | | IsVisit{}, |
| | | ReportSource{}, |
| | | OrderType{}, |
| | | ServiceContractStatus{}, |
| | | ) |
| | | return err |
| | | } |
New file |
| | |
| | | |
| | | package request |
| | | |
| | | type AddServiceContractStatus struct { |
| | | Name string ` json:"name" binding:"required"` |
| | | } |
| | | |
| | | type UpdateServiceContractStatus struct { |
| | | Id int `json:"id" binding:"required"` |
| | | Name string `json:"name" binding:"required"` |
| | | } |
| | | |
| | | type UpdateServiceContractStatuss struct { |
| | | ServiceContractStatuss []*UpdateServiceContractStatus `json:"service_contract_status" binding:"required"` |
| | | } |
| | |
| | | |
| | | DataResponse struct { |
| | | |
| | | // 服务合同状态 |
| | | ServiceContractStatus []*model.ServiceContractStatus `json:"serviceContractStatus"` |
| | | |
| | | |
| | | // 工单类型 |
| | | OrderType []*model.OrderType `json:"orderType"` |
| | | |
| | |
| | | OrderTypeResponse struct { |
| | | List []*model.OrderType `json:"list"` |
| | | } |
| | | |
| | | ServiceContractStatusResponse struct { |
| | | List []*model.ServiceContractStatus `json:"list"` |
| | | } |
| | | ) |
New file |
| | |
| | | package model |
| | | |
| | | import ( |
| | | "aps_crm/pkg/mysqlx" |
| | | "gorm.io/gorm" |
| | | ) |
| | | |
| | | type ( |
| | | // ServiceContractStatus 商机阶段 |
| | | ServiceContractStatus struct { |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | Name string `json:"name" gorm:"column:name;type:varchar(255);comment:商机阶段名称"` |
| | | } |
| | | |
| | | ServiceContractStatusSearch struct { |
| | | ServiceContractStatus |
| | | Orm *gorm.DB |
| | | } |
| | | ) |
| | | |
| | | func (ServiceContractStatus) TableName() string { |
| | | return "service_contract_status" |
| | | } |
| | | |
| | | func NewServiceContractStatusSearch() *ServiceContractStatusSearch { |
| | | return &ServiceContractStatusSearch{ |
| | | Orm: mysqlx.GetDB(), |
| | | } |
| | | } |
| | | |
| | | func (slf *ServiceContractStatusSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&ServiceContractStatus{}) |
| | | if slf.Id != 0 { |
| | | db = db.Where("id = ?", slf.Id) |
| | | } |
| | | if slf.Name != "" { |
| | | db = db.Where("name = ?", slf.Name) |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |
| | | func (slf *ServiceContractStatusSearch) Create(record *ServiceContractStatus) error { |
| | | var db = slf.build() |
| | | return db.Create(record).Error |
| | | } |
| | | |
| | | func (slf *ServiceContractStatusSearch) Delete() error { |
| | | var db = slf.build() |
| | | return db.Delete(&ServiceContractStatus{}).Error |
| | | } |
| | | |
| | | func (slf *ServiceContractStatusSearch) Update(record *ServiceContractStatus) error { |
| | | var db = slf.build() |
| | | return db.Updates(record).Error |
| | | } |
| | | |
| | | func (slf *ServiceContractStatusSearch) Find() (*ServiceContractStatus, error) { |
| | | var db = slf.build() |
| | | var record = new(ServiceContractStatus) |
| | | err := db.First(record).Error |
| | | return record, err |
| | | } |
| | | |
| | | func (slf *ServiceContractStatusSearch) FindAll() ([]*ServiceContractStatus, error) { |
| | | var db = slf.build() |
| | | var records = make([]*ServiceContractStatus, 0) |
| | | err := db.Find(&records).Error |
| | | return records, err |
| | | } |
| | | |
| | | func (slf *ServiceContractStatusSearch) SetId(id int) *ServiceContractStatusSearch { |
| | | slf.Id = id |
| | | return slf |
| | | } |
| | | |
| | | func (slf *ServiceContractStatusSearch) SetName(name string) *ServiceContractStatusSearch { |
| | | slf.Name = name |
| | | return slf |
| | | } |
| | | |
| | | func (slf *ServiceContractStatusSearch) Updates(data map[string]interface{}) error { |
| | | var db = slf.build() |
| | | return db.Updates(data).Error |
| | | } |
| | |
| | | |
| | | type ( |
| | | ServiceContract struct { |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | ClientId int `json:"clientId" gorm:"column:client_id;type:int;comment:客户id"` |
| | | Number string `json:"number" gorm:"column:number;type:varchar(255);comment:合同编号"` |
| | | MemberId int `json:"memberId" gorm:"column:member_id;type:int;comment:负责人id"` |
| | | ContactId int `json:"contactId" gorm:"column:contact_id;type:int;comment:联系人id"` |
| | | SaleChanceId int `json:"saleChanceId" gorm:"column:sale_chance_id;type:int;comment:销售机会id"` |
| | | ContractId int `json:"contractId" gorm:"column:contract_id;type:int;comment:合同id"` |
| | | QuotationId int `json:"quotationId" gorm:"column:quotation_id;type:int;comment:报价单id"` |
| | | TypeId int `json:"typeId" gorm:"column:type_id;type:int;comment:合同类型id"` |
| | | SignTime time.Time `json:"signTime" gorm:"column:sign_time;type:datetime;comment:签约时间"` |
| | | StartTime time.Time `json:"startTime" gorm:"column:start_time;type:datetime;comment:开始时间"` |
| | | EndTime time.Time `json:"endTime" gorm:"column:end_time;type:datetime;comment:结束时间"` |
| | | StatusId int `json:"statusId" gorm:"column:status_id;type:int;comment:合同状态id"` |
| | | ServiceTimes int `json:"serviceTimes" gorm:"column:service_times;type:int;comment:服务次数"` |
| | | Terms string `json:"terms" gorm:"column:terms;type:text;comment:条款"` |
| | | Remark string `json:"remark" gorm:"column:remark;type:text;comment:备注"` |
| | | Products []Product `json:"products" gorm:"many2many:serviceContract_product;"` |
| | | gorm.Model `json:"-"` |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | ClientId int `json:"clientId" gorm:"column:client_id;type:int;comment:客户id"` |
| | | Number string `json:"number" gorm:"column:number;type:varchar(255);comment:合同编号"` |
| | | MemberId int `json:"memberId" gorm:"column:member_id;type:int;comment:负责人id"` |
| | | ContactId int `json:"contactId" gorm:"column:contact_id;type:int;comment:联系人id"` |
| | | SaleChanceId int `json:"saleChanceId" gorm:"column:sale_chance_id;type:int;comment:销售机会id"` |
| | | ContractId int `json:"contractId" gorm:"column:contract_id;type:int;comment:合同id"` |
| | | QuotationId int `json:"quotationId" gorm:"column:quotation_id;type:int;comment:报价单id"` |
| | | TypeId int `json:"typeId" gorm:"column:type_id;type:int;comment:合同类型id"` |
| | | SignTime time.Time `json:"signTime" gorm:"column:sign_time;type:datetime;comment:签约时间"` |
| | | StartTime time.Time `json:"startTime" gorm:"column:start_time;type:datetime;comment:开始时间"` |
| | | EndTime time.Time `json:"endTime" gorm:"column:end_time;type:datetime;comment:结束时间"` |
| | | ServiceContractStatusId int `json:"serviceContractStatusId" gorm:"column:service_contract_status_id;type:int;comment:合同状态id"` |
| | | ServiceTimes int `json:"serviceTimes" gorm:"column:service_times;type:int;comment:服务次数"` |
| | | Terms string `json:"terms" gorm:"column:terms;type:text;comment:条款"` |
| | | Remark string `json:"remark" gorm:"column:remark;type:text;comment:备注"` |
| | | Products []Product `json:"products" gorm:"many2many:serviceContract_product;"` |
| | | gorm.Model `json:"-"` |
| | | } |
| | | |
| | | ServiceContractSearch struct { |
| | |
| | | return slf |
| | | } |
| | | |
| | | // 工单类型 报修来源(工单管理) |
| | | // 合同类型 合同状态(服务合同) |
| | | // 付款方式 是否开票 账户(销售退款单) |
| | | // 退入仓库 状态(销售退货单) |
| | |
| | | OrderTypeSetErr = 4700004 // 设置工单类型失败 |
| | | OrderTypeUpdateErr = 4700005 // 更新工单类型失败 |
| | | |
| | | ) |
| | | |
| | | ServiceContractStatusExist = 4400001 // 服务合同状态已存在 |
| | | ServiceContractStatusNotExist = 4400002 // 服务合同状态不存在 |
| | | ServiceContractStatusListErr = 4400003 // 获取服务合同状态列表失败 |
| | | ServiceContractStatusSetErr = 4400004 // 设置服务合同状态失败 |
| | | ServiceContractStatusUpdateErr = 4400005 // 更新服务合同状态失败 |
| | | |
| | | ) |
| | |
| | | ) |
| | | |
| | | type Group struct { |
| | | ServiceContractStatusRouter |
| | | OrderTypeRouter |
| | | ReportSourceRouter |
| | | IsVisitRouter |
| | |
| | | routerGroup.InitIsVisitRouter(PrivateGroup) |
| | | routerGroup.InitReportSourceRouter(PrivateGroup) |
| | | routerGroup.InitOrderTypeRouter(PrivateGroup) |
| | | routerGroup.InitServiceContractStatusRouter(PrivateGroup) |
| | | } |
| | | return Router |
| | | } |
New file |
| | |
| | | |
| | | package router |
| | | |
| | | import ( |
| | | v1 "aps_crm/api/v1" |
| | | "github.com/gin-gonic/gin" |
| | | ) |
| | | |
| | | type ServiceContractStatusRouter struct{} |
| | | |
| | | func (s *ServiceContractStatusRouter) InitServiceContractStatusRouter(router *gin.RouterGroup) { |
| | | serviceContractStatusRouter := router.Group("serviceContractStatus") |
| | | serviceContractStatusApi := v1.ApiGroup.ServiceContractStatusApi |
| | | { |
| | | serviceContractStatusRouter.POST("add", serviceContractStatusApi.Add) // 添加$CName$ |
| | | serviceContractStatusRouter.DELETE("delete/:id", serviceContractStatusApi.Delete) // 删除$CName$ |
| | | serviceContractStatusRouter.PUT("update", serviceContractStatusApi.Update) // 更新$CName$ |
| | | serviceContractStatusRouter.GET("list", serviceContractStatusApi.List) // 获取$CName$列表 |
| | | } |
| | | } |
| | |
| | | data.OrderType = orderTypeList |
| | | |
| | | |
| | | // get ServiceContractStatus list |
| | | serviceContractStatusList, _ := ServiceGroup.GetServiceContractStatusList() |
| | | data.ServiceContractStatus = serviceContractStatusList |
| | | |
| | | |
| | | errCode = ecode.OK |
| | | |
| | | return |
| | |
| | | IsVisitService |
| | | ReportSourceService |
| | | OrderTypeService |
| | | ServiceContractStatusService |
| | | } |
| | | |
| | | var ServiceGroup = new(Group) |
New file |
| | |
| | | |
| | | package service |
| | | |
| | | import ( |
| | | "aps_crm/model" |
| | | "aps_crm/model/request" |
| | | "aps_crm/pkg/ecode" |
| | | ) |
| | | |
| | | type ServiceContractStatusService struct{} |
| | | |
| | | func (ServiceContractStatusService) AddServiceContractStatus(serviceContractStatus *model.ServiceContractStatus) int { |
| | | err := model.NewServiceContractStatusSearch().Create(serviceContractStatus) |
| | | if err != nil { |
| | | return ecode.ServiceContractStatusExist |
| | | } |
| | | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (ServiceContractStatusService) DeleteServiceContractStatus(id int) int { |
| | | _, err := model.NewServiceContractStatusSearch().SetId(id).Find() |
| | | if err != nil { |
| | | return ecode.ServiceContractStatusNotExist |
| | | } |
| | | |
| | | err = model.NewServiceContractStatusSearch().SetId(id).Delete() |
| | | if err != nil { |
| | | return ecode.ServiceContractStatusNotExist |
| | | } |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (ServiceContractStatusService) GetServiceContractStatusList() ([]*model.ServiceContractStatus, int) { |
| | | list, err := model.NewServiceContractStatusSearch().FindAll() |
| | | if err != nil { |
| | | return nil, ecode.ServiceContractStatusListErr |
| | | } |
| | | |
| | | return list, ecode.OK |
| | | } |
| | | |
| | | func (ServiceContractStatusService) UpdateServiceContractStatus(serviceContractStatuss []*request.UpdateServiceContractStatus) int { |
| | | for _, v := range serviceContractStatuss { |
| | | // check serviceContractStatus exist |
| | | _, err := model.NewServiceContractStatusSearch().SetId(v.Id).Find() |
| | | if err != nil { |
| | | return ecode.ServiceContractStatusNotExist |
| | | } |
| | | |
| | | err = model.NewServiceContractStatusSearch().SetId(v.Id).Updates(map[string]interface{}{ |
| | | "name": v.Name, |
| | | }) |
| | | if err != nil { |
| | | return ecode.ServiceContractStatusSetErr |
| | | } |
| | | } |
| | | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (ServiceContractStatusService) GetServiceContractStatusDetail(id int) (*model.ServiceContractStatus, int) { |
| | | serviceContractStatus, err := model.NewServiceContractStatusSearch().SetId(id).Find() |
| | | if err != nil { |
| | | return nil, ecode.ServiceContractStatusNotExist |
| | | } |
| | | |
| | | return serviceContractStatus, ecode.OK |
| | | } |