You've already forked FrameTour-BE
模板、设备排序
This commit is contained in:
@@ -10,7 +10,9 @@ import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class DeviceRepository {
|
||||
@@ -126,4 +128,9 @@ public class DeviceRepository {
|
||||
redisTemplate.opsForValue().set(String.format(DEVICE_CACHE_KEY, device.getId()), JSONObject.toJSONString(device));
|
||||
redisTemplate.opsForValue().set(String.format(DEVICE_CACHE_KEY, device.getNo()), JSONObject.toJSONString(device));
|
||||
}
|
||||
|
||||
public List<DeviceEntity> getAllDeviceByScenicId(Long scenicId) {
|
||||
List<Long> deviceIdList = deviceMapper.listAllByScenicId(scenicId);
|
||||
return deviceIdList.stream().map(this::getDevice).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
@@ -68,6 +68,15 @@ public class TemplateRepository {
|
||||
return idList.stream().map(this::getTemplate).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<TemplateRespVO> getAllTemplateListByScenicId(Long scenicId) {
|
||||
List<Long> idList;
|
||||
idList = templateMapper.listAllTemplateIdByScenicId(scenicId);
|
||||
if (idList == null || idList.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return idList.stream().map(this::getTemplate).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public TemplateRespVO getTemplate(Long templateId) {
|
||||
if (redisTemplate.hasKey(String.format(TEMPLATE_CACHE_KEY, templateId))) {
|
||||
return JSONObject.parseObject(redisTemplate.opsForValue().get(String.format(TEMPLATE_CACHE_KEY, templateId)), TemplateRespVO.class);
|
||||
|
Reference in New Issue
Block a user