|
|
@@ -5,9 +5,11 @@ import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.ylx.common.core.domain.entity.SysDictData;
|
|
|
import com.ylx.common.exception.ServiceException;
|
|
|
import com.ylx.common.utils.DateUtils;
|
|
|
import com.ylx.common.utils.SecurityUtils;
|
|
|
@@ -15,8 +17,6 @@ import com.ylx.massage.domain.dto.OptionDTO;
|
|
|
import com.ylx.massage.domain.dto.ServiceOptionDTO;
|
|
|
import com.ylx.massage.domain.vo.ProductOptionVO;
|
|
|
import com.ylx.massage.domain.vo.ProductServiceOptionVO;
|
|
|
-import com.ylx.point.domain.PointActivity;
|
|
|
-import com.ylx.point.domain.vo.PointActivityPageVo;
|
|
|
import com.ylx.project.domain.Project;
|
|
|
import com.ylx.project.domain.dto.ProjectAddDTO;
|
|
|
import com.ylx.project.domain.dto.ProjectSearchDTO;
|
|
|
@@ -25,11 +25,16 @@ import com.ylx.project.domain.vo.ProjectDetailVo;
|
|
|
import com.ylx.project.domain.vo.ProjectPageVo;
|
|
|
import com.ylx.project.mapper.ProjectMapper;
|
|
|
import com.ylx.project.service.ProjectService;
|
|
|
+import com.ylx.servicecategory.domain.ServiceCategory;
|
|
|
+import com.ylx.servicecategory.service.ServiceCategoryService;
|
|
|
+import com.ylx.system.service.ISysDictDataService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -37,6 +42,11 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> implements ProjectService {
|
|
|
|
|
|
+ @Resource
|
|
|
+ private ServiceCategoryService serviceCategoryService;
|
|
|
+ @Resource
|
|
|
+ private ISysDictDataService sysDictDataService;
|
|
|
+
|
|
|
@Override
|
|
|
public Page<ProjectPageVo> list(Page<Project> page, ProjectSearchDTO dto) {
|
|
|
LambdaQueryWrapper<Project> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
@@ -48,9 +58,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
if (ObjectUtil.isNotEmpty(dto.getStatus())) {
|
|
|
queryWrapper.eq(Project::getStatus, dto.getStatus());
|
|
|
}
|
|
|
- // 类目ID
|
|
|
- if (ObjectUtil.isNotEmpty(dto.getType())) {
|
|
|
- queryWrapper.eq(Project::getType, dto.getType());
|
|
|
+ // 服务类目ID
|
|
|
+ if (ObjectUtil.isNotEmpty(dto.getCategoryId())) {
|
|
|
+ queryWrapper.eq(Project::getCategoryId, dto.getCategoryId());
|
|
|
}
|
|
|
queryWrapper.orderByDesc(Project::getCreateTime).orderByDesc(Project::getSortOrder);
|
|
|
Page<ProjectPageVo> pageData = new Page<>();
|
|
|
@@ -82,6 +92,12 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
entity.setUpdateBy(SecurityUtils.getUsername());
|
|
|
entity.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
|
+ // 根据项目亮点ID集合获取项目亮点
|
|
|
+ String highlightNames = this.buildHighlightNames(dto.getHighlightIds());
|
|
|
+ if(StrUtil.isNotEmpty(highlightNames)){
|
|
|
+ entity.setHighlight(highlightNames);
|
|
|
+ }
|
|
|
+
|
|
|
boolean updateResult = this.updateById(entity);
|
|
|
if (!updateResult) {
|
|
|
throw new ServiceException("更新项目失败");
|
|
|
@@ -93,11 +109,23 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
public void add(ProjectAddDTO dto) {
|
|
|
|
|
|
Project entity = new Project();
|
|
|
+
|
|
|
+ ServiceCategory serviceCategoryDetail = this.serviceCategoryService.getServiceCategoryDetail(dto.getCategoryId());
|
|
|
+ if (ObjectUtil.isNull(serviceCategoryDetail)) {
|
|
|
+ throw new ServiceException("服务类目不存在");
|
|
|
+ }
|
|
|
BeanUtil.copyProperties(dto, entity);
|
|
|
|
|
|
+ entity.setType(serviceCategoryDetail.getServiceTag());
|
|
|
entity.setCreateBy(SecurityUtils.getUsername());
|
|
|
entity.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
|
+ // 根据项目亮点ID集合获取项目亮点
|
|
|
+ String highlightNames = this.buildHighlightNames(dto.getHighlightIds());
|
|
|
+ if(StrUtil.isNotEmpty(highlightNames)){
|
|
|
+ entity.setHighlight(highlightNames);
|
|
|
+ }
|
|
|
+
|
|
|
boolean saveResult = this.save(entity);
|
|
|
if (!saveResult) {
|
|
|
throw new ServiceException("添加项目失败");
|
|
|
@@ -149,4 +177,34 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
return vo;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据亮点ID集合构建高亮名称字符串
|
|
|
+ *
|
|
|
+ * @param highlightIds 逗号分隔的ID字符串或单个ID
|
|
|
+ * @return 拼接好的名称字符串,如 "技术领先,市场广阔"
|
|
|
+ */
|
|
|
+ private String buildHighlightNames(String highlightIds) {
|
|
|
+ // 1. 基础校验:如果ID为空,直接返回空字符串,避免后续查库
|
|
|
+ if (StringUtils.isBlank(highlightIds)) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 解析ID列表 (兼容逗号分隔的情况)
|
|
|
+ List<String> idList = Arrays.asList(highlightIds.split(","));
|
|
|
+
|
|
|
+ // 3. 批量查询字典表
|
|
|
+ List<SysDictData> dictList = this.sysDictDataService.list(
|
|
|
+ new QueryWrapper<SysDictData>()
|
|
|
+ .in("dict_code", idList)
|
|
|
+ .select("dict_label") // 【性能优化】只查询需要的字段,减少IO开销
|
|
|
+ );
|
|
|
+
|
|
|
+ // 4. 提取名称并拼接
|
|
|
+ return dictList.stream()
|
|
|
+ .map(SysDictData::getDictLabel)
|
|
|
+ .filter(StringUtils::isNotBlank) // 过滤掉可能为空的标签
|
|
|
+ .collect(Collectors.joining(","));
|
|
|
+ }
|
|
|
+
|
|
|
}
|