feat(system): 添加菜单详情接口并完善权限控制
- 在 MenuController 中添加了菜单详情接口,并为所有菜单相关操作添加了权限控制 - 在 MenuService 接口中新增了 detail 方法 - 在 MenuServiceImpl 中实现了 detail 方法,用于根据 ID 查询菜单详情 - 为所有菜单操作添加了相应的权限控制注解
This commit is contained in:
parent
f494adc3cf
commit
7d0d0fea44
@ -6,6 +6,7 @@ import com.zsc.edu.gateway.modules.system.entity.Menu;
|
|||||||
import com.zsc.edu.gateway.modules.system.service.MenuService;
|
import com.zsc.edu.gateway.modules.system.service.MenuService;
|
||||||
import com.zsc.edu.gateway.modules.system.vo.MenuVo;
|
import com.zsc.edu.gateway.modules.system.vo.MenuVo;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@ -25,6 +26,7 @@ public class MenuController {
|
|||||||
* 新建菜单
|
* 新建菜单
|
||||||
*/
|
*/
|
||||||
@PostMapping
|
@PostMapping
|
||||||
|
@PreAuthorize("hasAuthority('system:menu:create')")
|
||||||
public Menu create(@RequestBody MenuDto dto) {
|
public Menu create(@RequestBody MenuDto dto) {
|
||||||
return service.create(dto);
|
return service.create(dto);
|
||||||
}
|
}
|
||||||
@ -33,6 +35,7 @@ public class MenuController {
|
|||||||
* 更新菜单
|
* 更新菜单
|
||||||
*/
|
*/
|
||||||
@PatchMapping("/{id}")
|
@PatchMapping("/{id}")
|
||||||
|
@PreAuthorize("hasAuthority('system:menu:update')")
|
||||||
public Menu update(@RequestBody MenuDto dto, @PathVariable("id") Long id) {
|
public Menu update(@RequestBody MenuDto dto, @PathVariable("id") Long id) {
|
||||||
return service.update(dto, id);
|
return service.update(dto, id);
|
||||||
}
|
}
|
||||||
@ -41,6 +44,7 @@ public class MenuController {
|
|||||||
* 删除菜单
|
* 删除菜单
|
||||||
*/
|
*/
|
||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
|
@PreAuthorize("hasAuthority('system:menu:delete')")
|
||||||
public Boolean delete(@PathVariable("id") Long id) {
|
public Boolean delete(@PathVariable("id") Long id) {
|
||||||
return service.delete(id);
|
return service.delete(id);
|
||||||
}
|
}
|
||||||
@ -49,7 +53,17 @@ public class MenuController {
|
|||||||
* 根据名字返回树
|
* 根据名字返回树
|
||||||
*/
|
*/
|
||||||
@GetMapping("/tree")
|
@GetMapping("/tree")
|
||||||
|
@PreAuthorize("hasAuthority('system:menu:query')")
|
||||||
public List<MenuVo> tree(@AuthenticationPrincipal UserDetailsImpl userDetails, @RequestParam String name) {
|
public List<MenuVo> tree(@AuthenticationPrincipal UserDetailsImpl userDetails, @RequestParam String name) {
|
||||||
return service.getTree(userDetails, name);
|
return service.getTree(userDetails, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据ID查询菜单详情
|
||||||
|
*/
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
@PreAuthorize("hasAuthority('system:menu:query')")
|
||||||
|
public Menu detail(@PathVariable("id") Long id) {
|
||||||
|
return service.detail(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,4 +24,6 @@ public interface MenuService extends IService<Menu> {
|
|||||||
Boolean delete(Long id);
|
Boolean delete(Long id);
|
||||||
|
|
||||||
List<MenuVo> getTree(UserDetailsImpl userDetails, String name);
|
List<MenuVo> getTree(UserDetailsImpl userDetails, String name);
|
||||||
|
|
||||||
|
Menu detail(Long id);
|
||||||
}
|
}
|
||||||
|
@ -108,4 +108,8 @@ public class MenuServiceImpl extends ServiceImpl<MenuRepository, Menu> implement
|
|||||||
return menuTrees;
|
return menuTrees;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Menu detail(Long id) {
|
||||||
|
return baseMapper.selectById(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user