You've already forked FrameTour-BE
Merge branch 'refs/heads/xmgl'
This commit is contained in:
@@ -44,6 +44,11 @@ public class ProjectEntity {
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 模板ID,用于绑定模板
|
||||
*/
|
||||
private Long templateId;
|
||||
|
||||
private Date createAt;
|
||||
private Date updateAt;
|
||||
}
|
@@ -28,4 +28,9 @@ public class ProjectReqQuery extends BaseQueryParameterReq {
|
||||
* 状态,0禁用,1启用
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 模板ID
|
||||
*/
|
||||
private Long templateId;
|
||||
}
|
@@ -45,6 +45,16 @@ public class ProjectRespVO {
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 模板ID
|
||||
*/
|
||||
private Long templateId;
|
||||
|
||||
/**
|
||||
* 模板名称
|
||||
*/
|
||||
private String templateName;
|
||||
|
||||
private Date createAt;
|
||||
private Date updateAt;
|
||||
}
|
@@ -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
|
||||
|
@@ -2,8 +2,8 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ycwl.basic.mapper.ProjectMapper">
|
||||
<insert id="add">
|
||||
insert into project(scenic_id, `name`, min_play_time, max_play_time, status, create_at, update_at)
|
||||
values (#{scenicId}, #{name}, #{minPlayTime}, #{maxPlayTime}, #{status}, now(), now())
|
||||
insert into project(scenic_id, `name`, min_play_time, max_play_time, status, template_id, create_at, update_at)
|
||||
values (#{scenicId}, #{name}, #{minPlayTime}, #{maxPlayTime}, #{status}, #{templateId}, now(), now())
|
||||
</insert>
|
||||
|
||||
<update id="update">
|
||||
@@ -12,6 +12,7 @@
|
||||
min_play_time = #{minPlayTime},
|
||||
max_play_time = #{maxPlayTime},
|
||||
status = #{status},
|
||||
template_id = #{templateId},
|
||||
update_at = now()
|
||||
where id = #{id}
|
||||
</update>
|
||||
@@ -35,7 +36,7 @@
|
||||
</delete>
|
||||
|
||||
<select id="list" resultType="com.ycwl.basic.model.pc.project.resp.ProjectRespVO">
|
||||
select p.id, p.scenic_id, p.`name`, p.min_play_time, p.max_play_time, p.status, p.create_at, p.update_at
|
||||
select p.id, p.scenic_id, p.`name`, p.min_play_time, p.max_play_time, p.status, p.template_id, p.create_at, p.update_at
|
||||
from project p
|
||||
<where>
|
||||
<if test="scenicId != null">
|
||||
@@ -47,12 +48,15 @@
|
||||
<if test="status != null">
|
||||
and p.`status` = #{status}
|
||||
</if>
|
||||
<if test="templateId != null">
|
||||
and p.template_id = #{templateId}
|
||||
</if>
|
||||
</where>
|
||||
order by p.create_at desc
|
||||
</select>
|
||||
|
||||
<select id="getById" resultType="com.ycwl.basic.model.pc.project.resp.ProjectRespVO">
|
||||
select p.id, p.scenic_id, p.`name`, p.min_play_time, p.max_play_time, p.status, p.create_at, p.update_at
|
||||
select p.id, p.scenic_id, p.`name`, p.min_play_time, p.max_play_time, p.status, p.template_id, p.create_at, p.update_at
|
||||
from project p
|
||||
where p.id = #{id}
|
||||
</select>
|
||||
|
Reference in New Issue
Block a user