add
add
satisfaction 满意度模块
add, Delete, update, list
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 SatisfactionApi struct{} |
| | | |
| | | // Add |
| | | // |
| | | // @Tags Satisfaction |
| | | // @Summary 添加满意度 |
| | | // @Produce application/json |
| | | // @Param object body request.AddSatisfaction true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/satisfaction/add [post] |
| | | func (s *SatisfactionApi) Add(c *gin.Context) { |
| | | var params request.AddSatisfaction |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | satisfaction := new(model.Satisfaction) |
| | | satisfaction.Name = params.Name |
| | | |
| | | errCode := satisfactionService.AddSatisfaction(satisfaction) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // Delete |
| | | // |
| | | // @Tags Satisfaction |
| | | // @Summary 删除满意度 |
| | | // @Produce application/json |
| | | // @Param id path int true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/satisfaction/delete/{id} [delete] |
| | | func (s *SatisfactionApi) Delete(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | id, _ := strconv.Atoi(c.Param("id")) |
| | | errCode := satisfactionService.DeleteSatisfaction(id) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // Update |
| | | // |
| | | // @Tags Satisfaction |
| | | // @Summary 更新满意度 |
| | | // @Produce application/json |
| | | // @Param object body request.UpdateSatisfactions true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/satisfaction/update [put] |
| | | func (s *SatisfactionApi) Update(c *gin.Context) { |
| | | var params request.UpdateSatisfactions |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | errCode := satisfactionService.UpdateSatisfaction(params.Satisfactions) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // List |
| | | // |
| | | // @Tags Satisfaction |
| | | // @Summary 满意度列表 |
| | | // @Produce application/json |
| | | // @Success 200 {object} contextx.Response{data=response.SatisfactionResponse} |
| | | // @Router /api/satisfaction/list [get] |
| | | func (s *SatisfactionApi) List(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | satisfactions, errCode := satisfactionService.GetSatisfactionList() |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.OkWithDetailed(response.SatisfactionResponse{ |
| | | List: satisfactions, |
| | | }) |
| | | } |
| | |
| | | return |
| | | } |
| | | |
| | | code, client := checkClientParams(params.Client) |
| | | if code != ecode.OK { |
| | | ctx.Fail(code) |
| | | return |
| | | } |
| | | |
| | | serviceFeeManage.Client = client |
| | | |
| | | errCode = serviceFeeManageService.AddServiceFeeManage(&serviceFeeManage) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | |
| | | // return ecode.InvalidParams, result |
| | | //} |
| | | |
| | | if serviceFeeManage.MemberId == 0 { |
| | | return ecode.InvalidParams, result |
| | | } |
| | | //if serviceFeeManage.MemberId == 0 { |
| | | // return ecode.InvalidParams, result |
| | | //} |
| | | |
| | | t, err := checkTimeFormat(serviceFeeManage.LatestDate) |
| | | if err != nil { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/satisfaction/add": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "Satisfaction" |
| | | ], |
| | | "summary": "添加满意度", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddSatisfaction" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/satisfaction/delete/{id}": { |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "Satisfaction" |
| | | ], |
| | | "summary": "删除满意度", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "查询参数", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/satisfaction/list": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "Satisfaction" |
| | | ], |
| | | "summary": "满意度列表", |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/response.SatisfactionResponse" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/satisfaction/update": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "Satisfaction" |
| | | ], |
| | | "summary": "更新满意度", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateSatisfactions" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/serviceContract/add": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | "model.MasterOrder": { |
| | | "type": "object", |
| | | "properties": { |
| | | "client": { |
| | | "$ref": "#/definitions/model.Client" |
| | | }, |
| | | "client_id": { |
| | | "type": "integer" |
| | | }, |
| | |
| | | "addressee": { |
| | | "type": "string" |
| | | }, |
| | | "client": { |
| | | "$ref": "#/definitions/model.Client" |
| | | }, |
| | | "clientId": { |
| | | "type": "integer" |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "model.Satisfaction": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "model.ServiceContract": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "model.SubOrder": { |
| | | "type": "object", |
| | | "properties": { |
| | | "client": { |
| | | "$ref": "#/definitions/model.Client" |
| | | }, |
| | | "clientId": { |
| | | "type": "integer" |
| | | }, |
| | |
| | | } |
| | | }, |
| | | "request.AddSalesSources": { |
| | | "type": "object", |
| | | "required": [ |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.AddSatisfaction": { |
| | | "type": "object", |
| | | "required": [ |
| | | "name" |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateSatisfaction": { |
| | | "type": "object", |
| | | "required": [ |
| | | "id", |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateSatisfactions": { |
| | | "type": "object", |
| | | "required": [ |
| | | "satisfactions" |
| | | ], |
| | | "properties": { |
| | | "satisfactions": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/request.UpdateSatisfaction" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateServiceContract": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.SatisfactionResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.Satisfaction" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "response.ServiceContractsResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/satisfaction/add": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "Satisfaction" |
| | | ], |
| | | "summary": "添加满意度", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddSatisfaction" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/satisfaction/delete/{id}": { |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "Satisfaction" |
| | | ], |
| | | "summary": "删除满意度", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "查询参数", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/satisfaction/list": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "Satisfaction" |
| | | ], |
| | | "summary": "满意度列表", |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/response.SatisfactionResponse" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/satisfaction/update": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "Satisfaction" |
| | | ], |
| | | "summary": "更新满意度", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateSatisfactions" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "$ref": "#/definitions/contextx.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api/serviceContract/add": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | "model.MasterOrder": { |
| | | "type": "object", |
| | | "properties": { |
| | | "client": { |
| | | "$ref": "#/definitions/model.Client" |
| | | }, |
| | | "client_id": { |
| | | "type": "integer" |
| | | }, |
| | |
| | | "addressee": { |
| | | "type": "string" |
| | | }, |
| | | "client": { |
| | | "$ref": "#/definitions/model.Client" |
| | | }, |
| | | "clientId": { |
| | | "type": "integer" |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "model.Satisfaction": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "model.ServiceContract": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "model.SubOrder": { |
| | | "type": "object", |
| | | "properties": { |
| | | "client": { |
| | | "$ref": "#/definitions/model.Client" |
| | | }, |
| | | "clientId": { |
| | | "type": "integer" |
| | | }, |
| | |
| | | } |
| | | }, |
| | | "request.AddSalesSources": { |
| | | "type": "object", |
| | | "required": [ |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.AddSatisfaction": { |
| | | "type": "object", |
| | | "required": [ |
| | | "name" |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateSatisfaction": { |
| | | "type": "object", |
| | | "required": [ |
| | | "id", |
| | | "name" |
| | | ], |
| | | "properties": { |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateSatisfactions": { |
| | | "type": "object", |
| | | "required": [ |
| | | "satisfactions" |
| | | ], |
| | | "properties": { |
| | | "satisfactions": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/request.UpdateSatisfaction" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateServiceContract": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.SatisfactionResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | | "list": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/model.Satisfaction" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "response.ServiceContractsResponse": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | type: object |
| | | model.MasterOrder: |
| | | properties: |
| | | client: |
| | | $ref: '#/definitions/model.Client' |
| | | client_id: |
| | | type: integer |
| | | end_time: |
| | |
| | | type: string |
| | | addressee: |
| | | type: string |
| | | client: |
| | | $ref: '#/definitions/model.Client' |
| | | clientId: |
| | | type: integer |
| | | conditions: |
| | |
| | | name: |
| | | type: string |
| | | type: object |
| | | model.Satisfaction: |
| | | properties: |
| | | id: |
| | | type: integer |
| | | name: |
| | | type: string |
| | | type: object |
| | | model.ServiceContract: |
| | | properties: |
| | | clientId: |
| | |
| | | type: object |
| | | model.SubOrder: |
| | | properties: |
| | | client: |
| | | $ref: '#/definitions/model.Client' |
| | | clientId: |
| | | type: integer |
| | | id: |
| | |
| | | $ref: '#/definitions/request.SalesReturn' |
| | | type: object |
| | | request.AddSalesSources: |
| | | properties: |
| | | name: |
| | | type: string |
| | | required: |
| | | - name |
| | | type: object |
| | | request.AddSatisfaction: |
| | | properties: |
| | | name: |
| | | type: string |
| | |
| | | $ref: '#/definitions/request.UpdateSalesSources' |
| | | type: array |
| | | type: object |
| | | request.UpdateSatisfaction: |
| | | properties: |
| | | id: |
| | | type: integer |
| | | name: |
| | | type: string |
| | | required: |
| | | - id |
| | | - name |
| | | type: object |
| | | request.UpdateSatisfactions: |
| | | properties: |
| | | satisfactions: |
| | | items: |
| | | $ref: '#/definitions/request.UpdateSatisfaction' |
| | | type: array |
| | | required: |
| | | - satisfactions |
| | | type: object |
| | | request.UpdateServiceContract: |
| | | properties: |
| | | clientId: |
| | |
| | | list: |
| | | items: |
| | | $ref: '#/definitions/model.SalesSources' |
| | | type: array |
| | | type: object |
| | | response.SatisfactionResponse: |
| | | properties: |
| | | list: |
| | | items: |
| | | $ref: '#/definitions/model.Satisfaction' |
| | | type: array |
| | | type: object |
| | | response.ServiceContractsResponse: |
| | |
| | | summary: 更新商机来源 |
| | | tags: |
| | | - SalesSources |
| | | /api/satisfaction/add: |
| | | post: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.AddSatisfaction' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 添加满意度 |
| | | tags: |
| | | - Satisfaction |
| | | /api/satisfaction/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: |
| | | - Satisfaction |
| | | /api/satisfaction/list: |
| | | get: |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | allOf: |
| | | - $ref: '#/definitions/contextx.Response' |
| | | - properties: |
| | | data: |
| | | $ref: '#/definitions/response.SatisfactionResponse' |
| | | type: object |
| | | summary: 满意度列表 |
| | | tags: |
| | | - Satisfaction |
| | | /api/satisfaction/update: |
| | | put: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.UpdateSatisfactions' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | $ref: '#/definitions/contextx.Response' |
| | | summary: 更新满意度 |
| | | tags: |
| | | - Satisfaction |
| | | /api/serviceContract/add: |
| | | post: |
| | | parameters: |
| | |
| | | Authority{}, |
| | | Api{}, |
| | | Department{}, |
| | | Satisfaction{}, |
| | | ) |
| | | return err |
| | | } |
New file |
| | |
| | | package request |
| | | |
| | | type AddSatisfaction struct { |
| | | Name string `json:"name" binding:"required"` |
| | | } |
| | | |
| | | type UpdateSatisfaction struct { |
| | | Id int `json:"id" binding:"required"` |
| | | Name string `json:"name" binding:"required"` |
| | | } |
| | | |
| | | type UpdateSatisfactions struct { |
| | | Satisfactions []*UpdateSatisfaction `json:"satisfactions" binding:"required"` |
| | | } |
| | |
| | | DepartmentResponse struct { |
| | | List []*model.Department `json:"list"` |
| | | } |
| | | |
| | | SatisfactionResponse struct { |
| | | List []*model.Satisfaction `json:"list"` |
| | | } |
| | | ) |
New file |
| | |
| | | package model |
| | | |
| | | import ( |
| | | "aps_crm/pkg/mysqlx" |
| | | "gorm.io/gorm" |
| | | ) |
| | | |
| | | type ( |
| | | Satisfaction struct { |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | Name string `json:"name" gorm:"column:name;type:varchar(255);comment:满意度名称"` |
| | | } |
| | | |
| | | SatisfactionSearch struct { |
| | | Satisfaction |
| | | Orm *gorm.DB |
| | | } |
| | | ) |
| | | |
| | | func (Satisfaction) TableName() string { |
| | | return "satisfaction" |
| | | } |
| | | |
| | | func NewSatisfactionSearch() *SatisfactionSearch { |
| | | return &SatisfactionSearch{ |
| | | Orm: mysqlx.GetDB(), |
| | | } |
| | | } |
| | | |
| | | func (slf *SatisfactionSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&Satisfaction{}) |
| | | if slf.Id != 0 { |
| | | db = db.Where("id = ?", slf.Id) |
| | | } |
| | | if slf.Name != "" { |
| | | db = db.Where("name = ?", slf.Name) |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |
| | | func (slf *SatisfactionSearch) Create(record *Satisfaction) error { |
| | | var db = slf.build() |
| | | return db.Create(record).Error |
| | | } |
| | | |
| | | func (slf *SatisfactionSearch) Delete() error { |
| | | var db = slf.build() |
| | | return db.Delete(&Satisfaction{}).Error |
| | | } |
| | | |
| | | func (slf *SatisfactionSearch) Update(record *Satisfaction) error { |
| | | var db = slf.build() |
| | | return db.Updates(record).Error |
| | | } |
| | | |
| | | func (slf *SatisfactionSearch) Find() (*Satisfaction, error) { |
| | | var db = slf.build() |
| | | var record = new(Satisfaction) |
| | | err := db.First(record).Error |
| | | return record, err |
| | | } |
| | | |
| | | func (slf *SatisfactionSearch) FindAll() ([]*Satisfaction, error) { |
| | | var db = slf.build() |
| | | var records = make([]*Satisfaction, 0) |
| | | err := db.Find(&records).Error |
| | | return records, err |
| | | } |
| | | |
| | | func (slf *SatisfactionSearch) SetId(id int) *SatisfactionSearch { |
| | | slf.Id = id |
| | | return slf |
| | | } |
| | | |
| | | func (slf *SatisfactionSearch) Updates(data map[string]interface{}) error { |
| | | var db = slf.build() |
| | | return db.Updates(data).Error |
| | | } |
| | |
| | | VettingListErr = 4100003 // 获取审批列表失败 |
| | | VettingSetErr = 4100004 // 设置审批失败 |
| | | |
| | | SatisfactionExist = 4200001 // 满意度已存在 |
| | | SatisfactionNotExist = 4200002 // 满意度不存在 |
| | | SatisfactionListErr = 4200003 // 获取满意度列表失败 |
| | | SatisfactionSetErr = 4200004 // 设置满意度失败 |
| | | SatisfactionUpdateErr = 4200005 // 更新满意度失败 |
| | | ) |
| | |
| | | MenuRouter |
| | | DataRouter |
| | | DepartmentRouter |
| | | SatisfactionRouter |
| | | } |
| | | |
| | | func InitRouter() *gin.Engine { |
| | |
| | | routerGroup.InitMenuRouter(PrivateGroup) // 注册menu路由 |
| | | routerGroup.InitDataRouter(PrivateGroup) // 注册data路由 |
| | | routerGroup.InitDepartmentRouter(PrivateGroup) // 注册department路由 |
| | | routerGroup.InitSatisfactionRouter(PrivateGroup) // 注册satisfaction路由 |
| | | } |
| | | return Router |
| | | } |
New file |
| | |
| | | package router |
| | | |
| | | import ( |
| | | v1 "aps_crm/api/v1" |
| | | "github.com/gin-gonic/gin" |
| | | ) |
| | | |
| | | type SatisfactionRouter struct{} |
| | | |
| | | func (s *SatisfactionRouter) InitSatisfactionRouter(router *gin.RouterGroup) { |
| | | satisfactionRouter := router.Group("satisfaction") |
| | | satisfactionApi := v1.ApiGroup.SatisfactionApi |
| | | { |
| | | satisfactionRouter.POST("add", satisfactionApi.Add) // 添加满意度 |
| | | satisfactionRouter.DELETE("delete/:id", satisfactionApi.Delete) // 删除满意度 |
| | | satisfactionRouter.PUT("update", satisfactionApi.Update) // 更新满意度 |
| | | satisfactionRouter.GET("list", satisfactionApi.List) // 获取满意度列表 |
| | | } |
| | | } |
| | |
| | | DataServer |
| | | DepartmentService |
| | | VettingService |
| | | SatisfactionService |
| | | } |
| | | |
| | | var ServiceGroup = new(Group) |
New file |
| | |
| | | package service |
| | | |
| | | import ( |
| | | "aps_crm/model" |
| | | "aps_crm/model/request" |
| | | "aps_crm/pkg/ecode" |
| | | ) |
| | | |
| | | type SatisfactionService struct{} |
| | | |
| | | func (SatisfactionService) AddSatisfaction(satisfaction *model.Satisfaction) int { |
| | | err := model.NewSatisfactionSearch().Create(satisfaction) |
| | | if err != nil { |
| | | return ecode.SatisfactionExist |
| | | } |
| | | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (SatisfactionService) DeleteSatisfaction(id int) int { |
| | | _, err := model.NewSatisfactionSearch().SetId(id).Find() |
| | | if err != nil { |
| | | return ecode.SatisfactionNotExist |
| | | } |
| | | |
| | | err = model.NewSatisfactionSearch().SetId(id).Delete() |
| | | if err != nil { |
| | | return ecode.SatisfactionNotExist |
| | | } |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (SatisfactionService) GetSatisfactionList() ([]*model.Satisfaction, int) { |
| | | list, err := model.NewSatisfactionSearch().FindAll() |
| | | if err != nil { |
| | | return nil, ecode.SatisfactionListErr |
| | | } |
| | | |
| | | return list, ecode.OK |
| | | } |
| | | |
| | | func (SatisfactionService) UpdateSatisfaction(satisfactions []*request.UpdateSatisfaction) int { |
| | | for _, v := range satisfactions { |
| | | // check satisfaction exist |
| | | _, err := model.NewSatisfactionSearch().SetId(v.Id).Find() |
| | | if err != nil { |
| | | return ecode.SatisfactionNotExist |
| | | } |
| | | |
| | | err = model.NewSatisfactionSearch().SetId(v.Id).Updates(map[string]interface{}{ |
| | | "name": v.Name, |
| | | }) |
| | | if err != nil { |
| | | return ecode.SatisfactionSetErr |
| | | } |
| | | } |
| | | |
| | | return ecode.OK |
| | | } |