mirror of
https://github.com/BgaSol/sol-cloud
synced 2026-05-24 09:38:21 +00:00
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
This commit is contained in:
parent
56acac8759
commit
815e2e7112
1 changed files with 5 additions and 1 deletions
|
|
@ -17,8 +17,10 @@ import org.apache.commons.lang3.StringUtils;
|
||||||
import org.redisson.api.RedissonClient;
|
import org.redisson.api.RedissonClient;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
@ -91,7 +93,9 @@ public class RoleService extends BasePoiService<RoleEntity,
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> toIds(List<? extends BaseEntity> list) {
|
private List<String> toIds(List<? extends BaseEntity> list) {
|
||||||
if (list == null) return null;
|
if (list == null || list.isEmpty()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
return list.stream().map(BaseEntity::getId).collect(Collectors.toList());
|
return list.stream().map(BaseEntity::getId).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue