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:
smile 2025-09-19 16:52:04 +08:00
parent 56acac8759
commit 815e2e7112

View file

@ -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<RoleEntity,
}
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());
}