Merge branch 'refs/heads/xmgl'

This commit is contained in:
2025-09-16 15:03:33 +08:00
5 changed files with 86 additions and 7 deletions

View File

@@ -44,6 +44,11 @@ public class ProjectEntity {
*/
private Integer status;
/**
* 模板ID,用于绑定模板
*/
private Long templateId;
private Date createAt;
private Date updateAt;
}

View File

@@ -28,4 +28,9 @@ public class ProjectReqQuery extends BaseQueryParameterReq {
* 状态,0禁用,1启用
*/
private Integer status;
/**
* 模板ID
*/
private Long templateId;
}

View File

@@ -45,6 +45,16 @@ public class ProjectRespVO {
*/
private Integer status;
/**
* 模板ID
*/
private Long templateId;
/**
* 模板名称
*/
private String templateName;
private Date createAt;
private Date updateAt;
}

View File

@@ -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