2024-09-27 12:21:17 +08:00
|
|
|
package cn.bunny.services.controller;
|
|
|
|
|
2024-10-03 15:52:02 +08:00
|
|
|
import cn.bunny.dao.dto.system.router.RouterAddDto;
|
|
|
|
import cn.bunny.dao.dto.system.router.RouterManageDto;
|
|
|
|
import cn.bunny.dao.dto.system.router.RouterUpdateDto;
|
2024-09-28 03:06:22 +08:00
|
|
|
import cn.bunny.dao.entity.system.Router;
|
|
|
|
import cn.bunny.dao.pojo.result.PageResult;
|
2024-09-27 16:49:01 +08:00
|
|
|
import cn.bunny.dao.pojo.result.Result;
|
2024-09-29 10:47:23 +08:00
|
|
|
import cn.bunny.dao.pojo.result.ResultCodeEnum;
|
2024-10-03 15:52:02 +08:00
|
|
|
import cn.bunny.dao.vo.system.router.RouterManageVo;
|
|
|
|
import cn.bunny.dao.vo.system.router.UserRouterVo;
|
2024-09-27 16:49:01 +08:00
|
|
|
import cn.bunny.services.service.RouterService;
|
2024-09-28 03:06:22 +08:00
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
2024-09-27 16:49:01 +08:00
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
2024-09-28 03:06:22 +08:00
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
2024-09-27 12:21:17 +08:00
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
2024-10-03 13:44:39 +08:00
|
|
|
import jakarta.validation.Valid;
|
2024-09-27 16:49:01 +08:00
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
2024-09-29 10:47:23 +08:00
|
|
|
import org.springframework.web.bind.annotation.*;
|
2024-09-28 03:06:22 +08:00
|
|
|
import reactor.core.publisher.Mono;
|
2024-09-27 12:21:17 +08:00
|
|
|
|
2024-09-27 16:49:01 +08:00
|
|
|
import java.util.List;
|
|
|
|
|
2024-09-27 12:21:17 +08:00
|
|
|
/**
|
|
|
|
* <p>
|
2024-10-16 16:57:03 +08:00
|
|
|
* 系统菜单 前端控制器
|
2024-09-27 12:21:17 +08:00
|
|
|
* </p>
|
|
|
|
*
|
|
|
|
* @author Bunny
|
|
|
|
* @since 2024-09-26
|
|
|
|
*/
|
|
|
|
@Tag(name = "系统路由", description = "系统路由相关接口")
|
|
|
|
@RestController
|
|
|
|
@RequestMapping("admin/router")
|
|
|
|
public class RouterController {
|
|
|
|
|
2024-09-27 16:49:01 +08:00
|
|
|
@Autowired
|
|
|
|
private RouterService routerService;
|
|
|
|
|
|
|
|
@Operation(summary = "获取用户菜单", description = "获取用户菜单")
|
|
|
|
@GetMapping("getRouterAsync")
|
2024-09-28 03:06:22 +08:00
|
|
|
public Mono<Result<List<UserRouterVo>>> getRouterAsync() {
|
2024-09-27 16:49:01 +08:00
|
|
|
List<UserRouterVo> voList = routerService.getRouterAsync();
|
2024-09-28 03:06:22 +08:00
|
|
|
return Mono.just(Result.success(voList));
|
|
|
|
}
|
|
|
|
|
2024-10-16 16:57:03 +08:00
|
|
|
@Operation(summary = "分页管理菜单列", description = "分页管理菜单列")
|
2024-10-03 13:44:39 +08:00
|
|
|
@GetMapping("getMenusList/{page}/{limit}")
|
2024-09-28 03:06:22 +08:00
|
|
|
public Mono<Result<PageResult<RouterManageVo>>> getMenusByPage(
|
|
|
|
@Parameter(name = "page", description = "当前页", required = true)
|
|
|
|
@PathVariable("page") Integer page,
|
|
|
|
@Parameter(name = "limit", description = "每页记录数", required = true)
|
|
|
|
@PathVariable("limit") Integer limit,
|
|
|
|
RouterManageDto dto) {
|
|
|
|
Page<Router> pageParams = new Page<>(page, limit);
|
|
|
|
PageResult<RouterManageVo> voPageResult = routerService.getMenusByPage(pageParams, dto);
|
|
|
|
|
|
|
|
return Mono.just(Result.success(voPageResult));
|
|
|
|
}
|
|
|
|
|
2024-10-16 16:57:03 +08:00
|
|
|
@Operation(summary = "管理菜单列", description = "管理菜单列")
|
2024-10-03 13:44:39 +08:00
|
|
|
@GetMapping("getMenusList")
|
|
|
|
public Mono<Result<List<RouterManageVo>>> getMenusList(RouterManageDto dto) {
|
|
|
|
List<RouterManageVo> voPageResult = routerService.getMenusList(dto);
|
2024-09-28 03:06:22 +08:00
|
|
|
|
|
|
|
return Mono.just(Result.success(voPageResult));
|
2024-09-27 16:49:01 +08:00
|
|
|
}
|
2024-09-29 10:47:23 +08:00
|
|
|
|
|
|
|
@Operation(summary = "添加路由菜单", description = "添加路由菜单")
|
|
|
|
@PostMapping("addMenu")
|
2024-10-03 13:44:39 +08:00
|
|
|
public Mono<Result<String>> addMenu(@Valid @RequestBody RouterAddDto dto) {
|
2024-09-29 10:47:23 +08:00
|
|
|
routerService.addMenu(dto);
|
|
|
|
return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Operation(summary = "更新路由菜单", description = "更新路由菜单")
|
|
|
|
@PutMapping("updateMenu")
|
2024-10-03 13:44:39 +08:00
|
|
|
public Mono<Result<String>> updateMenu(@Valid @RequestBody RouterUpdateDto dto) {
|
2024-09-29 10:47:23 +08:00
|
|
|
routerService.updateMenu(dto);
|
|
|
|
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Operation(summary = "删除路由菜单", description = "删除路由菜单")
|
|
|
|
@DeleteMapping("deletedMenuByIds")
|
|
|
|
public Mono<Result<String>> deletedMenuByIds(@RequestBody List<Long> ids) {
|
|
|
|
routerService.deletedMenuByIds(ids);
|
|
|
|
return Mono.just(Result.success(ResultCodeEnum.DELETE_SUCCESS));
|
|
|
|
}
|
2024-09-27 12:21:17 +08:00
|
|
|
}
|