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
package com.govmade.modules.system.controller;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.govmade.common.utils.PageTreeUtils;
import com.govmade.common.utils.R;
import com.govmade.common.validator.Assert;
import com.govmade.modules.basic.controller.AbstractController;
import com.govmade.modules.system.entity.MenuEntity;
import com.govmade.modules.system.service.MenuService;
/**
* 系统管理 - 菜单设置
*
* @author Fred
* @email fangtaosh@qq.com
* @date 2018年8月3日
*/
@RestController
@RequestMapping("/system/menu")
public class MenuController extends AbstractController {
@Autowired
private MenuService menuService;
/**
* 所有菜单数据树结构
*/
@GetMapping("/listTree")
public R listTree(@RequestParam Map<String, Object> params) {
PageTreeUtils page = menuService.queryPage(params);
return R.ok().put("page", page);
}
@GetMapping("/menuList")
public R queryMenuList() {
List<MenuEntity> queryMenuList=menuService.queryMenuList();
return R.ok().put("data", queryMenuList);
}
/**
* 保存或更新菜单
*/
@PostMapping("/save")
public R save(MenuEntity menu) {
if (null == menu.getId()) {
if (this.menuService.checkMenu(menu.getName()) > 0) {
return R.error(menu.getName() + " 已存在!");
}
}
menuService.save(menu);
return R.ok();
}
/**
* 根据ID查询菜单
*
* @param id
* @return
*/
@GetMapping("info/{id}")
public R info(@PathVariable("id") Long id) {
return R.ok().put("menu", menuService.queryById(id));
}
/**
* 批量删除菜单
*
* @param ids
* @return
*/
@DeleteMapping("/delete")
public R deleteMenu(@RequestBody Set<Long> ids) {
Assert.isNull(ids, "删除项不能为空");
menuService.deleteBatch(ids);
return R.ok();
}
}