lyh
5 天以前 fda571324684bc8d0945b3e2841305b1207fc3e9
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
package com.lxzn.ucenter.controller;
 
import com.lxzn.api.ucenter.MenuControllerApi;
import com.lxzn.framework.domain.ucenter.Button;
import com.lxzn.framework.domain.ucenter.Menu;
import com.lxzn.framework.domain.ucenter.ext.MenuExt;
import com.lxzn.framework.domain.ucenter.request.MenuRequest;
import com.lxzn.framework.model.response.*;
import com.lxzn.ucenter.service.IMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.Collections;
import java.util.List;
 
@RestController
@RequestMapping("/ucenter/menu")
public class MenuController implements MenuControllerApi {
    @Autowired
    private IMenuService menuService;
 
    @Override
    @PostMapping("/add")
    public ResponseResult addMenu(@RequestBody Menu menu) {
        boolean b = menuService.addMenu(menu);
        if(b) {
            return new ResponseResult(CommonCode.SUCCESS);
        }
        return new ResponseResult(CommonCode.FAIL);
    }
 
    @Override
    @PutMapping("/edit/{id}")
    public ResponseResult editMenu(@PathVariable("id") String id,@RequestBody Menu menu) {
        boolean b = menuService.editMenu(id,menu);
        if(b) {
            return new ResponseResult(CommonCode.SUCCESS);
        }
        return new ResponseResult(CommonCode.FAIL);
    }
 
    @Override
    @DeleteMapping("/delete")
    public ResponseResult deleteMenu(@RequestParam("id") String id) {
        boolean b = menuService.deleteMenuById(id);
        if(b) {
            return new ResponseResult(CommonCode.SUCCESS);
        }
        return new ResponseResult(CommonCode.FAIL);
    }
 
    @Override
    @GetMapping("/find/page/{page}/{size}")
    public QueryPageResponseResult<Menu> findPageList(@PathVariable("page") int page,@PathVariable("size") int size, MenuRequest menuRequest) {
        return menuService.findPageList(page,size,menuRequest);
    }
 
    @Override
    @PostMapping("/assign/button/{menuId}")
    public ResponseResult assignButton(@PathVariable("menuId") String menuId, @RequestBody List<Button> buttonList) {
        boolean b = menuService.assignButton(menuId, buttonList);
        if(b) {
            return new ResponseResult(CommonCode.SUCCESS);
        }
        return new ResponseResult(CommonCode.FAIL);
    }
 
    @Override
    @GetMapping("/find/all")
    public QueryListResponseResult<MenuExt> findAll() {
        List<MenuExt> menuExtList = menuService.findAll();
        if(menuExtList == null)
            menuExtList = Collections.emptyList();
        return new QueryListResponseResult(CommonCode.SUCCESS, menuExtList);
    }
 
    @Override
    @GetMapping("/find/list/all")
    public QueryListResponseResult<Menu> findListAll() {
        List<Menu> menuList = menuService.list();
        if(menuList == null)
            menuList = Collections.emptyList();
        return new QueryListResponseResult(CommonCode.SUCCESS, menuList);
    }
 
    @Override
    @GetMapping("/load/tree")
    public QueryListResponseResult<CommonJsonTree> loadTree() {
        List<CommonJsonTree> tree = menuService.loadTree();
        if(tree == null)
            tree = Collections.emptyList();
        return new QueryListResponseResult(CommonCode.SUCCESS, tree);
    }
 
}