|
@@ -9,6 +9,7 @@ import com.google.common.collect.Lists;
|
|
import com.persagy.common.enums.ResponseCode;
|
|
import com.persagy.common.enums.ResponseCode;
|
|
import com.persagy.common.exception.BusinessException;
|
|
import com.persagy.common.exception.BusinessException;
|
|
import com.persagy.fm.common.constant.DefaultValueConstants;
|
|
import com.persagy.fm.common.constant.DefaultValueConstants;
|
|
|
|
+import com.persagy.fm.common.constant.PageQueryConstants;
|
|
import com.persagy.fm.common.constant.enums.BoolEnum;
|
|
import com.persagy.fm.common.constant.enums.BoolEnum;
|
|
import com.persagy.fm.common.constant.enums.ValidEnum;
|
|
import com.persagy.fm.common.constant.enums.ValidEnum;
|
|
import com.persagy.fm.common.context.DefaultAppContext;
|
|
import com.persagy.fm.common.context.DefaultAppContext;
|
|
@@ -162,17 +163,11 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
|
* @version V1.0 2021/3/12 10:49 上午
|
|
* @version V1.0 2021/3/12 10:49 上午
|
|
*/
|
|
*/
|
|
private void checkDuplicateDeptName(String depName, String parentId) {
|
|
private void checkDuplicateDeptName(String depName, String parentId) {
|
|
- // 拼装查询参数
|
|
|
|
- QueryDepartmentDTO queryDepartmentDTO = new QueryDepartmentDTO();
|
|
|
|
- queryDepartmentDTO.setName(depName);
|
|
|
|
- queryDepartmentDTO.setParentId(parentId);
|
|
|
|
-
|
|
|
|
- // 查询
|
|
|
|
- List<Department> departments = queryDepartmentList(queryDepartmentDTO);
|
|
|
|
|
|
+ List<Department> departments = queryByNameAndParentId(depName, parentId);
|
|
|
|
|
|
// 处理查询结果
|
|
// 处理查询结果
|
|
if (!CollectionUtils.isEmpty(departments)) {
|
|
if (!CollectionUtils.isEmpty(departments)) {
|
|
- throw new BusinessException(ResponseCode.B0300.getCode(), "创建部门失败,部门名称重复");
|
|
|
|
|
|
+ throw new BusinessException(ResponseCode.B0300.getCode(), "部门名称重复");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -382,6 +377,8 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
|
}
|
|
}
|
|
|
|
|
|
PageQueryPersonDTO pageQueryPersonDTO = new PageQueryPersonDTO();
|
|
PageQueryPersonDTO pageQueryPersonDTO = new PageQueryPersonDTO();
|
|
|
|
+ pageQueryPersonDTO.setPage(PageQueryConstants.DEFAULT_PAGE);
|
|
|
|
+ pageQueryPersonDTO.setSize(PageQueryConstants.DEFAULT_SIZE);
|
|
pageQueryPersonDTO.setDepId(id);
|
|
pageQueryPersonDTO.setDepId(id);
|
|
IPage<ResponsePersonListItemVO> responsePersonListItemVOIPage = personService.pageQueryPerson(pageQueryPersonDTO);
|
|
IPage<ResponsePersonListItemVO> responsePersonListItemVOIPage = personService.pageQueryPerson(pageQueryPersonDTO);
|
|
if (responsePersonListItemVOIPage.getTotal() > 0) {
|
|
if (responsePersonListItemVOIPage.getTotal() > 0) {
|
|
@@ -399,6 +396,23 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
|
updateById(department);
|
|
updateById(department);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 根据名称和父部门id精确查询
|
|
|
|
+ *
|
|
|
|
+ * @param name 部门名称
|
|
|
|
+ * @param parentId 父部门id
|
|
|
|
+ * @return 满足条件的部门列表
|
|
|
|
+ * @author lixing
|
|
|
|
+ * @version V1.0 2021/4/12 4:45 下午
|
|
|
|
+ */
|
|
|
|
+ public List<Department> queryByNameAndParentId(String name, String parentId) {
|
|
|
|
+ QueryWrapper<Department> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ queryWrapper.eq(Department.PROP_VALID, ValidEnum.TRUE.getType());
|
|
|
|
+ queryWrapper.eq(Department.PROP_NAME, name);
|
|
|
|
+ queryWrapper.eq(Department.PROP_PARENT_ID, parentId);
|
|
|
|
+ return list(queryWrapper);
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public List<Department> queryDepartmentList(QueryDepartmentDTO queryDepartmentDTO) {
|
|
public List<Department> queryDepartmentList(QueryDepartmentDTO queryDepartmentDTO) {
|
|
QueryWrapper<Department> queryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<Department> queryWrapper = new QueryWrapper<>();
|