新增 是否为虚机构字段,部门查询时判断进行判断,是否显示虚机构
隐藏虚机构时,自动设置虚机构得父部门id至虚机构所有子部门中
This commit is contained in:
parent
0ee3e8b974
commit
7aa867aed0
@ -31,4 +31,7 @@ public class DeptRespDTO {
|
||||
@Schema(description = "部门状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer status; // 参见 CommonStatusEnum 枚举
|
||||
|
||||
@Schema(description = "是否为虚机构 | 0否 1是")
|
||||
private Integer virtuallyStatus;
|
||||
|
||||
}
|
||||
|
@ -27,9 +27,12 @@ public class UserSaveRespDTO {
|
||||
@Schema(description = "部门ID", example = "我是一个用户")
|
||||
private Long deptId;
|
||||
|
||||
@Schema(description = "岗位编号数组", example = "1")
|
||||
@Schema(description = "职称编号数组", example = "1")
|
||||
private Set<Long> postIds;
|
||||
|
||||
@Schema(description = "岗位编号数", example = "1")
|
||||
private Long positionId;
|
||||
|
||||
@Schema(description = "手机号码", example = "15601691300")
|
||||
@Mobile
|
||||
private String mobile;
|
||||
|
@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
|
||||
@ -68,6 +69,27 @@ public class DeptController {
|
||||
@PreAuthorize("@ss.hasPermission('system:dept:query')")
|
||||
public CommonResult<List<DeptRespVO>> getDeptList(DeptListReqVO reqVO) {
|
||||
List<DeptDO> list = deptService.getDeptList(reqVO);
|
||||
|
||||
if (reqVO.getVirtuallyStatus() == 1) {
|
||||
|
||||
// 获得所有得虚机构部门信息
|
||||
List<DeptDO> virtuallyDeptId = list.stream()
|
||||
.filter(dept -> dept.getVirtuallyStatus() == 1)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 移除虚机构,不展示
|
||||
list.removeIf(dept -> dept.getVirtuallyStatus() == 1);
|
||||
|
||||
virtuallyDeptId.forEach(data -> {
|
||||
|
||||
// 将虚机构的子部门,父部门设置为虚机构的父部门
|
||||
list.stream().filter(dept -> dept.getParentId().equals(data.getId()))
|
||||
.map(dept -> dept.setParentId(data.getParentId()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
return success(BeanUtils.toBean(list, DeptRespVO.class));
|
||||
}
|
||||
|
||||
@ -76,6 +98,24 @@ public class DeptController {
|
||||
public CommonResult<List<DeptSimpleRespVO>> getSimpleDeptList() {
|
||||
List<DeptDO> list = deptService.getDeptList(
|
||||
new DeptListReqVO().setStatus(CommonStatusEnum.ENABLE.getStatus()));
|
||||
|
||||
// 获得所有得虚机构部门信息
|
||||
List<DeptDO> virtuallyDeptId = list.stream()
|
||||
.filter(dept -> dept.getVirtuallyStatus() == 1)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 移除虚机构,不展示
|
||||
list.removeIf(dept -> dept.getVirtuallyStatus() == 1);
|
||||
|
||||
virtuallyDeptId.forEach(data -> {
|
||||
|
||||
// 将虚机构的子部门,父部门设置为虚机构的父部门
|
||||
list.stream().filter(dept -> dept.getParentId().equals(data.getId()))
|
||||
.map(dept -> dept.setParentId(data.getParentId()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
});
|
||||
|
||||
return success(BeanUtils.toBean(list, DeptSimpleRespVO.class));
|
||||
}
|
||||
|
||||
@ -85,6 +125,24 @@ public class DeptController {
|
||||
public CommonResult<List<DeptSimpleRespVO>> getAllDeptList() {
|
||||
List<DeptDO> list = deptService.getDeptList(
|
||||
new DeptListReqVO().setStatus(CommonStatusEnum.ENABLE.getStatus()));
|
||||
|
||||
// 获得所有得虚机构部门信息
|
||||
List<DeptDO> virtuallyDeptId = list.stream()
|
||||
.filter(dept -> dept.getVirtuallyStatus() == 1)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 移除虚机构,不展示
|
||||
list.removeIf(dept -> dept.getVirtuallyStatus() == 1);
|
||||
|
||||
virtuallyDeptId.forEach(data -> {
|
||||
|
||||
// 将虚机构的子部门,父部门设置为虚机构的父部门
|
||||
list.stream().filter(dept -> dept.getParentId().equals(data.getId()))
|
||||
.map(dept -> dept.setParentId(data.getParentId()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
});
|
||||
|
||||
return success(BeanUtils.toBean(list, DeptSimpleRespVO.class));
|
||||
}
|
||||
|
||||
|
@ -13,4 +13,6 @@ public class DeptListReqVO {
|
||||
@Schema(description = "展示状态,参见 CommonStatusEnum 枚举类", example = "1")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "是否为虚机构 | 0否 1是")
|
||||
private Integer virtuallyStatus;
|
||||
}
|
||||
|
@ -36,6 +36,9 @@ public class DeptRespVO {
|
||||
@Schema(description = "状态,见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "是否为虚机构 | 0否 1是")
|
||||
private Integer virtuallyStatus;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "时间戳格式")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
|
@ -49,4 +49,7 @@ public class DeptSaveReqVO {
|
||||
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "是否为虚机构 | 0否 1是")
|
||||
private Integer virtuallyStatus;
|
||||
|
||||
}
|
||||
|
@ -20,4 +20,6 @@ public class DeptSimpleRespVO {
|
||||
@Schema(description = "父部门 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long parentId;
|
||||
|
||||
@Schema(description = "是否为虚机构 | 0否 1是")
|
||||
private Integer virtuallyStatus;
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ public class FactoryUserController {
|
||||
return success("true");
|
||||
}else {
|
||||
|
||||
return error(-1, msg);
|
||||
return error(-1, "照片下发异常!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,4 +75,9 @@ public class DeptDO extends TenantBaseDO {
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 是否为虚机构 | 0否 1是
|
||||
*/
|
||||
private Integer virtuallyStatus;
|
||||
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public class DeptServiceImpl implements DeptService {
|
||||
DeptDO dept = BeanUtils.toBean(createReqVO, DeptDO.class);
|
||||
deptMapper.insert(dept);
|
||||
|
||||
if (dept.getParentId().toString().equals("0")) {
|
||||
if ("0".equals(dept.getParentId().toString())) {
|
||||
|
||||
dept.setLevel(0);
|
||||
dept.setFlag(dept.getId().toString());
|
||||
|
@ -62,7 +62,7 @@ public class FactoryUserServiceImpl implements FactoryUserService{
|
||||
private WebsocketService websocketService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class) // 异常回滚
|
||||
// @Transactional(rollbackFor = Exception.class) // 异常回滚
|
||||
public String createUser(FactoryUserSaveReqVO createReqVO){
|
||||
|
||||
// 校验账户配合
|
||||
@ -119,7 +119,7 @@ public class FactoryUserServiceImpl implements FactoryUserService{
|
||||
} catch (Exception ex) {
|
||||
|
||||
// 手动回滚
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
return ex.getMessage();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user