|
|
@@ -9,6 +9,7 @@ import cn.reghao.jutil.jdk.result.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.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
@@ -29,6 +30,7 @@ public class MenuController {
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "添加资源")
|
|
|
+ @PreAuthorize("hasRole('ROLE_ADMIN')")
|
|
|
@PostMapping(produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
public String addMenu(@Validated Menu menu) {
|
|
|
Result result = menuService.addMenu(menu);
|
|
|
@@ -36,6 +38,7 @@ public class MenuController {
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "修改资源")
|
|
|
+ @PreAuthorize("hasRole('ROLE_ADMIN')")
|
|
|
@PostMapping(value = "/edit", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
public String modifyMenu(@Validated MenuDto menuDto) {
|
|
|
Result result = menuService.updateMenu(menuDto);
|
|
|
@@ -43,6 +46,7 @@ public class MenuController {
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "修改资源状态")
|
|
|
+ @PreAuthorize("hasRole('ROLE_ADMIN')")
|
|
|
@PostMapping(value = "/status/{enabled}", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
public String menuStatus(@PathVariable("enabled") boolean enabled, @RequestParam("ids") List<Integer> ids) {
|
|
|
menuService.updateMenusStatus(enabled, ids);
|
|
|
@@ -50,6 +54,7 @@ public class MenuController {
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "删除资源")
|
|
|
+ @PreAuthorize("hasRole('ROLE_ADMIN')")
|
|
|
@DeleteMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
public String deleteMenu(@PathVariable("id") Integer menuId) {
|
|
|
Result result = menuService.deleteMenu(menuId);
|
|
|
@@ -57,12 +62,15 @@ public class MenuController {
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "获取指定状态的菜单")
|
|
|
+ @PreAuthorize("hasRole('ROLE_ADMIN')")
|
|
|
@GetMapping(value = "/ztree/{enabled}", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
public String list(@PathVariable(value = "enabled") Boolean enabled) {
|
|
|
List<MenuTree> list = menuService.getMenusByStatus(enabled);
|
|
|
return WebResult.success(list);
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value = "返回所有 dir menu")
|
|
|
+ @PreAuthorize("hasRole('ROLE_ADMIN')")
|
|
|
@GetMapping(value = "/ztree/parent", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
public String getDirMenus() {
|
|
|
List<MenuTree> list = menuService.getDirMenus();
|
|
|
@@ -70,6 +78,7 @@ public class MenuController {
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "对同一 pid 组内的资源进行排序")
|
|
|
+ @PreAuthorize("hasRole('ROLE_ADMIN')")
|
|
|
@GetMapping(value = "/sorted/{pid}/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
public String sortList(@PathVariable(value = "pid") int pid,
|
|
|
@PathVariable(value = "id", required = false) Menu menu) {
|