add
ServiceContractType 服务合同类型
add, Delete, update, list
| | |
| | | ) |
| | | |
| | | type Group struct { |
| | | ServiceContractTypeApi |
| | | ServiceContractStatusApi |
| | | OrderTypeApi |
| | | ReportSourceApi |
| | |
| | | reportSourceService = service.ServiceGroup.ReportSourceService |
| | | orderTypeService = service.ServiceGroup.OrderTypeService |
| | | serviceContractStatusService = service.ServiceGroup.ServiceContractStatusService |
| | | serviceContractTypeService = service.ServiceGroup.ServiceContractTypeService |
| | | ) |
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 ServiceContractTypeApi struct{} |
| | | |
| | | // Add |
| | | // |
| | | // @Tags ServiceContractType |
| | | // @Summary 添加服务合同类型 |
| | | // @Produce application/json |
| | | // @Param object body request.AddServiceContractType true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/serviceContractType/add [post] |
| | | func (s *ServiceContractTypeApi) Add(c *gin.Context) { |
| | | var params request.AddServiceContractType |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | serviceContractType := new(model.ServiceContractType) |
| | | serviceContractType.Name = params.Name |
| | | |
| | | errCode := serviceContractTypeService.AddServiceContractType(serviceContractType) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // Delete |
| | | // |
| | | // @Tags ServiceContractType |
| | | // @Summary 删除服务合同类型 |
| | | // @Produce application/json |
| | | // @Param id path int true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/serviceContractType/delete/{id} [delete] |
| | | func (s *ServiceContractTypeApi) Delete(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | id, _ := strconv.Atoi(c.Param("id")) |
| | | errCode := serviceContractTypeService.DeleteServiceContractType(id) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // Update |
| | | // |
| | | // @Tags ServiceContractType |
| | | // @Summary 更新服务合同类型 |
| | | // @Produce application/json |
| | | // @Param object body request.UpdateServiceContractTypes true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/serviceContractType/update [put] |
| | | func (s *ServiceContractTypeApi) Update(c *gin.Context) { |
| | | var params request.UpdateServiceContractTypes |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | errCode := serviceContractTypeService.UpdateServiceContractType(params.ServiceContractTypes) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // List |
| | | // |
| | | // @Tags ServiceContractType |
| | | // @Summary 获取服务合同类型列表 |
| | | // @Produce application/json |
| | | // @Success 200 {object} contextx.Response{data=response.ServiceContractTypeResponse} |
| | | // @Router /api/serviceContractType/list [get] |
| | | func (s *ServiceContractTypeApi) List(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | serviceContractTypes, errCode := serviceContractTypeService.GetServiceContractTypeList() |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.OkWithDetailed(response.ServiceContractTypeResponse{ |
| | | List: serviceContractTypes, |
| | | }) |
| | | } |
| | |
| | | result.ContactId = serviceContract.ContactId |
| | | result.SaleChanceId = serviceContract.SaleChanceId |
| | | result.QuotationId = serviceContract.QuotationId |
| | | result.TypeId = serviceContract.TypeId |
| | | result.ServiceContractTypeId = serviceContract.TypeId |
| | | result.ServiceContractStatusId = serviceContract.StatusId |
| | | result.ServiceTimes = serviceContract.ServiceTimes |
| | | result.Terms = serviceContract.Terms |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/serviceContractType/add": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "ServiceContractType" |
| | | ], |
| | | "summary": "添加服务合同类型", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddServiceContractType" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/serviceContractType/delete/{id}": { |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "ServiceContractType" |
| | | ], |
| | | "summary": "删除服务合同类型", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "查询参数", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/serviceContractType/list": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "ServiceContractType" |
| | | ], |
| | | "summary": "获取服务合同类型列表", |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/response.ServiceContractTypeResponse" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/serviceContractType/update": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "ServiceContractType" |
| | | ], |
| | | "summary": "更新服务合同类型", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateServiceContractTypes" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/serviceFeeManage/add": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | "serviceContractStatusId": { |
| | | "type": "integer" |
| | | }, |
| | | "serviceContractTypeId": { |
| | | "type": "integer" |
| | | }, |
| | | "serviceTimes": { |
| | | "type": "integer" |
| | | }, |
| | |
| | | }, |
| | | "terms": { |
| | | "type": "string" |
| | | }, |
| | | "typeId": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "model.ServiceContractStatus": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "model.ServiceContractType": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | |
| | | } |
| | | }, |
| | | "request.AddServiceContractStatus": { |
| | | "type": "object", |
| | | "required": [ |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.AddServiceContractType": { |
| | | "type": "object", |
| | | "required": [ |
| | | "name" |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateServiceContractType": { |
| | | "type": "object", |
| | | "required": [ |
| | | "id", |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateServiceContractTypes": { |
| | | "type": "object", |
| | | "required": [ |
| | | "service_contract_type" |
| | | ], |
| | | "properties": { |
| | | "service_contract_type": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/request.UpdateServiceContractType" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateServiceFeeManage": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "$ref": "#/definitions/model.ServiceContractStatus" |
| | | } |
| | | }, |
| | | "serviceContractType": { |
| | | "description": "服务合同类型", |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.ServiceContractType" |
| | | } |
| | | }, |
| | | "solve_rate": { |
| | | "description": "解决率", |
| | | "type": "array", |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.ServiceContractTypeResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.ServiceContractType" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "response.ServiceContractsResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/serviceContractType/add": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "ServiceContractType" |
| | | ], |
| | | "summary": "添加服务合同类型", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddServiceContractType" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/serviceContractType/delete/{id}": { |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "ServiceContractType" |
| | | ], |
| | | "summary": "删除服务合同类型", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "查询参数", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/serviceContractType/list": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "ServiceContractType" |
| | | ], |
| | | "summary": "获取服务合同类型列表", |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/response.ServiceContractTypeResponse" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/serviceContractType/update": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "ServiceContractType" |
| | | ], |
| | | "summary": "更新服务合同类型", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateServiceContractTypes" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/serviceFeeManage/add": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | "serviceContractStatusId": { |
| | | "type": "integer" |
| | | }, |
| | | "serviceContractTypeId": { |
| | | "type": "integer" |
| | | }, |
| | | "serviceTimes": { |
| | | "type": "integer" |
| | | }, |
| | |
| | | }, |
| | | "terms": { |
| | | "type": "string" |
| | | }, |
| | | "typeId": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "model.ServiceContractStatus": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "model.ServiceContractType": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | |
| | | } |
| | | }, |
| | | "request.AddServiceContractStatus": { |
| | | "type": "object", |
| | | "required": [ |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.AddServiceContractType": { |
| | | "type": "object", |
| | | "required": [ |
| | | "name" |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateServiceContractType": { |
| | | "type": "object", |
| | | "required": [ |
| | | "id", |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateServiceContractTypes": { |
| | | "type": "object", |
| | | "required": [ |
| | | "service_contract_type" |
| | | ], |
| | | "properties": { |
| | | "service_contract_type": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/request.UpdateServiceContractType" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateServiceFeeManage": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "$ref": "#/definitions/model.ServiceContractStatus" |
| | | } |
| | | }, |
| | | "serviceContractType": { |
| | | "description": "服务合同类型", |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.ServiceContractType" |
| | | } |
| | | }, |
| | | "solve_rate": { |
| | | "description": "解决率", |
| | | "type": "array", |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.ServiceContractTypeResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.ServiceContractType" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "response.ServiceContractsResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | type: integer |
| | | serviceContractStatusId: |
| | | type: integer |
| | | serviceContractTypeId: |
| | | type: integer |
| | | serviceTimes: |
| | | type: integer |
| | | signTime: |
| | |
| | | type: string |
| | | terms: |
| | | type: string |
| | | typeId: |
| | | type: integer |
| | | type: object |
| | | model.ServiceContractStatus: |
| | | properties: |
| | | id: |
| | | type: integer |
| | | name: |
| | | type: string |
| | | type: object |
| | | model.ServiceContractType: |
| | | properties: |
| | | id: |
| | | type: integer |
| | |
| | | type: integer |
| | | type: object |
| | | request.AddServiceContractStatus: |
| | | properties: |
| | | name: |
| | | type: string |
| | | required: |
| | | - name |
| | | type: object |
| | | request.AddServiceContractType: |
| | | properties: |
| | | name: |
| | | type: string |
| | |
| | | required: |
| | | - service_contract_status |
| | | type: object |
| | | request.UpdateServiceContractType: |
| | | properties: |
| | | id: |
| | | type: integer |
| | | name: |
| | | type: string |
| | | required: |
| | | - id |
| | | - name |
| | | type: object |
| | | request.UpdateServiceContractTypes: |
| | | properties: |
| | | service_contract_type: |
| | | items: |
| | | $ref: '#/definitions/request.UpdateServiceContractType' |
| | | type: array |
| | | required: |
| | | - service_contract_type |
| | | type: object |
| | | request.UpdateServiceFeeManage: |
| | | properties: |
| | | business_scope: |
| | |
| | | items: |
| | | $ref: '#/definitions/model.ServiceContractStatus' |
| | | type: array |
| | | serviceContractType: |
| | | description: 服务合同类型 |
| | | items: |
| | | $ref: '#/definitions/model.ServiceContractType' |
| | | type: array |
| | | solve_rate: |
| | | description: 解决率 |
| | | items: |
| | |
| | | list: |
| | | items: |
| | | $ref: '#/definitions/model.ServiceContractStatus' |
| | | type: array |
| | | type: object |
| | | response.ServiceContractTypeResponse: |
| | | properties: |
| | | list: |
| | | items: |
| | | $ref: '#/definitions/model.ServiceContractType' |
| | | type: array |
| | | type: object |
| | | response.ServiceContractsResponse: |
| | |
| | | summary: 更新服务合同状态 |
| | | tags: |
| | | - ServiceContractStatus |
| | | /api/serviceContractType/add: |
| | | post: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.AddServiceContractType' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 添加服务合同类型 |
| | | tags: |
| | | - ServiceContractType |
| | | /api/serviceContractType/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: |
| | | - ServiceContractType |
| | | /api/serviceContractType/list: |
| | | get: |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | allOf: |
| | | - $ref: '#/definitions/contextx.Response' |
| | | - properties: |
| | | data: |
| | | $ref: '#/definitions/response.ServiceContractTypeResponse' |
| | | type: object |
| | | summary: 获取服务合同类型列表 |
| | | tags: |
| | | - ServiceContractType |
| | | /api/serviceContractType/update: |
| | | put: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.UpdateServiceContractTypes' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 更新服务合同类型 |
| | | tags: |
| | | - ServiceContractType |
| | | /api/serviceFeeManage/add: |
| | | post: |
| | | parameters: |
| | |
| | | ReportSource{}, |
| | | OrderType{}, |
| | | ServiceContractStatus{}, |
| | | ServiceContractType{}, |
| | | ) |
| | | return err |
| | | } |
New file |
| | |
| | | |
| | | package request |
| | | |
| | | type AddServiceContractType struct { |
| | | Name string ` json:"name" binding:"required"` |
| | | } |
| | | |
| | | type UpdateServiceContractType struct { |
| | | Id int `json:"id" binding:"required"` |
| | | Name string `json:"name" binding:"required"` |
| | | } |
| | | |
| | | type UpdateServiceContractTypes struct { |
| | | ServiceContractTypes []*UpdateServiceContractType `json:"service_contract_type" binding:"required"` |
| | | } |
| | |
| | | |
| | | DataResponse struct { |
| | | |
| | | // 服务合同类型 |
| | | ServiceContractType []*model.ServiceContractType `json:"serviceContractType"` |
| | | |
| | | |
| | | // 服务合同状态 |
| | | ServiceContractStatus []*model.ServiceContractStatus `json:"serviceContractStatus"` |
| | | |
| | |
| | | ServiceContractStatusResponse struct { |
| | | List []*model.ServiceContractStatus `json:"list"` |
| | | } |
| | | |
| | | ServiceContractTypeResponse struct { |
| | | List []*model.ServiceContractType `json:"list"` |
| | | } |
| | | ) |
New file |
| | |
| | | package model |
| | | |
| | | import ( |
| | | "aps_crm/pkg/mysqlx" |
| | | "gorm.io/gorm" |
| | | ) |
| | | |
| | | type ( |
| | | // ServiceContractType 商机阶段 |
| | | ServiceContractType struct { |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | Name string `json:"name" gorm:"column:name;type:varchar(255);comment:商机阶段名称"` |
| | | } |
| | | |
| | | ServiceContractTypeSearch struct { |
| | | ServiceContractType |
| | | Orm *gorm.DB |
| | | } |
| | | ) |
| | | |
| | | func (ServiceContractType) TableName() string { |
| | | return "service_contract_type" |
| | | } |
| | | |
| | | func NewServiceContractTypeSearch() *ServiceContractTypeSearch { |
| | | return &ServiceContractTypeSearch{ |
| | | Orm: mysqlx.GetDB(), |
| | | } |
| | | } |
| | | |
| | | func (slf *ServiceContractTypeSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&ServiceContractType{}) |
| | | if slf.Id != 0 { |
| | | db = db.Where("id = ?", slf.Id) |
| | | } |
| | | if slf.Name != "" { |
| | | db = db.Where("name = ?", slf.Name) |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |
| | | func (slf *ServiceContractTypeSearch) Create(record *ServiceContractType) error { |
| | | var db = slf.build() |
| | | return db.Create(record).Error |
| | | } |
| | | |
| | | func (slf *ServiceContractTypeSearch) Delete() error { |
| | | var db = slf.build() |
| | | return db.Delete(&ServiceContractType{}).Error |
| | | } |
| | | |
| | | func (slf *ServiceContractTypeSearch) Update(record *ServiceContractType) error { |
| | | var db = slf.build() |
| | | return db.Updates(record).Error |
| | | } |
| | | |
| | | func (slf *ServiceContractTypeSearch) Find() (*ServiceContractType, error) { |
| | | var db = slf.build() |
| | | var record = new(ServiceContractType) |
| | | err := db.First(record).Error |
| | | return record, err |
| | | } |
| | | |
| | | func (slf *ServiceContractTypeSearch) FindAll() ([]*ServiceContractType, error) { |
| | | var db = slf.build() |
| | | var records = make([]*ServiceContractType, 0) |
| | | err := db.Find(&records).Error |
| | | return records, err |
| | | } |
| | | |
| | | func (slf *ServiceContractTypeSearch) SetId(id int) *ServiceContractTypeSearch { |
| | | slf.Id = id |
| | | return slf |
| | | } |
| | | |
| | | func (slf *ServiceContractTypeSearch) SetName(name string) *ServiceContractTypeSearch { |
| | | slf.Name = name |
| | | return slf |
| | | } |
| | | |
| | | func (slf *ServiceContractTypeSearch) Updates(data map[string]interface{}) error { |
| | | var db = slf.build() |
| | | return db.Updates(data).Error |
| | | } |
| | |
| | | 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"` |
| | | ServiceContractTypeId int `json:"serviceContractTypeId" gorm:"column:service_contract_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:结束时间"` |
| | |
| | | ServiceContractStatusSetErr = 4400004 // 设置服务合同状态失败 |
| | | ServiceContractStatusUpdateErr = 4400005 // 更新服务合同状态失败 |
| | | |
| | | |
| | | ServiceContractTypeExist = 4400001 // 服务合同类型已存在 |
| | | ServiceContractTypeNotExist = 4400002 // 服务合同类型不存在 |
| | | ServiceContractTypeListErr = 4400003 // 获取服务合同类型列表失败 |
| | | ServiceContractTypeSetErr = 4400004 // 设置服务合同类型失败 |
| | | ServiceContractTypeUpdateErr = 4400005 // 更新服务合同类型失败 |
| | | |
| | | ) |
| | |
| | | ) |
| | | |
| | | type Group struct { |
| | | ServiceContractTypeRouter |
| | | ServiceContractStatusRouter |
| | | OrderTypeRouter |
| | | ReportSourceRouter |
| | |
| | | routerGroup.InitReportSourceRouter(PrivateGroup) |
| | | routerGroup.InitOrderTypeRouter(PrivateGroup) |
| | | routerGroup.InitServiceContractStatusRouter(PrivateGroup) |
| | | routerGroup.InitServiceContractTypeRouter(PrivateGroup) |
| | | } |
| | | return Router |
| | | } |
New file |
| | |
| | | |
| | | package router |
| | | |
| | | import ( |
| | | v1 "aps_crm/api/v1" |
| | | "github.com/gin-gonic/gin" |
| | | ) |
| | | |
| | | type ServiceContractTypeRouter struct{} |
| | | |
| | | func (s *ServiceContractTypeRouter) InitServiceContractTypeRouter(router *gin.RouterGroup) { |
| | | serviceContractTypeRouter := router.Group("serviceContractType") |
| | | serviceContractTypeApi := v1.ApiGroup.ServiceContractTypeApi |
| | | { |
| | | serviceContractTypeRouter.POST("add", serviceContractTypeApi.Add) // 添加$CName$ |
| | | serviceContractTypeRouter.DELETE("delete/:id", serviceContractTypeApi.Delete) // 删除$CName$ |
| | | serviceContractTypeRouter.PUT("update", serviceContractTypeApi.Update) // 更新$CName$ |
| | | serviceContractTypeRouter.GET("list", serviceContractTypeApi.List) // 获取$CName$列表 |
| | | } |
| | | } |
| | |
| | | data.ServiceContractStatus = serviceContractStatusList |
| | | |
| | | |
| | | // get ServiceContractType list |
| | | serviceContractTypeList, _ := ServiceGroup.GetServiceContractTypeList() |
| | | data.ServiceContractType = serviceContractTypeList |
| | | |
| | | |
| | | errCode = ecode.OK |
| | | |
| | | return |
| | |
| | | ReportSourceService |
| | | OrderTypeService |
| | | ServiceContractStatusService |
| | | ServiceContractTypeService |
| | | } |
| | | |
| | | var ServiceGroup = new(Group) |
New file |
| | |
| | | |
| | | package service |
| | | |
| | | import ( |
| | | "aps_crm/model" |
| | | "aps_crm/model/request" |
| | | "aps_crm/pkg/ecode" |
| | | ) |
| | | |
| | | type ServiceContractTypeService struct{} |
| | | |
| | | func (ServiceContractTypeService) AddServiceContractType(serviceContractType *model.ServiceContractType) int { |
| | | err := model.NewServiceContractTypeSearch().Create(serviceContractType) |
| | | if err != nil { |
| | | return ecode.ServiceContractTypeExist |
| | | } |
| | | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (ServiceContractTypeService) DeleteServiceContractType(id int) int { |
| | | _, err := model.NewServiceContractTypeSearch().SetId(id).Find() |
| | | if err != nil { |
| | | return ecode.ServiceContractTypeNotExist |
| | | } |
| | | |
| | | err = model.NewServiceContractTypeSearch().SetId(id).Delete() |
| | | if err != nil { |
| | | return ecode.ServiceContractTypeNotExist |
| | | } |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (ServiceContractTypeService) GetServiceContractTypeList() ([]*model.ServiceContractType, int) { |
| | | list, err := model.NewServiceContractTypeSearch().FindAll() |
| | | if err != nil { |
| | | return nil, ecode.ServiceContractTypeListErr |
| | | } |
| | | |
| | | return list, ecode.OK |
| | | } |
| | | |
| | | func (ServiceContractTypeService) UpdateServiceContractType(serviceContractTypes []*request.UpdateServiceContractType) int { |
| | | for _, v := range serviceContractTypes { |
| | | // check serviceContractType exist |
| | | _, err := model.NewServiceContractTypeSearch().SetId(v.Id).Find() |
| | | if err != nil { |
| | | return ecode.ServiceContractTypeNotExist |
| | | } |
| | | |
| | | err = model.NewServiceContractTypeSearch().SetId(v.Id).Updates(map[string]interface{}{ |
| | | "name": v.Name, |
| | | }) |
| | | if err != nil { |
| | | return ecode.ServiceContractTypeSetErr |
| | | } |
| | | } |
| | | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (ServiceContractTypeService) GetServiceContractTypeDetail(id int) (*model.ServiceContractType, int) { |
| | | serviceContractType, err := model.NewServiceContractTypeSearch().SetId(id).Find() |
| | | if err != nil { |
| | | return nil, ecode.ServiceContractTypeNotExist |
| | | } |
| | | |
| | | return serviceContractType, ecode.OK |
| | | } |