From 815e2e71127b0c2a8579a412656d4f84c2da8096 Mon Sep 17 00:00:00 2001 From: smile <1372184840@qq.com> Date: Fri, 19 Sep 2025 16:52:04 +0800 Subject: [PATCH] refactor(web-system-8081): Optimizing the toIds method in RoleService -Add processing for empty lists and return empty lists instead of null -Use Collections. emptyList() instead of new ArrayList<>() -Optimized code structure, improved code readability and robustness --- .../com/bgasol/web/system/role/service/RoleService.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cloud/web/web-system-8081/src/main/java/com/bgasol/web/system/role/service/RoleService.java b/cloud/web/web-system-8081/src/main/java/com/bgasol/web/system/role/service/RoleService.java index 291dc65..bec71c6 100644 --- a/cloud/web/web-system-8081/src/main/java/com/bgasol/web/system/role/service/RoleService.java +++ b/cloud/web/web-system-8081/src/main/java/com/bgasol/web/system/role/service/RoleService.java @@ -17,8 +17,10 @@ import org.apache.commons.lang3.StringUtils; import org.redisson.api.RedissonClient; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.stream.Collectors; @@ -91,7 +93,9 @@ public class RoleService extends BasePoiService toIds(List list) { - if (list == null) return null; + if (list == null || list.isEmpty()) { + return Collections.emptyList(); + } return list.stream().map(BaseEntity::getId).collect(Collectors.toList()); }