forked from kidgrow-microservices-platform

zhaoxiaohao
2020-05-22 f21c78ae0e3c410c6ba5be77277b5b491aca3af1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
package com.kidgrow.oprationcenter.controller;
 
import com.kidgrow.common.controller.BaseController;
import com.kidgrow.common.model.PageResult;
import com.kidgrow.common.model.ResultBody;
import com.kidgrow.oprationcenter.model.SysFeedback;
import com.kidgrow.oprationcenter.service.ISysFeedbackService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.ObjectError;
import org.springframework.web.bind.annotation.*;
 
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
 
 
/**
 * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br>
 * @Description: 
 * @Project: 运营中心
 * @CreateDate: Created in 2020-04-02 18:25:34 <br>
 * @Author: <a href="4345453@kidgrow.com">liuke</a>
 * @version: 1.0
 */
@Slf4j
@RestController
@RequestMapping("/sysfeedback")
@Api(tags = "")
public class SysFeedbackController  extends BaseController{
    @Autowired
    private ISysFeedbackService sysFeedbackService;
 
    /**
     * 列表
     */
    @ApiOperation(value = "查询列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "分页起始位置", required = true, dataType = "Integer"),
            @ApiImplicitParam(name = "limit", value = "分页结束位置", required = true, dataType = "Integer")
    })
    @GetMapping
    public PageResult list(@RequestParam Map<String, Object> params) {
        if(params.size()==0){
            params.put("page",1);
            params.put("limit",10);
        }
        return sysFeedbackService.findList(params);
    }
 
    /**
     * 查询
     */
    @ApiOperation(value = "查询")
    @GetMapping("/{id}")
    public ResultBody findById(@PathVariable Long id) {
        SysFeedback model = sysFeedbackService.getById(id);
        return ResultBody.ok().data(model).msg("查询成功");
    }
 
    /**
     * 根据SysFeedback当做查询条件进行查询
     */
    @ApiOperation(value = "根据SysFeedback当做查询条件进行查询")
    @PostMapping("/query")
    public ResultBody findByObject(@RequestBody SysFeedback sysFeedback) {
        SysFeedback model = sysFeedbackService.findByObject(sysFeedback);
        return ResultBody.ok().data(model).msg("查询成功");
    }
 
    /**
     * 新增or更新
     */
    @ApiOperation(value = "保存")
    @PostMapping
    public ResultBody save(@Valid @RequestBody SysFeedback sysFeedback, BindingResult bindingResult) {
        List<String> errMsg= new ArrayList<>();
        if (bindingResult.hasErrors()) {
            for (ObjectError error : bindingResult.getAllErrors()) {
                errMsg.add(error.getDefaultMessage());
            }
            return ResultBody.failed().msg(errMsg.toString());
        }  else {
            boolean v= sysFeedbackService.saveOrUpdate(sysFeedback);
            if(v) {
                return ResultBody.ok().data(sysFeedback).msg("保存成功");
            }
            else {
                return ResultBody.failed().msg("保存失败");
            }
        }
    }
 
    /**
     * 删除
     */
    @ApiOperation(value = "删除")
    @DeleteMapping("/{id}")
    public ResultBody delete(@PathVariable Long id) {
        boolean v= sysFeedbackService.removeById(id);
        if(v) {
            return ResultBody.ok().msg("删除成功");
        }
        else {
            return ResultBody.failed().msg("删除失败");
        }
    }
    /**
     * 修改状态
     *
     * @param params
     * @return
     */
    @ApiOperation(value = "修改反馈数据状态")
    @GetMapping("/updateEnabled")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Integer"),
            @ApiImplicitParam(name = "enabled", value = "是否启用", required = true, dataType = "Boolean")
    })
    public ResultBody updateEnabled(@RequestParam Map<String, Object> params) {
        if (params.size()==0)
        {
            return ResultBody.failed().msg("参数异常!");
        }
        return sysFeedbackService.updateEnabled(params);
    }
    @PostMapping("getDoctor")
    public ResultBody getoneee(){
        return sysFeedbackService.getoneee();
    }
 
}