提交 | 用户 | 时间
|
e7c126
|
1 |
package com.iailab.module.system.controller.admin.permission; |
H |
2 |
|
|
3 |
import com.iailab.framework.common.enums.CommonStatusEnum; |
|
4 |
import com.iailab.framework.common.pojo.CommonResult; |
|
5 |
import com.iailab.framework.common.util.object.BeanUtils; |
|
6 |
import com.iailab.module.system.controller.admin.permission.vo.menu.MenuListReqVO; |
|
7 |
import com.iailab.module.system.controller.admin.permission.vo.menu.MenuRespVO; |
|
8 |
import com.iailab.module.system.controller.admin.permission.vo.menu.MenuSaveVO; |
|
9 |
import com.iailab.module.system.controller.admin.permission.vo.menu.MenuSimpleRespVO; |
|
10 |
import com.iailab.module.system.dal.dataobject.permission.MenuDO; |
|
11 |
import com.iailab.module.system.service.permission.MenuService; |
|
12 |
import io.swagger.v3.oas.annotations.Operation; |
|
13 |
import io.swagger.v3.oas.annotations.Parameter; |
|
14 |
import io.swagger.v3.oas.annotations.tags.Tag; |
|
15 |
import org.springframework.security.access.prepost.PreAuthorize; |
|
16 |
import org.springframework.validation.annotation.Validated; |
|
17 |
import org.springframework.web.bind.annotation.*; |
|
18 |
|
|
19 |
import javax.annotation.Resource; |
|
20 |
import javax.validation.Valid; |
|
21 |
import java.util.Comparator; |
|
22 |
import java.util.List; |
|
23 |
|
|
24 |
import static com.iailab.framework.common.pojo.CommonResult.success; |
|
25 |
|
|
26 |
@Tag(name = "管理后台 - 菜单") |
|
27 |
@RestController |
|
28 |
@RequestMapping("/system/menu") |
|
29 |
@Validated |
|
30 |
public class MenuController { |
|
31 |
|
|
32 |
@Resource |
|
33 |
private MenuService menuService; |
|
34 |
|
|
35 |
@PostMapping("/create") |
|
36 |
@Operation(summary = "创建菜单") |
|
37 |
@PreAuthorize("@ss.hasPermission('system:menu:create')") |
|
38 |
public CommonResult<Long> createMenu(@Valid @RequestBody MenuSaveVO createReqVO) { |
|
39 |
Long menuId = menuService.createMenu(createReqVO); |
|
40 |
return success(menuId); |
|
41 |
} |
|
42 |
|
818a01
|
43 |
@PostMapping("/createAppMenu") |
H |
44 |
@Operation(summary = "创建菜单") |
|
45 |
@PreAuthorize("@ss.hasPermission('system:app-menu:create')") |
|
46 |
public CommonResult<Long> createAppMenu(@Valid @RequestBody MenuSaveVO createReqVO) { |
|
47 |
Long menuId = menuService.createMenu(createReqVO); |
|
48 |
return success(menuId); |
|
49 |
} |
|
50 |
|
e7c126
|
51 |
@PutMapping("/update") |
H |
52 |
@Operation(summary = "修改菜单") |
|
53 |
@PreAuthorize("@ss.hasPermission('system:menu:update')") |
|
54 |
public CommonResult<Boolean> updateMenu(@Valid @RequestBody MenuSaveVO updateReqVO) { |
818a01
|
55 |
menuService.updateMenu(updateReqVO); |
H |
56 |
return success(true); |
|
57 |
} |
|
58 |
|
|
59 |
@PutMapping("/updateAppMenu") |
|
60 |
@Operation(summary = "修改菜单") |
|
61 |
@PreAuthorize("@ss.hasPermission('system:app-menu:update')") |
|
62 |
public CommonResult<Boolean> updateAppMenu(@Valid @RequestBody MenuSaveVO updateReqVO) { |
e7c126
|
63 |
menuService.updateMenu(updateReqVO); |
H |
64 |
return success(true); |
|
65 |
} |
|
66 |
|
|
67 |
@DeleteMapping("/delete") |
|
68 |
@Operation(summary = "删除菜单") |
|
69 |
@Parameter(name = "id", description = "菜单编号", required= true, example = "1024") |
|
70 |
@PreAuthorize("@ss.hasPermission('system:menu:delete')") |
|
71 |
public CommonResult<Boolean> deleteMenu(@RequestParam("id") Long id) { |
|
72 |
menuService.deleteMenu(id); |
|
73 |
return success(true); |
|
74 |
} |
|
75 |
|
818a01
|
76 |
@DeleteMapping("/deleteAppMenu") |
H |
77 |
@Operation(summary = "删除菜单") |
|
78 |
@Parameter(name = "id", description = "菜单编号", required= true, example = "1024") |
|
79 |
@PreAuthorize("@ss.hasPermission('system:app-menu:delete')") |
|
80 |
public CommonResult<Boolean> deleteAppMenu(@RequestParam("id") Long id) { |
|
81 |
menuService.deleteMenu(id); |
|
82 |
return success(true); |
|
83 |
} |
|
84 |
|
|
85 |
|
e7c126
|
86 |
@GetMapping("/list") |
H |
87 |
@Operation(summary = "获取菜单列表", description = "用于【菜单管理】界面") |
|
88 |
@PreAuthorize("@ss.hasPermission('system:menu:query')") |
|
89 |
public CommonResult<List<MenuRespVO>> getMenuList(MenuListReqVO reqVO) { |
|
90 |
List<MenuDO> list = menuService.getMenuList(reqVO); |
818a01
|
91 |
list.sort(Comparator.comparing(MenuDO::getSort)); |
H |
92 |
return success(BeanUtils.toBean(list, MenuRespVO.class)); |
|
93 |
} |
|
94 |
|
|
95 |
@GetMapping("/app-menu-list") |
|
96 |
@Operation(summary = "获取应用菜单列表", description = "用于【应用菜单】界面") |
|
97 |
@PreAuthorize("@ss.hasPermission('system:app-menu:query')") |
|
98 |
public CommonResult<List<MenuRespVO>> getAppMenuList(MenuListReqVO reqVO) { |
|
99 |
List<MenuDO> list = menuService.getAppMenuList(reqVO); |
e7c126
|
100 |
list.sort(Comparator.comparing(MenuDO::getSort)); |
H |
101 |
return success(BeanUtils.toBean(list, MenuRespVO.class)); |
|
102 |
} |
|
103 |
|
|
104 |
@GetMapping({"/list-all-simple", "simple-list"}) |
|
105 |
@Operation(summary = "获取菜单精简信息列表", description = "只包含被开启的菜单,用于【角色分配菜单】功能的选项。" + |
|
106 |
"在多租户的场景下,会只返回租户所在套餐有的菜单") |
|
107 |
public CommonResult<List<MenuSimpleRespVO>> getSimpleMenuList() { |
|
108 |
List<MenuDO> list = menuService.getMenuListByTenant( |
|
109 |
new MenuListReqVO().setStatus(CommonStatusEnum.ENABLE.getStatus())); |
|
110 |
list.sort(Comparator.comparing(MenuDO::getSort)); |
|
111 |
return success(BeanUtils.toBean(list, MenuSimpleRespVO.class)); |
|
112 |
} |
|
113 |
|
818a01
|
114 |
@GetMapping({"simple-app-menus"}) |
H |
115 |
@Operation(summary = "获取应用菜单精简信息列表", description = "只包含被开启的菜单,用于【角色分配菜单】功能的选项。" + |
|
116 |
"在多租户的场景下,会只返回租户所在套餐有的菜单") |
|
117 |
public CommonResult<List<MenuSimpleRespVO>> getSimpleAppMenuList() { |
|
118 |
List<MenuDO> list = menuService.getAppMenuListByTenant( |
|
119 |
new MenuListReqVO().setStatus(CommonStatusEnum.ENABLE.getStatus())); |
|
120 |
list.sort(Comparator.comparing(MenuDO::getSort)); |
|
121 |
return success(BeanUtils.toBean(list, MenuSimpleRespVO.class)); |
|
122 |
} |
|
123 |
|
e7c126
|
124 |
@GetMapping("/get") |
H |
125 |
@Operation(summary = "获取菜单信息") |
|
126 |
@PreAuthorize("@ss.hasPermission('system:menu:query')") |
|
127 |
public CommonResult<MenuRespVO> getMenu(Long id) { |
|
128 |
MenuDO menu = menuService.getMenu(id); |
|
129 |
return success(BeanUtils.toBean(menu, MenuRespVO.class)); |
|
130 |
} |
|
131 |
|
818a01
|
132 |
@GetMapping("/getAppMenu") |
H |
133 |
@Operation(summary = "获取菜单信息") |
|
134 |
@PreAuthorize("@ss.hasPermission('system:app-menu:query')") |
|
135 |
public CommonResult<MenuRespVO> getAppMenu(Long id) { |
|
136 |
MenuDO menu = menuService.getMenu(id); |
|
137 |
return success(BeanUtils.toBean(menu, MenuRespVO.class)); |
|
138 |
} |
|
139 |
|
e7c126
|
140 |
} |