You've already forked FrameTour-BE
Merge branch 'refs/heads/xmgl'
This commit is contained in:
@@ -7,10 +7,13 @@ import com.ycwl.basic.model.pc.project.entity.ProjectEntity;
|
||||
import com.ycwl.basic.model.pc.project.req.ProjectReqQuery;
|
||||
import com.ycwl.basic.model.pc.project.resp.ProjectRespVO;
|
||||
import com.ycwl.basic.repository.ScenicRepository;
|
||||
import com.ycwl.basic.repository.TemplateRepository;
|
||||
import com.ycwl.basic.service.pc.ProjectService;
|
||||
import com.ycwl.basic.model.pc.template.resp.TemplateRespVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@@ -30,6 +33,9 @@ public class ProjectServiceImpl implements ProjectService {
|
||||
|
||||
@Autowired
|
||||
private ScenicRepository scenicRepository;
|
||||
|
||||
@Autowired
|
||||
private TemplateRepository templateRepository;
|
||||
|
||||
@Override
|
||||
public PageInfo<ProjectRespVO> pageQuery(ProjectReqQuery projectReqQuery) {
|
||||
@@ -44,11 +50,28 @@ public class ProjectServiceImpl implements ProjectService {
|
||||
.collect(Collectors.toList());
|
||||
Map<Long, String> scenicNames = scenicRepository.batchGetScenicNames(scenicIds);
|
||||
|
||||
// 设置景区名称
|
||||
// 批量获取模板名称
|
||||
List<Long> templateIds = list.stream()
|
||||
.map(ProjectRespVO::getTemplateId)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
Map<Long, String> templateNames = new HashMap<>();
|
||||
for (Long templateId : templateIds) {
|
||||
TemplateRespVO template = templateRepository.getTemplate(templateId);
|
||||
if (template != null) {
|
||||
templateNames.put(templateId, template.getName());
|
||||
}
|
||||
}
|
||||
|
||||
// 设置景区名称和模板名称
|
||||
list.forEach(item -> {
|
||||
if (item.getScenicId() != null) {
|
||||
item.setScenicName(scenicNames.get(item.getScenicId()));
|
||||
}
|
||||
if (item.getTemplateId() != null) {
|
||||
item.setTemplateName(templateNames.get(item.getTemplateId()));
|
||||
}
|
||||
});
|
||||
|
||||
PageInfo<ProjectRespVO> pageInfo = new PageInfo(list);
|
||||
@@ -67,11 +90,28 @@ public class ProjectServiceImpl implements ProjectService {
|
||||
.collect(Collectors.toList());
|
||||
Map<Long, String> scenicNames = scenicRepository.batchGetScenicNames(scenicIds);
|
||||
|
||||
// 设置景区名称
|
||||
// 批量获取模板名称
|
||||
List<Long> templateIds = list.stream()
|
||||
.map(ProjectRespVO::getTemplateId)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
Map<Long, String> templateNames = new HashMap<>();
|
||||
for (Long templateId : templateIds) {
|
||||
TemplateRespVO template = templateRepository.getTemplate(templateId);
|
||||
if (template != null) {
|
||||
templateNames.put(templateId, template.getName());
|
||||
}
|
||||
}
|
||||
|
||||
// 设置景区名称和模板名称
|
||||
list.forEach(item -> {
|
||||
if (item.getScenicId() != null) {
|
||||
item.setScenicName(scenicNames.get(item.getScenicId()));
|
||||
}
|
||||
if (item.getTemplateId() != null) {
|
||||
item.setTemplateName(templateNames.get(item.getTemplateId()));
|
||||
}
|
||||
});
|
||||
|
||||
return list;
|
||||
@@ -79,7 +119,22 @@ public class ProjectServiceImpl implements ProjectService {
|
||||
|
||||
@Override
|
||||
public ProjectRespVO getById(Long id) {
|
||||
return projectMapper.getById(id);
|
||||
ProjectRespVO project = projectMapper.getById(id);
|
||||
if (project != null) {
|
||||
// 设置景区名称
|
||||
if (project.getScenicId() != null) {
|
||||
Map<Long, String> scenicNames = scenicRepository.batchGetScenicNames(List.of(project.getScenicId()));
|
||||
project.setScenicName(scenicNames.get(project.getScenicId()));
|
||||
}
|
||||
// 设置模板名称
|
||||
if (project.getTemplateId() != null) {
|
||||
TemplateRespVO template = templateRepository.getTemplate(project.getTemplateId());
|
||||
if (template != null) {
|
||||
project.setTemplateName(template.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
return project;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user