add
OrderType 工单类型模块
add, Delete, update, list
| | |
| | | ) |
| | | |
| | | type Group struct { |
| | | OrderTypeApi |
| | | ReportSourceApi |
| | | IsVisitApi |
| | | SolveRateApi |
| | |
| | | solveRateService = service.ServiceGroup.SolveRateService |
| | | isVisitService = service.ServiceGroup.IsVisitService |
| | | reportSourceService = service.ServiceGroup.ReportSourceService |
| | | orderTypeService = service.ServiceGroup.OrderTypeService |
| | | ) |
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 OrderTypeApi struct{} |
| | | |
| | | // Add |
| | | // |
| | | // @Tags OrderType |
| | | // @Summary 添加工单类型 |
| | | // @Produce application/json |
| | | // @Param object body request.AddOrderType true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/orderType/add [post] |
| | | func (s *OrderTypeApi) Add(c *gin.Context) { |
| | | var params request.AddOrderType |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | orderType := new(model.OrderType) |
| | | orderType.Name = params.Name |
| | | |
| | | errCode := orderTypeService.AddOrderType(orderType) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // Delete |
| | | // |
| | | // @Tags OrderType |
| | | // @Summary 删除工单类型 |
| | | // @Produce application/json |
| | | // @Param id path int true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/orderType/delete/{id} [delete] |
| | | func (s *OrderTypeApi) Delete(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | id, _ := strconv.Atoi(c.Param("id")) |
| | | errCode := orderTypeService.DeleteOrderType(id) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // Update |
| | | // |
| | | // @Tags OrderType |
| | | // @Summary 更新工单类型 |
| | | // @Produce application/json |
| | | // @Param object body request.UpdateOrderTypes true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/orderType/update [put] |
| | | func (s *OrderTypeApi) Update(c *gin.Context) { |
| | | var params request.UpdateOrderTypes |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | errCode := orderTypeService.UpdateOrderType(params.OrderTypes) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // List |
| | | // |
| | | // @Tags OrderType |
| | | // @Summary 获取工单类型列表 |
| | | // @Produce application/json |
| | | // @Success 200 {object} contextx.Response{data=response.OrderTypeResponse} |
| | | // @Router /api/orderType/list [get] |
| | | func (s *OrderTypeApi) List(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | orderTypes, errCode := orderTypeService.GetOrderTypeList() |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.OkWithDetailed(response.OrderTypeResponse{ |
| | | List: orderTypes, |
| | | }) |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/orderType/add": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "OrderType" |
| | | ], |
| | | "summary": "添加工单类型", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddOrderType" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/orderType/delete/{id}": { |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "OrderType" |
| | | ], |
| | | "summary": "删除工单类型", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "查询参数", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/orderType/list": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "OrderType" |
| | | ], |
| | | "summary": "获取工单类型列表", |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/response.OrderTypeResponse" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/orderType/update": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "OrderType" |
| | | ], |
| | | "summary": "更新工单类型", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateOrderTypes" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/plan/add": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | } |
| | | } |
| | | }, |
| | | "model.OrderType": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "model.Plan": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | }, |
| | | "sourceSheet": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "request.AddOrderType": { |
| | | "type": "object", |
| | | "required": [ |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateOrderType": { |
| | | "type": "object", |
| | | "required": [ |
| | | "id", |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateOrderTypes": { |
| | | "type": "object", |
| | | "required": [ |
| | | "order_type" |
| | | ], |
| | | "properties": { |
| | | "order_type": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/request.UpdateOrderType" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdatePlan": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "$ref": "#/definitions/model.User" |
| | | } |
| | | }, |
| | | "orderType": { |
| | | "description": "工单类型", |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.OrderType" |
| | | } |
| | | }, |
| | | "province": { |
| | | "description": "省份数据", |
| | | "type": "array", |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.OrderTypeResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.OrderType" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "response.PageResult": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/orderType/add": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "OrderType" |
| | | ], |
| | | "summary": "添加工单类型", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddOrderType" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/orderType/delete/{id}": { |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "OrderType" |
| | | ], |
| | | "summary": "删除工单类型", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "查询参数", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/orderType/list": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "OrderType" |
| | | ], |
| | | "summary": "获取工单类型列表", |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/response.OrderTypeResponse" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/orderType/update": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "OrderType" |
| | | ], |
| | | "summary": "更新工单类型", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateOrderTypes" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/plan/add": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | } |
| | | } |
| | | }, |
| | | "model.OrderType": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "model.Plan": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | }, |
| | | "sourceSheet": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "request.AddOrderType": { |
| | | "type": "object", |
| | | "required": [ |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateOrderType": { |
| | | "type": "object", |
| | | "required": [ |
| | | "id", |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateOrderTypes": { |
| | | "type": "object", |
| | | "required": [ |
| | | "order_type" |
| | | ], |
| | | "properties": { |
| | | "order_type": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/request.UpdateOrderType" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdatePlan": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "$ref": "#/definitions/model.User" |
| | | } |
| | | }, |
| | | "orderType": { |
| | | "description": "工单类型", |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.OrderType" |
| | | } |
| | | }, |
| | | "province": { |
| | | "description": "省份数据", |
| | | "type": "array", |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.OrderTypeResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.OrderType" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "response.PageResult": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | title: |
| | | type: string |
| | | type: object |
| | | model.OrderType: |
| | | properties: |
| | | id: |
| | | type: integer |
| | | name: |
| | | type: string |
| | | type: object |
| | | model.Plan: |
| | | properties: |
| | | clientId: |
| | |
| | | type: integer |
| | | sourceSheet: |
| | | type: integer |
| | | type: object |
| | | request.AddOrderType: |
| | | properties: |
| | | name: |
| | | type: string |
| | | required: |
| | | - name |
| | | type: object |
| | | request.AddPlan: |
| | | properties: |
| | |
| | | sourceSheet: |
| | | type: integer |
| | | type: object |
| | | request.UpdateOrderType: |
| | | properties: |
| | | id: |
| | | type: integer |
| | | name: |
| | | type: string |
| | | required: |
| | | - id |
| | | - name |
| | | type: object |
| | | request.UpdateOrderTypes: |
| | | properties: |
| | | order_type: |
| | | items: |
| | | $ref: '#/definitions/request.UpdateOrderType' |
| | | type: array |
| | | required: |
| | | - order_type |
| | | type: object |
| | | request.UpdatePlan: |
| | | properties: |
| | | id: |
| | |
| | | items: |
| | | $ref: '#/definitions/model.User' |
| | | type: array |
| | | orderType: |
| | | description: 工单类型 |
| | | items: |
| | | $ref: '#/definitions/model.OrderType' |
| | | type: array |
| | | province: |
| | | description: 省份数据 |
| | | items: |
| | |
| | | list: |
| | | items: |
| | | $ref: '#/definitions/model.Menu' |
| | | type: array |
| | | type: object |
| | | response.OrderTypeResponse: |
| | | properties: |
| | | list: |
| | | items: |
| | | $ref: '#/definitions/model.OrderType' |
| | | type: array |
| | | type: object |
| | | response.PageResult: |
| | |
| | | summary: 更新工单 |
| | | tags: |
| | | - OrderManage |
| | | /api/orderType/add: |
| | | post: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.AddOrderType' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 添加工单类型 |
| | | tags: |
| | | - OrderType |
| | | /api/orderType/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: |
| | | - OrderType |
| | | /api/orderType/list: |
| | | get: |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | allOf: |
| | | - $ref: '#/definitions/contextx.Response' |
| | | - properties: |
| | | data: |
| | | $ref: '#/definitions/response.OrderTypeResponse' |
| | | type: object |
| | | summary: 获取工单类型列表 |
| | | tags: |
| | | - OrderType |
| | | /api/orderType/update: |
| | | put: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.UpdateOrderTypes' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 更新工单类型 |
| | | tags: |
| | | - OrderType |
| | | /api/plan/add: |
| | | post: |
| | | parameters: |
| | |
| | | IsVisit{}, |
| | | IsVisit{}, |
| | | ReportSource{}, |
| | | OrderType{}, |
| | | ) |
| | | return err |
| | | } |
New file |
| | |
| | | package model |
| | | |
| | | import ( |
| | | "aps_crm/pkg/mysqlx" |
| | | "gorm.io/gorm" |
| | | ) |
| | | |
| | | type ( |
| | | // OrderType 商机阶段 |
| | | OrderType struct { |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | Name string `json:"name" gorm:"column:name;type:varchar(255);comment:商机阶段名称"` |
| | | } |
| | | |
| | | OrderTypeSearch struct { |
| | | OrderType |
| | | Orm *gorm.DB |
| | | } |
| | | ) |
| | | |
| | | func (OrderType) TableName() string { |
| | | return "order_type" |
| | | } |
| | | |
| | | func NewOrderTypeSearch() *OrderTypeSearch { |
| | | return &OrderTypeSearch{ |
| | | Orm: mysqlx.GetDB(), |
| | | } |
| | | } |
| | | |
| | | func (slf *OrderTypeSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&OrderType{}) |
| | | if slf.Id != 0 { |
| | | db = db.Where("id = ?", slf.Id) |
| | | } |
| | | if slf.Name != "" { |
| | | db = db.Where("name = ?", slf.Name) |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |
| | | func (slf *OrderTypeSearch) Create(record *OrderType) error { |
| | | var db = slf.build() |
| | | return db.Create(record).Error |
| | | } |
| | | |
| | | func (slf *OrderTypeSearch) Delete() error { |
| | | var db = slf.build() |
| | | return db.Delete(&OrderType{}).Error |
| | | } |
| | | |
| | | func (slf *OrderTypeSearch) Update(record *OrderType) error { |
| | | var db = slf.build() |
| | | return db.Updates(record).Error |
| | | } |
| | | |
| | | func (slf *OrderTypeSearch) Find() (*OrderType, error) { |
| | | var db = slf.build() |
| | | var record = new(OrderType) |
| | | err := db.First(record).Error |
| | | return record, err |
| | | } |
| | | |
| | | func (slf *OrderTypeSearch) FindAll() ([]*OrderType, error) { |
| | | var db = slf.build() |
| | | var records = make([]*OrderType, 0) |
| | | err := db.Find(&records).Error |
| | | return records, err |
| | | } |
| | | |
| | | func (slf *OrderTypeSearch) SetId(id int) *OrderTypeSearch { |
| | | slf.Id = id |
| | | return slf |
| | | } |
| | | |
| | | func (slf *OrderTypeSearch) SetName(name string) *OrderTypeSearch { |
| | | slf.Name = name |
| | | return slf |
| | | } |
| | | |
| | | func (slf *OrderTypeSearch) Updates(data map[string]interface{}) error { |
| | | var db = slf.build() |
| | | return db.Updates(data).Error |
| | | } |
New file |
| | |
| | | |
| | | package request |
| | | |
| | | type AddOrderType struct { |
| | | Name string ` json:"name" binding:"required"` |
| | | } |
| | | |
| | | type UpdateOrderType struct { |
| | | Id int `json:"id" binding:"required"` |
| | | Name string `json:"name" binding:"required"` |
| | | } |
| | | |
| | | type UpdateOrderTypes struct { |
| | | OrderTypes []*UpdateOrderType `json:"order_type" binding:"required"` |
| | | } |
| | |
| | | |
| | | DataResponse struct { |
| | | |
| | | // 工单类型 |
| | | OrderType []*model.OrderType `json:"orderType"` |
| | | |
| | | |
| | | // 报表来源 |
| | | ReportSource []*model.ReportSource `json:"reportSource"` |
| | | |
| | |
| | | ReportSourceResponse struct { |
| | | List []*model.ReportSource `json:"list"` |
| | | } |
| | | |
| | | OrderTypeResponse struct { |
| | | List []*model.OrderType `json:"list"` |
| | | } |
| | | ) |
| | |
| | | IsVisitSetErr = 4500004 // 设置服务人员是否来过失败 |
| | | IsVisitUpdateErr = 4500005 // 更新服务人员是否来过失败 |
| | | |
| | | ReportSourceExist = 4600001 // 报表来源已存在 |
| | | ReportSourceNotExist = 4600002 // 报表来源不存在 |
| | | ReportSourceListErr = 4600003 // 获取报表来源列表失败 |
| | | ReportSourceSetErr = 4600004 // 设置报表来源失败 |
| | | ReportSourceUpdateErr = 4600005 // 更新报表来源失败 |
| | | |
| | | ReportSourceExist = 4400001 // 报表来源已存在 |
| | | ReportSourceNotExist = 4400002 // 报表来源不存在 |
| | | ReportSourceListErr = 4400003 // 获取报表来源列表失败 |
| | | ReportSourceSetErr = 4400004 // 设置报表来源失败 |
| | | ReportSourceUpdateErr = 4400005 // 更新报表来源失败 |
| | | OrderTypeExist = 4700001 // 工单类型已存在 |
| | | OrderTypeNotExist = 4700002 // 工单类型不存在 |
| | | OrderTypeListErr = 4700003 // 获取工单类型列表失败 |
| | | OrderTypeSetErr = 4700004 // 设置工单类型失败 |
| | | OrderTypeUpdateErr = 4700005 // 更新工单类型失败 |
| | | |
| | | ) |
| | | ) |
| | |
| | | ) |
| | | |
| | | type Group struct { |
| | | OrderTypeRouter |
| | | ReportSourceRouter |
| | | IsVisitRouter |
| | | SolveRateRouter |
| | |
| | | routerGroup.InitSolveRateRouter(PrivateGroup) |
| | | routerGroup.InitIsVisitRouter(PrivateGroup) |
| | | routerGroup.InitReportSourceRouter(PrivateGroup) |
| | | routerGroup.InitOrderTypeRouter(PrivateGroup) |
| | | } |
| | | return Router |
| | | } |
New file |
| | |
| | | |
| | | package router |
| | | |
| | | import ( |
| | | v1 "aps_crm/api/v1" |
| | | "github.com/gin-gonic/gin" |
| | | ) |
| | | |
| | | type OrderTypeRouter struct{} |
| | | |
| | | func (s *OrderTypeRouter) InitOrderTypeRouter(router *gin.RouterGroup) { |
| | | orderTypeRouter := router.Group("orderType") |
| | | orderTypeApi := v1.ApiGroup.OrderTypeApi |
| | | { |
| | | orderTypeRouter.POST("add", orderTypeApi.Add) // 添加$CName$ |
| | | orderTypeRouter.DELETE("delete/:id", orderTypeApi.Delete) // 删除$CName$ |
| | | orderTypeRouter.PUT("update", orderTypeApi.Update) // 更新$CName$ |
| | | orderTypeRouter.GET("list", orderTypeApi.List) // 获取$CName$列表 |
| | | } |
| | | } |
| | |
| | | data.ReportSource = reportSourceList |
| | | |
| | | |
| | | // get OrderType list |
| | | orderTypeList, _ := ServiceGroup.GetOrderTypeList() |
| | | data.OrderType = orderTypeList |
| | | |
| | | |
| | | errCode = ecode.OK |
| | | |
| | | return |
| | |
| | | SolveRateService |
| | | IsVisitService |
| | | ReportSourceService |
| | | OrderTypeService |
| | | } |
| | | |
| | | var ServiceGroup = new(Group) |
New file |
| | |
| | | |
| | | package service |
| | | |
| | | import ( |
| | | "aps_crm/model" |
| | | "aps_crm/model/request" |
| | | "aps_crm/pkg/ecode" |
| | | ) |
| | | |
| | | type OrderTypeService struct{} |
| | | |
| | | func (OrderTypeService) AddOrderType(orderType *model.OrderType) int { |
| | | err := model.NewOrderTypeSearch().Create(orderType) |
| | | if err != nil { |
| | | return ecode.OrderTypeExist |
| | | } |
| | | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (OrderTypeService) DeleteOrderType(id int) int { |
| | | _, err := model.NewOrderTypeSearch().SetId(id).Find() |
| | | if err != nil { |
| | | return ecode.OrderTypeNotExist |
| | | } |
| | | |
| | | err = model.NewOrderTypeSearch().SetId(id).Delete() |
| | | if err != nil { |
| | | return ecode.OrderTypeNotExist |
| | | } |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (OrderTypeService) GetOrderTypeList() ([]*model.OrderType, int) { |
| | | list, err := model.NewOrderTypeSearch().FindAll() |
| | | if err != nil { |
| | | return nil, ecode.OrderTypeListErr |
| | | } |
| | | |
| | | return list, ecode.OK |
| | | } |
| | | |
| | | func (OrderTypeService) UpdateOrderType(orderTypes []*request.UpdateOrderType) int { |
| | | for _, v := range orderTypes { |
| | | // check orderType exist |
| | | _, err := model.NewOrderTypeSearch().SetId(v.Id).Find() |
| | | if err != nil { |
| | | return ecode.OrderTypeNotExist |
| | | } |
| | | |
| | | err = model.NewOrderTypeSearch().SetId(v.Id).Updates(map[string]interface{}{ |
| | | "name": v.Name, |
| | | }) |
| | | if err != nil { |
| | | return ecode.OrderTypeSetErr |
| | | } |
| | | } |
| | | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (OrderTypeService) GetOrderTypeDetail(id int) (*model.OrderType, int) { |
| | | orderType, err := model.NewOrderTypeSearch().SetId(id).Find() |
| | | if err != nil { |
| | | return nil, ecode.OrderTypeNotExist |
| | | } |
| | | |
| | | return orderType, ecode.OK |
| | | } |