|
@@ -6,6 +6,7 @@ import com.persagy.fm.common.utils.ResultHelper;
|
|
import com.persagy.fm.department.model.ConvertDepartmentTool;
|
|
import com.persagy.fm.department.model.ConvertDepartmentTool;
|
|
import com.persagy.fm.department.model.Department;
|
|
import com.persagy.fm.department.model.Department;
|
|
import com.persagy.fm.department.model.dto.*;
|
|
import com.persagy.fm.department.model.dto.*;
|
|
|
|
+import com.persagy.fm.department.model.vo.ManagerVO;
|
|
import com.persagy.fm.department.model.vo.ResponseDepartmentItemVO;
|
|
import com.persagy.fm.department.model.vo.ResponseDepartmentItemVO;
|
|
import com.persagy.fm.department.model.vo.ResponseDepartmentListItemVO;
|
|
import com.persagy.fm.department.model.vo.ResponseDepartmentListItemVO;
|
|
import com.persagy.fm.department.model.vo.ResponseDepartmentTreeItemVO;
|
|
import com.persagy.fm.department.model.vo.ResponseDepartmentTreeItemVO;
|
|
@@ -20,6 +21,7 @@ import com.persagy.fm.translate.model.Transes;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.assertj.core.util.Lists;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
@@ -63,43 +65,40 @@ public class DepartmentController {
|
|
@ApiOperation(value = "部门详情")
|
|
@ApiOperation(value = "部门详情")
|
|
@PostMapping("/get")
|
|
@PostMapping("/get")
|
|
// TODO: 2021/3/24 使用翻译器
|
|
// TODO: 2021/3/24 使用翻译器
|
|
- @Transes({
|
|
|
|
- @Trans(source = "personNameTranslator",
|
|
|
|
- type = TransType.SERVICE, batch = true,
|
|
|
|
- parameter = "managers", target = "managersShowName"),
|
|
|
|
-// @Trans(source = "com.persagy.fm.person.service.IPersonTransBatchHandler",
|
|
|
|
-// type = TransType.SERVICE, result = "name", batch = true,
|
|
|
|
-// condition = "id", parameter = "projectIds", target = "projectsShowName")
|
|
|
|
- })
|
|
|
|
- @Trans(type = TransType.SERVICE, batch = true, source = "personNameTranslator", parameter = "managers", target = "managerShowName")
|
|
|
|
|
|
+// @Transes({
|
|
|
|
+// @Trans(source = "personNameTranslator",
|
|
|
|
+// type = TransType.SERVICE, batch = true,
|
|
|
|
+// parameter = "managerIds", target = "managerObjs"),
|
|
|
|
+//// @Trans(source = "com.persagy.fm.person.service.IPersonTransBatchHandler",
|
|
|
|
+//// type = TransType.SERVICE, result = "name", batch = true,
|
|
|
|
+//// condition = "id", parameter = "projectIds", target = "projectsShowName")
|
|
|
|
+// })
|
|
public CommonResult<ResponseDepartmentItemVO> queryDepartmentDetail(
|
|
public CommonResult<ResponseDepartmentItemVO> queryDepartmentDetail(
|
|
@Valid @RequestBody QueryDepartmentDetailDTO queryDepartmentDetailDTO) {
|
|
@Valid @RequestBody QueryDepartmentDetailDTO queryDepartmentDetailDTO) {
|
|
Department department = departmentService.queryDepartmentDetail(queryDepartmentDetailDTO.getId());
|
|
Department department = departmentService.queryDepartmentDetail(queryDepartmentDetailDTO.getId());
|
|
ResponseDepartmentItemVO responseDepartmentItemVO = ConvertDepartmentTool.INSTANCE.convert2ResponseItemDTO(department);
|
|
ResponseDepartmentItemVO responseDepartmentItemVO = ConvertDepartmentTool.INSTANCE.convert2ResponseItemDTO(department);
|
|
- // 部门负责人转换为列表
|
|
|
|
- String managers = department.getManagers();
|
|
|
|
- List<Long> managerIdList = change2ManagerIdList(managers);
|
|
|
|
- responseDepartmentItemVO.setManagers(managerIdList);
|
|
|
|
|
|
+ List<ManagerVO> test = test(department.getManagers());
|
|
|
|
+ responseDepartmentItemVO.setManagerObjs(test);
|
|
return ResultHelper.single(responseDepartmentItemVO);
|
|
return ResultHelper.single(responseDepartmentItemVO);
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * 将部门负责人转换为负责人id列表
|
|
|
|
- *
|
|
|
|
- * @param managers 负责人id字符串:id,id,id
|
|
|
|
- * @return 负责人id列表
|
|
|
|
- * @author lixing
|
|
|
|
- * @version V1.0 2021/3/24 11:09 上午
|
|
|
|
- */
|
|
|
|
- private List<Long> change2ManagerIdList(String managers) {
|
|
|
|
- if (StringUtils.isNotBlank(managers)) {
|
|
|
|
- String[] managersArray = managers.split(",");
|
|
|
|
- List<String> managerStrList = Arrays.asList(managersArray);
|
|
|
|
- return managerStrList.stream().map(Long::valueOf).collect(Collectors.toList());
|
|
|
|
|
|
+ @Trans(source = "personNameTranslator",
|
|
|
|
+ type = TransType.SERVICE, batch = true,
|
|
|
|
+ parameter = "id", target = "name")
|
|
|
|
+ private List<ManagerVO> test(String manager) {
|
|
|
|
+ String[] ids = manager.split(",");
|
|
|
|
+ if (ids.length == 0) {
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
- return null;
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
+ List<ManagerVO> result = Lists.newArrayList();
|
|
|
|
+ for (String id : ids) {
|
|
|
|
+ ManagerVO managerVO = new ManagerVO();
|
|
|
|
+ managerVO.setId(Long.valueOf(id));
|
|
|
|
+ result.add(managerVO);
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
|
|
@ApiOperation(value = "更新部门")
|
|
@ApiOperation(value = "更新部门")
|
|
@PostMapping("/update")
|
|
@PostMapping("/update")
|
|
@@ -173,8 +172,8 @@ public class DepartmentController {
|
|
@ApiOperation(value = "部门项目树")
|
|
@ApiOperation(value = "部门项目树")
|
|
@PostMapping("/projects/tree")
|
|
@PostMapping("/projects/tree")
|
|
public CommonResult<PageList<ProjectTreeItemVO>> queryDepProjectTree(
|
|
public CommonResult<PageList<ProjectTreeItemVO>> queryDepProjectTree(
|
|
- @Valid @RequestBody DeleteDepartmentDTO deleteDepartmentDTO) {
|
|
|
|
- List<ProjectTreeItemVO> projectTreeItemVOList = depProjectService.queryDepProjectTree(deleteDepartmentDTO.getId());
|
|
|
|
|
|
+ @Valid @RequestBody QueryDepProjectTreeDTO queryDepProjectTreeDTO) {
|
|
|
|
+ List<ProjectTreeItemVO> projectTreeItemVOList = depProjectService.queryDepProjectTree(queryDepProjectTreeDTO.getParentDepId());
|
|
return ResultHelper.multi(projectTreeItemVOList);
|
|
return ResultHelper.multi(projectTreeItemVOList);
|
|
}
|
|
}
|
|
|
|
|