|
|
@@ -1,12 +1,19 @@
|
|
|
package cn.reghao.devops.mgr.admin.controller.page;
|
|
|
|
|
|
+import cn.reghao.devops.mgr.admin.model.dto.MenuDto;
|
|
|
import cn.reghao.devops.mgr.admin.model.po.Menu;
|
|
|
+import cn.reghao.devops.mgr.admin.model.vo.MenuTree;
|
|
|
import cn.reghao.devops.mgr.admin.model.vo.RoleVO;
|
|
|
+import cn.reghao.devops.mgr.admin.service.MenuService;
|
|
|
+import cn.reghao.jutil.jdk.result.Result;
|
|
|
+import cn.reghao.jutil.web.WebResult;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import org.springframework.http.MediaType;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.ui.Model;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.util.*;
|
|
|
@@ -20,6 +27,12 @@ import java.util.stream.Collectors;
|
|
|
@RequestMapping("/rbac/menu")
|
|
|
@Controller
|
|
|
public class MenuPageController {
|
|
|
+ private final MenuService menuService;
|
|
|
+
|
|
|
+ public MenuPageController(MenuService menuService) {
|
|
|
+ this.menuService = menuService;
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation(value = "资源列表页面", notes = "N")
|
|
|
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
|
|
@GetMapping
|
|
|
@@ -56,4 +69,73 @@ public class MenuPageController {
|
|
|
model.addAttribute("list", list);
|
|
|
return "/admin/menu/roles";
|
|
|
}
|
|
|
+
|
|
|
+ @ApiOperation(value = "添加资源", notes = "N")
|
|
|
+ @PreAuthorize("hasRole('ROLE_ADMIN')")
|
|
|
+ @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ @ResponseBody
|
|
|
+ public String addMenu(@Validated Menu menu) {
|
|
|
+ Result result = menuService.addMenu(menu);
|
|
|
+ return WebResult.result(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "修改资源", notes = "N")
|
|
|
+ @PreAuthorize("hasRole('ROLE_ADMIN')")
|
|
|
+ @PostMapping(value = "/edit", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ @ResponseBody
|
|
|
+ public String modifyMenu(@Validated MenuDto menuDto) {
|
|
|
+ Result result = menuService.updateMenu(menuDto);
|
|
|
+ return WebResult.result(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "修改资源状态", notes = "N")
|
|
|
+ @PreAuthorize("hasRole('ROLE_ADMIN')")
|
|
|
+ @PostMapping(value = "/status/{enabled}", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ @ResponseBody
|
|
|
+ public String menuStatus(@PathVariable("enabled") boolean enabled, @RequestParam("ids") List<Integer> ids) {
|
|
|
+ menuService.updateMenusStatus(enabled, ids);
|
|
|
+ return WebResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "删除资源", notes = "N")
|
|
|
+ @PreAuthorize("hasRole('ROLE_ADMIN')")
|
|
|
+ @DeleteMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ @ResponseBody
|
|
|
+ public String deleteMenu(@PathVariable("id") Integer menuId) {
|
|
|
+ /*Result result = menuService.deleteMenu(menuId);
|
|
|
+ return WebResult.result(result);*/
|
|
|
+ return WebResult.failWithMsg("接口未实现");
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "获取指定状态的菜单", notes = "N")
|
|
|
+ @PreAuthorize("hasRole('ROLE_ADMIN')")
|
|
|
+ @GetMapping(value = "/ztree/{enabled}", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ @ResponseBody
|
|
|
+ public String list(@PathVariable(value = "enabled") Boolean enabled) {
|
|
|
+ List<MenuTree> list = menuService.getMenusByStatus(enabled);
|
|
|
+ return WebResult.success(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "返回所有 dir menu", notes = "N")
|
|
|
+ @PreAuthorize("hasRole('ROLE_ADMIN')")
|
|
|
+ @GetMapping(value = "/ztree/parent", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ @ResponseBody
|
|
|
+ public String getDirMenus() {
|
|
|
+ List<MenuTree> list = menuService.getDirMenus();
|
|
|
+ return WebResult.success(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "对同一 pid 组内的资源进行排序", notes = "N")
|
|
|
+ @PreAuthorize("hasRole('ROLE_ADMIN')")
|
|
|
+ @GetMapping(value = "/sorted/{pid}/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ @ResponseBody
|
|
|
+ public String sortList(@PathVariable(value = "pid") int pid,
|
|
|
+ @PathVariable(value = "id", required = false) Menu menu) {
|
|
|
+ /*Map<Integer, String> map = menuService.getSortedChildGroupByPid(pid);
|
|
|
+ // 排除当前 menu
|
|
|
+ if (menu != null) {
|
|
|
+ map.remove(menu.getPos());
|
|
|
+ }*/
|
|
|
+ return WebResult.failWithMsg("接口未实现");
|
|
|
+ }
|
|
|
}
|