lyh
8 小时以前 371365543363969fd3afcc404440c838817ecc3d
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
package com.lxzn.ucenter.controller;
 
import com.lxzn.api.ucenter.ButtonControllerApi;
import com.lxzn.framework.domain.ucenter.Button;
import com.lxzn.framework.domain.ucenter.request.ButtonRequest;
import com.lxzn.framework.model.response.CommonCode;
import com.lxzn.framework.model.response.QueryListResponseResult;
import com.lxzn.framework.model.response.QueryPageResponseResult;
import com.lxzn.framework.model.response.ResponseResult;
import com.lxzn.ucenter.service.IButtonService;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Collections;
import java.util.List;
 
@RestController
@RequestMapping("/ucenter/btn")
public class ButtonController implements ButtonControllerApi {
    @Autowired
    private IButtonService buttonService;
 
    @Override
    @PostMapping("/add")
    public ResponseResult addButton(@RequestBody Button button) {
        boolean b = buttonService.addButton(button);
        if(b) {
            return new ResponseResult(CommonCode.SUCCESS);
        }
        return new ResponseResult(CommonCode.FAIL);
    }
 
    @Override
    @GetMapping("/find/list")
    public QueryListResponseResult<Button> findByButtonType(@RequestParam("buttonType") Integer buttonType) {
        List<Button> list = buttonService.findByButtonType(buttonType);
        if(list == null)
            list = Collections.emptyList();
        return new QueryListResponseResult<>(CommonCode.SUCCESS, list);
    }
 
    @Override
    @GetMapping("/find/page/{page}/{size}")
    public QueryPageResponseResult<Button> findByPageList(@PathVariable("page") int page, @PathVariable("size") int size, ButtonRequest buttonRequest) {
        return buttonService.findByPageList(page, size, buttonRequest);
    }
 
    @Override
    @PutMapping("/edit/{id}")
    public ResponseResult editButton(@PathVariable("id") String id,@RequestBody Button button) {
        boolean b = buttonService.editButton(id,button);
        if(b) {
            return new ResponseResult(CommonCode.SUCCESS);
        }
        return new ResponseResult(CommonCode.FAIL);
    }
 
    @Override
    @DeleteMapping("/delete")
    public ResponseResult deleteButton(@RequestParam("id") String id) {
        boolean b = buttonService.deleteButtonById(id);
        if(b) {
            return new ResponseResult(CommonCode.SUCCESS);
        }
        return new ResponseResult(CommonCode.FAIL);
    }
 
    @Override
    @GetMapping("/get/role")
    public QueryListResponseResult<Button> findPermsByRoleId(@RequestParam("roleId") String roleId) {
        List<Button> list = buttonService.findPermsByRoleId(roleId);
        if(list == null)
            list = Collections.emptyList();
        return new QueryListResponseResult<>(CommonCode.SUCCESS, list);
    }
 
    @Override
    @GetMapping("/get/menu")
    public QueryListResponseResult<Button> findByMenuId(@RequestParam("menuId") String menuId) {
        List<Button> list = buttonService.findByMenuId(menuId);
        if(list == null)
            list = Collections.emptyList();
        return new QueryListResponseResult<>(CommonCode.SUCCESS, list);
    }
 
    @Override
    @GetMapping("/get/object")
    public QueryListResponseResult<Button> findByObjectId(@RequestParam("objectId") String objectId) {
        List<Button> list = buttonService.findByObjectId(objectId);
        if(list == null)
            list = Collections.emptyList();
        return new QueryListResponseResult<>(CommonCode.SUCCESS, list);
    }
 
    @Override
    @GetMapping("/exportXls")
    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
        List<Button> list = buttonService.list();
        //mv.addObject(NormalExcelConstants.FILE_NAME,"导出Excel文件名字");
        //注解对象Class
        mv.addObject(NormalExcelConstants.CLASS,Button.class);
        //自定义导出字段
        //mv.addObject(NormalExcelConstants.EXPORT_FIELDS,"name,keyWord,punchTime");
        //自定义表格参数
        mv.addObject(NormalExcelConstants.PARAMS,new ExportParams("自定义导出Excel模板内容标题", "自定义Sheet名字"));
        //导出数据列表
        mv.addObject(NormalExcelConstants.DATA_LIST,list);
        return mv;
    }
}