You've already forked FrameTour-BE
feat(pc): 添加景区项目管理功能
- 新增项目管理相关的 Controller、Service、Mapper 及模型类 - 实现项目分页查询、列表查询、详情查询、新增、修改、删除等功能 - 添加项目状态更新和二维码下载功能 - 集成微信小程序二维码生成和存储服务
This commit is contained in:
47
src/main/java/com/ycwl/basic/service/pc/ProjectService.java
Normal file
47
src/main/java/com/ycwl/basic/service/pc/ProjectService.java
Normal file
@@ -0,0 +1,47 @@
|
||||
package com.ycwl.basic.service.pc;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
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 java.util.List;
|
||||
|
||||
/**
|
||||
* 景区项目管理服务接口
|
||||
*
|
||||
* @Author: Claude
|
||||
* @Date: 2025-01-15
|
||||
*/
|
||||
public interface ProjectService {
|
||||
|
||||
/**
|
||||
* 分页查询项目列表
|
||||
*/
|
||||
PageInfo<ProjectRespVO> pageQuery(ProjectReqQuery projectReqQuery);
|
||||
|
||||
/**
|
||||
* 查询项目列表
|
||||
*/
|
||||
List<ProjectRespVO> list(ProjectReqQuery projectReqQuery);
|
||||
|
||||
/**
|
||||
* 根据ID查询项目详情
|
||||
*/
|
||||
ProjectRespVO getById(Long id);
|
||||
|
||||
/**
|
||||
* 新增或修改项目
|
||||
*/
|
||||
int addOrUpdate(ProjectEntity project);
|
||||
|
||||
/**
|
||||
* 删除项目
|
||||
*/
|
||||
int delete(Long id);
|
||||
|
||||
/**
|
||||
* 更新项目状态
|
||||
*/
|
||||
int updateStatus(Long id);
|
||||
}
|
@@ -0,0 +1,104 @@
|
||||
package com.ycwl.basic.service.pc.impl;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.ycwl.basic.mapper.ProjectMapper;
|
||||
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.service.pc.ProjectService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 景区项目管理服务实现
|
||||
*
|
||||
* @Author: Claude
|
||||
* @Date: 2025-01-15
|
||||
*/
|
||||
@Service
|
||||
public class ProjectServiceImpl implements ProjectService {
|
||||
|
||||
@Autowired
|
||||
private ProjectMapper projectMapper;
|
||||
|
||||
@Autowired
|
||||
private ScenicRepository scenicRepository;
|
||||
|
||||
@Override
|
||||
public PageInfo<ProjectRespVO> pageQuery(ProjectReqQuery projectReqQuery) {
|
||||
PageHelper.startPage(projectReqQuery.getPageNum(), projectReqQuery.getPageSize());
|
||||
List<ProjectRespVO> list = projectMapper.list(projectReqQuery);
|
||||
|
||||
// 批量获取景区名称
|
||||
List<Long> scenicIds = list.stream()
|
||||
.map(ProjectRespVO::getScenicId)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
Map<Long, String> scenicNames = scenicRepository.batchGetScenicNames(scenicIds);
|
||||
|
||||
// 设置景区名称
|
||||
list.forEach(item -> {
|
||||
if (item.getScenicId() != null) {
|
||||
item.setScenicName(scenicNames.get(item.getScenicId()));
|
||||
}
|
||||
});
|
||||
|
||||
PageInfo<ProjectRespVO> pageInfo = new PageInfo(list);
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProjectRespVO> list(ProjectReqQuery projectReqQuery) {
|
||||
List<ProjectRespVO> list = projectMapper.list(projectReqQuery);
|
||||
|
||||
// 批量获取景区名称
|
||||
List<Long> scenicIds = list.stream()
|
||||
.map(ProjectRespVO::getScenicId)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
Map<Long, String> scenicNames = scenicRepository.batchGetScenicNames(scenicIds);
|
||||
|
||||
// 设置景区名称
|
||||
list.forEach(item -> {
|
||||
if (item.getScenicId() != null) {
|
||||
item.setScenicName(scenicNames.get(item.getScenicId()));
|
||||
}
|
||||
});
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProjectRespVO getById(Long id) {
|
||||
return projectMapper.getById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int addOrUpdate(ProjectEntity project) {
|
||||
Long id = project.getId();
|
||||
if (id == null) {
|
||||
return projectMapper.add(project);
|
||||
} else {
|
||||
return projectMapper.update(project);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Long id) {
|
||||
return projectMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateStatus(Long id) {
|
||||
return projectMapper.updateStatus(id);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user