|
@@ -3,10 +3,13 @@ package com.ylx.project.service.impl;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
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.LambdaQueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
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.exception.ServiceException;
|
|
|
import com.ylx.common.utils.DateUtils;
|
|
import com.ylx.common.utils.DateUtils;
|
|
|
import com.ylx.common.utils.SecurityUtils;
|
|
import com.ylx.common.utils.SecurityUtils;
|
|
@@ -24,12 +27,14 @@ import com.ylx.project.mapper.ProjectMapper;
|
|
|
import com.ylx.project.service.ProjectService;
|
|
import com.ylx.project.service.ProjectService;
|
|
|
import com.ylx.servicecategory.domain.ServiceCategory;
|
|
import com.ylx.servicecategory.domain.ServiceCategory;
|
|
|
import com.ylx.servicecategory.service.ServiceCategoryService;
|
|
import com.ylx.servicecategory.service.ServiceCategoryService;
|
|
|
|
|
+import com.ylx.system.service.ISysDictDataService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
@@ -39,6 +44,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
|
private ServiceCategoryService serviceCategoryService;
|
|
private ServiceCategoryService serviceCategoryService;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private ISysDictDataService sysDictDataService;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public Page<ProjectPageVo> list(Page<Project> page, ProjectSearchDTO dto) {
|
|
public Page<ProjectPageVo> list(Page<Project> page, ProjectSearchDTO dto) {
|
|
@@ -85,6 +92,12 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
entity.setUpdateBy(SecurityUtils.getUsername());
|
|
entity.setUpdateBy(SecurityUtils.getUsername());
|
|
|
entity.setUpdateTime(DateUtils.getNowDate());
|
|
entity.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
|
|
|
|
|
+ // 根据项目亮点ID集合获取项目亮点
|
|
|
|
|
+ String highlightNames = this.buildHighlightNames(dto.getHighlightIds());
|
|
|
|
|
+ if(StrUtil.isNotEmpty(highlightNames)){
|
|
|
|
|
+ entity.setHighlight(highlightNames);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
boolean updateResult = this.updateById(entity);
|
|
boolean updateResult = this.updateById(entity);
|
|
|
if (!updateResult) {
|
|
if (!updateResult) {
|
|
|
throw new ServiceException("更新项目失败");
|
|
throw new ServiceException("更新项目失败");
|
|
@@ -107,6 +120,12 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
entity.setCreateBy(SecurityUtils.getUsername());
|
|
entity.setCreateBy(SecurityUtils.getUsername());
|
|
|
entity.setCreateTime(DateUtils.getNowDate());
|
|
entity.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
|
|
|
|
|
+ // 根据项目亮点ID集合获取项目亮点
|
|
|
|
|
+ String highlightNames = this.buildHighlightNames(dto.getHighlightIds());
|
|
|
|
|
+ if(StrUtil.isNotEmpty(highlightNames)){
|
|
|
|
|
+ entity.setHighlight(highlightNames);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
boolean saveResult = this.save(entity);
|
|
boolean saveResult = this.save(entity);
|
|
|
if (!saveResult) {
|
|
if (!saveResult) {
|
|
|
throw new ServiceException("添加项目失败");
|
|
throw new ServiceException("添加项目失败");
|
|
@@ -158,4 +177,34 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
return vo;
|
|
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(","));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|