add
ReportSource 报修来源模块
add, Delete, update, list
| | |
| | | ) |
| | | |
| | | type Group struct { |
| | | ReportSourceApi |
| | | IsVisitApi |
| | | SolveRateApi |
| | | TimelyRateApi |
| | |
| | | timelyRateService = service.ServiceGroup.TimelyRateService |
| | | solveRateService = service.ServiceGroup.SolveRateService |
| | | isVisitService = service.ServiceGroup.IsVisitService |
| | | ) |
| | | reportSourceService = service.ServiceGroup.ReportSourceService |
| | | ) |
| | |
| | | // Add |
| | | // |
| | | // @Tags OrderManage |
| | | // @Summary 添加订单 |
| | | // @Summary 添加工单 |
| | | // @Produce application/json |
| | | // @Param object body request.AddOrderManage true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | |
| | | // Delete |
| | | // |
| | | // @Tags OrderManage |
| | | // @Summary 删除订单 |
| | | // @Summary 删除工单 |
| | | // @Produce application/json |
| | | // @Param id path int true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | |
| | | // Update |
| | | // |
| | | // @Tags OrderManage |
| | | // @Summary 更新订单 |
| | | // @Summary 更新工单 |
| | | // @Produce application/json |
| | | // @Param object body request.UpdateOrderManage true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | |
| | | // List |
| | | // |
| | | // @Tags OrderManage |
| | | // @Summary 订单列表 |
| | | // @Summary 工单列表 |
| | | // @Produce application/json |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/orderManage/list [get] |
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 ReportSourceApi struct{} |
| | | |
| | | // Add |
| | | // |
| | | // @Tags ReportSource |
| | | // @Summary 添加报表来源 |
| | | // @Produce application/json |
| | | // @Param object body request.AddReportSource true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/reportSource/add [post] |
| | | func (s *ReportSourceApi) Add(c *gin.Context) { |
| | | var params request.AddReportSource |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | reportSource := new(model.ReportSource) |
| | | reportSource.Name = params.Name |
| | | |
| | | errCode := reportSourceService.AddReportSource(reportSource) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // Delete |
| | | // |
| | | // @Tags ReportSource |
| | | // @Summary 删除报表来源 |
| | | // @Produce application/json |
| | | // @Param id path int true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/reportSource/delete/{id} [delete] |
| | | func (s *ReportSourceApi) Delete(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | id, _ := strconv.Atoi(c.Param("id")) |
| | | errCode := reportSourceService.DeleteReportSource(id) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // Update |
| | | // |
| | | // @Tags ReportSource |
| | | // @Summary 更新报表来源 |
| | | // @Produce application/json |
| | | // @Param object body request.UpdateReportSources true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/reportSource/update [put] |
| | | func (s *ReportSourceApi) Update(c *gin.Context) { |
| | | var params request.UpdateReportSources |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | errCode := reportSourceService.UpdateReportSource(params.ReportSources) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // List |
| | | // |
| | | // @Tags ReportSource |
| | | // @Summary 获取报表来源列表 |
| | | // @Produce application/json |
| | | // @Success 200 {object} contextx.Response{data=response.ReportSourceResponse} |
| | | // @Router /api/reportSource/list [get] |
| | | func (s *ReportSourceApi) List(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | reportSources, errCode := reportSourceService.GetReportSourceList() |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.OkWithDetailed(response.ReportSourceResponse{ |
| | | List: reportSources, |
| | | }) |
| | | } |
| | |
| | | "tags": [ |
| | | "OrderManage" |
| | | ], |
| | | "summary": "添加订单", |
| | | "summary": "添加工单", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | |
| | | "tags": [ |
| | | "OrderManage" |
| | | ], |
| | | "summary": "删除订单", |
| | | "summary": "删除工单", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | |
| | | "tags": [ |
| | | "OrderManage" |
| | | ], |
| | | "summary": "订单列表", |
| | | "summary": "工单列表", |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | |
| | | "tags": [ |
| | | "OrderManage" |
| | | ], |
| | | "summary": "更新订单", |
| | | "summary": "更新工单", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateRegularCustomersList" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/reportSource/add": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "ReportSource" |
| | | ], |
| | | "summary": "添加报表来源", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddReportSource" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/reportSource/delete/{id}": { |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "ReportSource" |
| | | ], |
| | | "summary": "删除报表来源", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "查询参数", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/reportSource/list": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "ReportSource" |
| | | ], |
| | | "summary": "获取报表来源列表", |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/response.ReportSourceResponse" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/reportSource/update": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "ReportSource" |
| | | ], |
| | | "summary": "更新报表来源", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateReportSources" |
| | | } |
| | | } |
| | | ], |
| | |
| | | } |
| | | } |
| | | }, |
| | | "model.ReportSource": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "model.SaleChance": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | }, |
| | | "request.AddRegularCustomers": { |
| | | "type": "object", |
| | | "required": [ |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.AddReportSource": { |
| | | "type": "object", |
| | | "required": [ |
| | | "name" |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateReportSource": { |
| | | "type": "object", |
| | | "required": [ |
| | | "id", |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateReportSources": { |
| | | "type": "object", |
| | | "required": [ |
| | | "report_source" |
| | | ], |
| | | "properties": { |
| | | "report_source": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/request.UpdateReportSource" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateSaleChance": { |
| | | "type": "object", |
| | | "required": [ |
| | |
| | | "$ref": "#/definitions/model.RegularCustomers" |
| | | } |
| | | }, |
| | | "reportSource": { |
| | | "description": "报表来源", |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.ReportSource" |
| | | } |
| | | }, |
| | | "sale_stage": { |
| | | "description": "销售阶段", |
| | | "type": "array", |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.ReportSourceResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.ReportSource" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "response.SaleChanceResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "tags": [ |
| | | "OrderManage" |
| | | ], |
| | | "summary": "添加订单", |
| | | "summary": "添加工单", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | |
| | | "tags": [ |
| | | "OrderManage" |
| | | ], |
| | | "summary": "删除订单", |
| | | "summary": "删除工单", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | |
| | | "tags": [ |
| | | "OrderManage" |
| | | ], |
| | | "summary": "订单列表", |
| | | "summary": "工单列表", |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | |
| | | "tags": [ |
| | | "OrderManage" |
| | | ], |
| | | "summary": "更新订单", |
| | | "summary": "更新工单", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateRegularCustomersList" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/reportSource/add": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "ReportSource" |
| | | ], |
| | | "summary": "添加报表来源", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddReportSource" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/reportSource/delete/{id}": { |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "ReportSource" |
| | | ], |
| | | "summary": "删除报表来源", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "查询参数", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/reportSource/list": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "ReportSource" |
| | | ], |
| | | "summary": "获取报表来源列表", |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/response.ReportSourceResponse" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/reportSource/update": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "ReportSource" |
| | | ], |
| | | "summary": "更新报表来源", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateReportSources" |
| | | } |
| | | } |
| | | ], |
| | |
| | | } |
| | | } |
| | | }, |
| | | "model.ReportSource": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "model.SaleChance": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | }, |
| | | "request.AddRegularCustomers": { |
| | | "type": "object", |
| | | "required": [ |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.AddReportSource": { |
| | | "type": "object", |
| | | "required": [ |
| | | "name" |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateReportSource": { |
| | | "type": "object", |
| | | "required": [ |
| | | "id", |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateReportSources": { |
| | | "type": "object", |
| | | "required": [ |
| | | "report_source" |
| | | ], |
| | | "properties": { |
| | | "report_source": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/request.UpdateReportSource" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateSaleChance": { |
| | | "type": "object", |
| | | "required": [ |
| | |
| | | "$ref": "#/definitions/model.RegularCustomers" |
| | | } |
| | | }, |
| | | "reportSource": { |
| | | "description": "报表来源", |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.ReportSource" |
| | | } |
| | | }, |
| | | "sale_stage": { |
| | | "description": "销售阶段", |
| | | "type": "array", |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.ReportSourceResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.ReportSource" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "response.SaleChanceResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | name: |
| | | type: string |
| | | type: object |
| | | model.ReportSource: |
| | | properties: |
| | | id: |
| | | type: integer |
| | | name: |
| | | type: string |
| | | type: object |
| | | model.SaleChance: |
| | | properties: |
| | | advantages: |
| | |
| | | - name |
| | | type: object |
| | | request.AddRegularCustomers: |
| | | properties: |
| | | name: |
| | | type: string |
| | | required: |
| | | - name |
| | | type: object |
| | | request.AddReportSource: |
| | | properties: |
| | | name: |
| | | type: string |
| | |
| | | required: |
| | | - regularCustomers |
| | | type: object |
| | | request.UpdateReportSource: |
| | | properties: |
| | | id: |
| | | type: integer |
| | | name: |
| | | type: string |
| | | required: |
| | | - id |
| | | - name |
| | | type: object |
| | | request.UpdateReportSources: |
| | | properties: |
| | | report_source: |
| | | items: |
| | | $ref: '#/definitions/request.UpdateReportSource' |
| | | type: array |
| | | required: |
| | | - report_source |
| | | type: object |
| | | request.UpdateSaleChance: |
| | | properties: |
| | | advantages: |
| | |
| | | items: |
| | | $ref: '#/definitions/model.RegularCustomers' |
| | | type: array |
| | | reportSource: |
| | | description: 报表来源 |
| | | items: |
| | | $ref: '#/definitions/model.ReportSource' |
| | | type: array |
| | | sale_stage: |
| | | description: 销售阶段 |
| | | items: |
| | |
| | | list: |
| | | items: |
| | | $ref: '#/definitions/model.RegularCustomers' |
| | | type: array |
| | | type: object |
| | | response.ReportSourceResponse: |
| | | properties: |
| | | list: |
| | | items: |
| | | $ref: '#/definitions/model.ReportSource' |
| | | type: array |
| | | type: object |
| | | response.SaleChanceResponse: |
| | |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 添加订单 |
| | | summary: 添加工单 |
| | | tags: |
| | | - OrderManage |
| | | /api/orderManage/delete/{id}: |
| | |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 删除订单 |
| | | summary: 删除工单 |
| | | tags: |
| | | - OrderManage |
| | | /api/orderManage/list: |
| | |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 订单列表 |
| | | summary: 工单列表 |
| | | tags: |
| | | - OrderManage |
| | | /api/orderManage/update: |
| | |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 更新订单 |
| | | summary: 更新工单 |
| | | tags: |
| | | - OrderManage |
| | | /api/plan/add: |
| | |
| | | summary: 更新常客 |
| | | tags: |
| | | - RegularCustomers |
| | | /api/reportSource/add: |
| | | post: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.AddReportSource' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 添加报表来源 |
| | | tags: |
| | | - ReportSource |
| | | /api/reportSource/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: |
| | | - ReportSource |
| | | /api/reportSource/list: |
| | | get: |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | allOf: |
| | | - $ref: '#/definitions/contextx.Response' |
| | | - properties: |
| | | data: |
| | | $ref: '#/definitions/response.ReportSourceResponse' |
| | | type: object |
| | | summary: 获取报表来源列表 |
| | | tags: |
| | | - ReportSource |
| | | /api/reportSource/update: |
| | | put: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.UpdateReportSources' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 更新报表来源 |
| | | tags: |
| | | - ReportSource |
| | | /api/saleChance/add: |
| | | post: |
| | | parameters: |
| | |
| | | SolveRate{}, |
| | | IsVisit{}, |
| | | IsVisit{}, |
| | | ReportSource{}, |
| | | ) |
| | | return err |
| | | } |
New file |
| | |
| | | package model |
| | | |
| | | import ( |
| | | "aps_crm/pkg/mysqlx" |
| | | "gorm.io/gorm" |
| | | ) |
| | | |
| | | type ( |
| | | // ReportSource 商机阶段 |
| | | ReportSource struct { |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | Name string `json:"name" gorm:"column:name;type:varchar(255);comment:商机阶段名称"` |
| | | } |
| | | |
| | | ReportSourceSearch struct { |
| | | ReportSource |
| | | Orm *gorm.DB |
| | | } |
| | | ) |
| | | |
| | | func (ReportSource) TableName() string { |
| | | return "report_source" |
| | | } |
| | | |
| | | func NewReportSourceSearch() *ReportSourceSearch { |
| | | return &ReportSourceSearch{ |
| | | Orm: mysqlx.GetDB(), |
| | | } |
| | | } |
| | | |
| | | func (slf *ReportSourceSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&ReportSource{}) |
| | | if slf.Id != 0 { |
| | | db = db.Where("id = ?", slf.Id) |
| | | } |
| | | if slf.Name != "" { |
| | | db = db.Where("name = ?", slf.Name) |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |
| | | func (slf *ReportSourceSearch) Create(record *ReportSource) error { |
| | | var db = slf.build() |
| | | return db.Create(record).Error |
| | | } |
| | | |
| | | func (slf *ReportSourceSearch) Delete() error { |
| | | var db = slf.build() |
| | | return db.Delete(&ReportSource{}).Error |
| | | } |
| | | |
| | | func (slf *ReportSourceSearch) Update(record *ReportSource) error { |
| | | var db = slf.build() |
| | | return db.Updates(record).Error |
| | | } |
| | | |
| | | func (slf *ReportSourceSearch) Find() (*ReportSource, error) { |
| | | var db = slf.build() |
| | | var record = new(ReportSource) |
| | | err := db.First(record).Error |
| | | return record, err |
| | | } |
| | | |
| | | func (slf *ReportSourceSearch) FindAll() ([]*ReportSource, error) { |
| | | var db = slf.build() |
| | | var records = make([]*ReportSource, 0) |
| | | err := db.Find(&records).Error |
| | | return records, err |
| | | } |
| | | |
| | | func (slf *ReportSourceSearch) SetId(id int) *ReportSourceSearch { |
| | | slf.Id = id |
| | | return slf |
| | | } |
| | | |
| | | func (slf *ReportSourceSearch) SetName(name string) *ReportSourceSearch { |
| | | slf.Name = name |
| | | return slf |
| | | } |
| | | |
| | | func (slf *ReportSourceSearch) Updates(data map[string]interface{}) error { |
| | | var db = slf.build() |
| | | return db.Updates(data).Error |
| | | } |
New file |
| | |
| | | |
| | | package request |
| | | |
| | | type AddReportSource struct { |
| | | Name string ` json:"name" binding:"required"` |
| | | } |
| | | |
| | | type UpdateReportSource struct { |
| | | Id int `json:"id" binding:"required"` |
| | | Name string `json:"name" binding:"required"` |
| | | } |
| | | |
| | | type UpdateReportSources struct { |
| | | ReportSources []*UpdateReportSource `json:"report_source" binding:"required"` |
| | | } |
| | |
| | | |
| | | DataResponse struct { |
| | | |
| | | // 报表来源 |
| | | ReportSource []*model.ReportSource `json:"reportSource"` |
| | | |
| | | |
| | | // 服务人员是否来过 |
| | | IsVisit []*model.IsVisit `json:"isVisit"` |
| | | |
| | |
| | | IsVisitResponse struct { |
| | | List []*model.IsVisit `json:"list"` |
| | | } |
| | | ) |
| | | |
| | | ReportSourceResponse struct { |
| | | List []*model.ReportSource `json:"list"` |
| | | } |
| | | ) |
| | |
| | | return slf |
| | | } |
| | | |
| | | // 及时率 解决率 满意度 服务人员是否来过 (服务回访单) |
| | | // 工单类型 报修来源(工单管理) |
| | | // 合同类型 合同状态(服务合同) |
| | | // 付款方式 是否开票 账户(销售退款单) |
| | |
| | | IsVisitSetErr = 4500004 // 设置服务人员是否来过失败 |
| | | IsVisitUpdateErr = 4500005 // 更新服务人员是否来过失败 |
| | | |
| | | ) |
| | | |
| | | ReportSourceExist = 4400001 // 报表来源已存在 |
| | | ReportSourceNotExist = 4400002 // 报表来源不存在 |
| | | ReportSourceListErr = 4400003 // 获取报表来源列表失败 |
| | | ReportSourceSetErr = 4400004 // 设置报表来源失败 |
| | | ReportSourceUpdateErr = 4400005 // 更新报表来源失败 |
| | | |
| | | ) |
| | |
| | | ) |
| | | |
| | | type Group struct { |
| | | ReportSourceRouter |
| | | IsVisitRouter |
| | | SolveRateRouter |
| | | TimelyRateRouter |
| | |
| | | routerGroup.InitTimelyRateRouter(PrivateGroup) |
| | | routerGroup.InitSolveRateRouter(PrivateGroup) |
| | | routerGroup.InitIsVisitRouter(PrivateGroup) |
| | | routerGroup.InitReportSourceRouter(PrivateGroup) |
| | | } |
| | | return Router |
| | | } |
| | | } |
New file |
| | |
| | | |
| | | package router |
| | | |
| | | import ( |
| | | v1 "aps_crm/api/v1" |
| | | "github.com/gin-gonic/gin" |
| | | ) |
| | | |
| | | type ReportSourceRouter struct{} |
| | | |
| | | func (s *ReportSourceRouter) InitReportSourceRouter(router *gin.RouterGroup) { |
| | | reportSourceRouter := router.Group("reportSource") |
| | | reportSourceApi := v1.ApiGroup.ReportSourceApi |
| | | { |
| | | reportSourceRouter.POST("add", reportSourceApi.Add) // 添加$CName$ |
| | | reportSourceRouter.DELETE("delete/:id", reportSourceApi.Delete) // 删除$CName$ |
| | | reportSourceRouter.PUT("update", reportSourceApi.Update) // 更新$CName$ |
| | | reportSourceRouter.GET("list", reportSourceApi.List) // 获取$CName$列表 |
| | | } |
| | | } |
| | |
| | | isVisitList, _ := ServiceGroup.GetIsVisitList() |
| | | data.IsVisit = isVisitList |
| | | |
| | | // get ReportSource list |
| | | reportSourceList, _ := ServiceGroup.GetReportSourceList() |
| | | data.ReportSource = reportSourceList |
| | | |
| | | |
| | | errCode = ecode.OK |
| | | |
| | | return |
| | | } |
| | | } |
| | |
| | | TimelyRateService |
| | | SolveRateService |
| | | IsVisitService |
| | | ReportSourceService |
| | | } |
| | | |
| | | var ServiceGroup = new(Group) |
| | | var ServiceGroup = new(Group) |
New file |
| | |
| | | |
| | | package service |
| | | |
| | | import ( |
| | | "aps_crm/model" |
| | | "aps_crm/model/request" |
| | | "aps_crm/pkg/ecode" |
| | | ) |
| | | |
| | | type ReportSourceService struct{} |
| | | |
| | | func (ReportSourceService) AddReportSource(reportSource *model.ReportSource) int { |
| | | err := model.NewReportSourceSearch().Create(reportSource) |
| | | if err != nil { |
| | | return ecode.ReportSourceExist |
| | | } |
| | | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (ReportSourceService) DeleteReportSource(id int) int { |
| | | _, err := model.NewReportSourceSearch().SetId(id).Find() |
| | | if err != nil { |
| | | return ecode.ReportSourceNotExist |
| | | } |
| | | |
| | | err = model.NewReportSourceSearch().SetId(id).Delete() |
| | | if err != nil { |
| | | return ecode.ReportSourceNotExist |
| | | } |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (ReportSourceService) GetReportSourceList() ([]*model.ReportSource, int) { |
| | | list, err := model.NewReportSourceSearch().FindAll() |
| | | if err != nil { |
| | | return nil, ecode.ReportSourceListErr |
| | | } |
| | | |
| | | return list, ecode.OK |
| | | } |
| | | |
| | | func (ReportSourceService) UpdateReportSource(reportSources []*request.UpdateReportSource) int { |
| | | for _, v := range reportSources { |
| | | // check reportSource exist |
| | | _, err := model.NewReportSourceSearch().SetId(v.Id).Find() |
| | | if err != nil { |
| | | return ecode.ReportSourceNotExist |
| | | } |
| | | |
| | | err = model.NewReportSourceSearch().SetId(v.Id).Updates(map[string]interface{}{ |
| | | "name": v.Name, |
| | | }) |
| | | if err != nil { |
| | | return ecode.ReportSourceSetErr |
| | | } |
| | | } |
| | | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (ReportSourceService) GetReportSourceDetail(id int) (*model.ReportSource, int) { |
| | | reportSource, err := model.NewReportSourceSearch().SetId(id).Find() |
| | | if err != nil { |
| | | return nil, ecode.ReportSourceNotExist |
| | | } |
| | | |
| | | return reportSource, ecode.OK |
| | | } |