refactor: 修改缓存排序.

This commit is contained in:
lijiahang
2023-12-27 15:20:14 +08:00
parent fda6085cc8
commit 6d1ffd43b4
5 changed files with 11 additions and 2 deletions

View File

@@ -18,7 +18,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
@@ -88,7 +88,7 @@ public class ${type}ApiImpl implements ${type}Api {
public List<${type}DTO> get${type}ByIdList(List<Long> idList) {
log.info("${type}Api.get${type}ByIdList idList: {}", idList);
if (Lists.isEmpty(idList)) {
return new ArrayList<>();
return Lists.empty();
}
// 查询
List<${type}DO> rows = ${typeLower}DAO.selectBatchIds(idList);
@@ -112,6 +112,7 @@ public class ${type}ApiImpl implements ${type}Api {
return ${typeLower}Service.get${type}ListByCache()
.stream()
.map(${type}ProviderConvert.MAPPER::to)
.sorted(Comparator.comparing(${type}DTO::getId))
.collect(Collectors.toList());
}

View File

@@ -30,6 +30,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -131,6 +132,7 @@ public class HostIdentityServiceImpl implements HostIdentityService {
// 转换
return list.stream()
.map(HostIdentityConvert.MAPPER::to)
.sorted(Comparator.comparing(HostIdentityVO::getId))
.collect(Collectors.toList());
}

View File

@@ -29,6 +29,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
@@ -145,6 +146,7 @@ public class HostKeyServiceImpl implements HostKeyService {
// 转换
return list.stream()
.map(HostKeyConvert.MAPPER::to)
.sorted(Comparator.comparing(HostKeyVO::getId))
.collect(Collectors.toList());
}

View File

@@ -39,6 +39,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Future;
@@ -170,6 +171,7 @@ public class HostServiceImpl implements HostService {
// 转换
return list.stream()
.map(HostConvert.MAPPER::to)
.sorted(Comparator.comparing(HostVO::getId))
.collect(Collectors.toList());
}

View File

@@ -34,6 +34,7 @@ import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
@@ -180,6 +181,7 @@ public class SystemUserServiceImpl implements SystemUserService {
// 转换
return list.stream()
.map(SystemUserConvert.MAPPER::to)
.sorted(Comparator.comparing(SystemUserVO::getId))
.collect(Collectors.toList());
}