|
|
@@ -1,5 +1,6 @@
|
|
|
package cn.iocoder.yudao.module.rd.service.expertpool;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
import cn.iocoder.yudao.module.rd.controller.admin.expertpool.vo.ExpertPoolPageReqVO;
|
|
|
@@ -11,10 +12,18 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
|
+import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
|
|
+import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
|
|
+
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
+import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
|
|
+import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
|
|
import static cn.iocoder.yudao.module.rd.enums.ErrorCodeConstant.EXPERT_POOL_NOT_EXISTS;
|
|
|
|
|
|
|
|
|
@@ -30,6 +39,9 @@ public class ExpertPoolServiceImpl implements ExpertPoolService {
|
|
|
@Resource
|
|
|
private ExpertPoolMapper expertPoolMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private DeptApi deptApi;
|
|
|
+
|
|
|
@Override
|
|
|
public Long createExpertPool(ExpertPoolSaveReqVO createReqVO) {
|
|
|
// 插入
|
|
|
@@ -54,6 +66,25 @@ public class ExpertPoolServiceImpl implements ExpertPoolService {
|
|
|
return maxSortObj == null || maxSortObj.getSort() == null ? 0 : maxSortObj.getSort();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 填充部门名称
|
|
|
+ */
|
|
|
+ private void fillDeptName(List<ExpertPoolDO> list) {
|
|
|
+ if (CollUtil.isEmpty(list)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 收集所有 deptId
|
|
|
+ Set<Long> deptIds = convertSet(list, ExpertPoolDO::getDeptId, id -> id != null);
|
|
|
+ if (CollUtil.isEmpty(deptIds)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 批量查部门
|
|
|
+ List<DeptRespDTO> depts = deptApi.getDeptList(deptIds);
|
|
|
+ Map<Long, String> deptMap = convertMap(depts, DeptRespDTO::getId, DeptRespDTO::getName);
|
|
|
+ // 填充
|
|
|
+ list.forEach(item -> item.setDeptName(deptMap.get(item.getDeptId())));
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void updateExpertPool(ExpertPoolSaveReqVO updateReqVO) {
|
|
|
// 校验存在
|
|
|
@@ -102,7 +133,9 @@ public class ExpertPoolServiceImpl implements ExpertPoolService {
|
|
|
|
|
|
@Override
|
|
|
public ExpertPoolDO getExpertPool(Long id) {
|
|
|
- return expertPoolMapper.selectById(id);
|
|
|
+ ExpertPoolDO expertPool = expertPoolMapper.selectById(id);
|
|
|
+ fillDeptName(Collections.singletonList(expertPool));
|
|
|
+ return expertPool;
|
|
|
}
|
|
|
|
|
|
@Override
|