新增组织查询调整 ids
This commit is contained in:
@@ -3,6 +3,8 @@ package com.zt.plat.module.system.api.dept.dto;
|
|||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门列表 Request DTO
|
* 部门列表 Request DTO
|
||||||
*
|
*
|
||||||
@@ -24,4 +26,7 @@ public class DeptListReqDTO {
|
|||||||
@Schema(description = "是否集团", example = "false")
|
@Schema(description = "是否集团", example = "false")
|
||||||
private Boolean isGroup;
|
private Boolean isGroup;
|
||||||
|
|
||||||
|
@Schema(description = "部门编号集合,支持多部门查询", example = "[\"1001\", \"1002\"]")
|
||||||
|
private List<String> ids;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,8 @@ package com.zt.plat.module.system.controller.admin.dept.vo.dept;
|
|||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 部门列表 Request VO")
|
@Schema(description = "管理后台 - 部门列表 Request VO")
|
||||||
@Data
|
@Data
|
||||||
public class DeptListReqVO {
|
public class DeptListReqVO {
|
||||||
@@ -21,4 +23,7 @@ public class DeptListReqVO {
|
|||||||
|
|
||||||
@Schema(description = "是否集团", example = "false")
|
@Schema(description = "是否集团", example = "false")
|
||||||
private Boolean isGroup;
|
private Boolean isGroup;
|
||||||
|
|
||||||
|
@Schema(description = "部门编号集合,支持多部门查询", example = "[\"1001\", \"1002\"]")
|
||||||
|
private List<String> ids;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.zt.plat.module.system.dal.mysql.dept;
|
package com.zt.plat.module.system.dal.mysql.dept;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
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.update.UpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
import com.zt.plat.framework.common.enums.CommonStatusEnum;
|
import com.zt.plat.framework.common.enums.CommonStatusEnum;
|
||||||
@@ -11,6 +13,7 @@ import org.apache.ibatis.annotations.Mapper;
|
|||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author chenbowen
|
* @author chenbowen
|
||||||
@@ -19,12 +22,21 @@ import java.util.List;
|
|||||||
public interface DeptMapper extends BaseMapperX<DeptDO> {
|
public interface DeptMapper extends BaseMapperX<DeptDO> {
|
||||||
|
|
||||||
default List<DeptDO> selectList(DeptListReqVO reqVO) {
|
default List<DeptDO> selectList(DeptListReqVO reqVO) {
|
||||||
return selectList(new LambdaQueryWrapperX<DeptDO>()
|
LambdaQueryWrapperX<DeptDO> query = new LambdaQueryWrapperX<DeptDO>()
|
||||||
.likeIfPresent(DeptDO::getName, reqVO.getName())
|
.likeIfPresent(DeptDO::getName, reqVO.getName())
|
||||||
.eqIfPresent(DeptDO::getCode, reqVO.getCode())
|
.eqIfPresent(DeptDO::getCode, reqVO.getCode())
|
||||||
.eqIfPresent(DeptDO::getStatus, reqVO.getStatus())
|
.eqIfPresent(DeptDO::getStatus, reqVO.getStatus())
|
||||||
.eqIfPresent(DeptDO::getIsCompany, reqVO.getIsCompany())
|
.eqIfPresent(DeptDO::getIsCompany, reqVO.getIsCompany())
|
||||||
);
|
.eqIfPresent(DeptDO::getIsGroup, reqVO.getIsGroup());
|
||||||
|
if (CollUtil.isNotEmpty(reqVO.getIds())) {
|
||||||
|
List<Long> ids = reqVO.getIds().stream()
|
||||||
|
.filter(StrUtil::isNotBlank)
|
||||||
|
.map(String::trim)
|
||||||
|
.map(Long::valueOf)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
query.inIfPresent(DeptDO::getId, ids);
|
||||||
|
}
|
||||||
|
return selectList(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
default DeptDO selectByParentIdAndName(Long parentId, String name) {
|
default DeptDO selectByParentIdAndName(Long parentId, String name) {
|
||||||
|
|||||||
@@ -257,12 +257,20 @@ public class DeptServiceImplTest extends BaseDbUnitTest {
|
|||||||
DeptDO dept = randomPojo(DeptDO.class, o -> { // 等会查询到
|
DeptDO dept = randomPojo(DeptDO.class, o -> { // 等会查询到
|
||||||
o.setName("开发部");
|
o.setName("开发部");
|
||||||
o.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
o.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||||
|
o.setParentId(DeptDO.PARENT_ID_ROOT);
|
||||||
|
o.setSort(1);
|
||||||
}).setDeptSource(1);
|
}).setDeptSource(1);
|
||||||
deptMapper.insert(dept);
|
deptMapper.insert(dept);
|
||||||
// 测试 name 不匹配
|
// 测试 name 不匹配
|
||||||
deptMapper.insert(ObjectUtils.cloneIgnoreId(dept, o -> o.setName("发")));
|
deptMapper.insert(ObjectUtils.cloneIgnoreId(dept, o -> {
|
||||||
|
o.setName("发");
|
||||||
|
o.setSort(2);
|
||||||
|
}));
|
||||||
// 测试 status 不匹配
|
// 测试 status 不匹配
|
||||||
deptMapper.insert(ObjectUtils.cloneIgnoreId(dept, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus())));
|
deptMapper.insert(ObjectUtils.cloneIgnoreId(dept, o -> {
|
||||||
|
o.setStatus(CommonStatusEnum.DISABLE.getStatus());
|
||||||
|
o.setSort(3);
|
||||||
|
}));
|
||||||
// 准备参数
|
// 准备参数
|
||||||
DeptListReqVO reqVO = new DeptListReqVO();
|
DeptListReqVO reqVO = new DeptListReqVO();
|
||||||
reqVO.setName("开");
|
reqVO.setName("开");
|
||||||
@@ -275,6 +283,41 @@ public class DeptServiceImplTest extends BaseDbUnitTest {
|
|||||||
assertPojoEquals(dept, sysDeptDOS.get(0));
|
assertPojoEquals(dept, sysDeptDOS.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetDeptList_reqVO_ids() {
|
||||||
|
DeptDO dept1 = randomPojo(DeptDO.class, o -> {
|
||||||
|
o.setName("集团一部");
|
||||||
|
o.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||||
|
o.setParentId(DeptDO.PARENT_ID_ROOT);
|
||||||
|
o.setSort(1);
|
||||||
|
}).setDeptSource(1);
|
||||||
|
deptMapper.insert(dept1);
|
||||||
|
DeptDO dept2 = randomPojo(DeptDO.class, o -> {
|
||||||
|
o.setName("集团二部");
|
||||||
|
o.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||||
|
o.setParentId(DeptDO.PARENT_ID_ROOT);
|
||||||
|
o.setSort(2);
|
||||||
|
}).setDeptSource(1);
|
||||||
|
deptMapper.insert(dept2);
|
||||||
|
DeptDO otherDept = randomPojo(DeptDO.class, o -> {
|
||||||
|
o.setName("其他部门");
|
||||||
|
o.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||||
|
o.setParentId(DeptDO.PARENT_ID_ROOT);
|
||||||
|
o.setSort(3);
|
||||||
|
}).setDeptSource(1);
|
||||||
|
deptMapper.insert(otherDept);
|
||||||
|
|
||||||
|
DeptListReqVO reqVO = new DeptListReqVO();
|
||||||
|
reqVO.setIds(Arrays.asList(String.valueOf(dept1.getId()), String.valueOf(dept2.getId())));
|
||||||
|
|
||||||
|
List<DeptDO> result = deptService.getDeptList(reqVO);
|
||||||
|
|
||||||
|
assertEquals(2, result.size());
|
||||||
|
assertEquals(dept1.getId(), result.get(0).getId());
|
||||||
|
assertEquals(dept2.getId(), result.get(1).getId());
|
||||||
|
assertTrue(result.stream().noneMatch(item -> item.getId().equals(otherDept.getId())));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetChildDeptList() {
|
public void testGetChildDeptList() {
|
||||||
// mock 数据(1 级别子节点)
|
// mock 数据(1 级别子节点)
|
||||||
|
|||||||
Reference in New Issue
Block a user