From 889c774520c833cfd401d9c68b012795b7c71a91 Mon Sep 17 00:00:00 2001 From: Bunny <1319900154@qq.com> Date: Sat, 16 Nov 2024 22:57:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=8C=E5=96=84=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=BD=93=E5=89=8D=E7=94=A8=E6=88=B7=E4=B8=8B=E6=89=80=E6=9C=89?= =?UTF-8?q?=E7=9A=84=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/financial/CategoryController.java | 14 +++++++------- .../service/financial/CategoryService.java | 2 +- .../financial/impl/CategoryServiceImpl.java | 10 ++++++++-- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/service/src/main/java/cn/bunny/services/controller/financial/CategoryController.java b/service/src/main/java/cn/bunny/services/controller/financial/CategoryController.java index 6a80354..a3c585c 100644 --- a/service/src/main/java/cn/bunny/services/controller/financial/CategoryController.java +++ b/service/src/main/java/cn/bunny/services/controller/financial/CategoryController.java @@ -39,6 +39,13 @@ public class CategoryController { @Autowired private CategoryService categoryService; + @Operation(summary = "查询当前用户下所有的分类", description = "查询当前用户下所有的分类") + @GetMapping("noManage/getCategoryUserAllList") + public Mono>> getCategoryUserAllList(@RequestParam(required = false) Long userId) { + List voList = categoryService.getCategoryUserAllList(userId); + return Mono.just(Result.success(voList)); + } + @Operation(summary = "分页查询分类信息", description = "分页查询分类信息") @GetMapping("getCategoryList/{page}/{limit}") public Mono>> getCategoryList( @@ -65,13 +72,6 @@ public class CategoryController { return Mono.just(Result.success(pageResult)); } - @Operation(summary = "查询当前用户下所有的分类", description = "查询当前用户下所有的分类") - @GetMapping("noManage/getCategoryUserAllList") - public Mono>> getCategoryUserAllList() { - List voList = categoryService.getCategoryUserAllList(); - return Mono.just(Result.success(voList)); - } - @Operation(summary = "添加分类信息", description = "添加分类信息") @PostMapping("addCategory") public Mono> addCategory(@Valid @RequestBody CategoryAddDto dto) { diff --git a/service/src/main/java/cn/bunny/services/service/financial/CategoryService.java b/service/src/main/java/cn/bunny/services/service/financial/CategoryService.java index 6ff00b7..8a65aaa 100644 --- a/service/src/main/java/cn/bunny/services/service/financial/CategoryService.java +++ b/service/src/main/java/cn/bunny/services/service/financial/CategoryService.java @@ -44,7 +44,7 @@ public interface CategoryService extends IService { * * @return 当前用户分类返回列表 */ - List getCategoryUserAllList(); + List getCategoryUserAllList(Long userId); /** * * 添加分类信息 diff --git a/service/src/main/java/cn/bunny/services/service/financial/impl/CategoryServiceImpl.java b/service/src/main/java/cn/bunny/services/service/financial/impl/CategoryServiceImpl.java index 60ca105..b7fcb5e 100644 --- a/service/src/main/java/cn/bunny/services/service/financial/impl/CategoryServiceImpl.java +++ b/service/src/main/java/cn/bunny/services/service/financial/impl/CategoryServiceImpl.java @@ -90,9 +90,15 @@ public class CategoryServiceImpl extends ServiceImpl i * @return 当前用户分类返回列表 */ @Override - public List getCategoryUserAllList() { + public List getCategoryUserAllList(Long userId) { + // 判断用户ID是否为空,如果为空设置为当前的用户的ID + if (userId == null) { + userId = BaseContext.getUserId(); + } + + // 根据用户id返回父级列表 LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(Category::getUserId, BaseContext.getUserId()) + wrapper.eq(Category::getUserId, userId) .or() .eq(Category::getIsBuiltin, true); return list(wrapper)