use of com.paascloud.provider.model.vo.GroupZtreeVo in project paascloud-master by paascloud.
the class UacGroupServiceImpl method buildNode.
private List<GroupZtreeVo> buildNode(List<UacGroup> groupList, List<GroupZtreeVo> tree) {
for (UacGroup group : groupList) {
GroupZtreeVo groupZTreeVo = buildGroupZTreeVoByGroup(group);
if (0L == group.getPid()) {
groupZTreeVo.setOpen(true);
}
// 设置根节点
tree.add(groupZTreeVo);
UacGroup query = new UacGroup();
query.setPid(group.getId());
List<UacGroup> groupChildrenList = uacGroupMapper.select(query);
// 有子节点 递归查询
if (PublicUtil.isNotEmpty(groupChildrenList)) {
buildNode(groupChildrenList, tree);
}
}
return tree;
}
use of com.paascloud.provider.model.vo.GroupZtreeVo in project paascloud-master by paascloud.
the class UacGroupServiceImpl method buildGroupTree.
private List<MenuVo> buildGroupTree(List<GroupZtreeVo> childUacGroupList, Long currentGroupId) {
List<MenuVo> listVo = Lists.newArrayList();
MenuVo menuVo;
for (GroupZtreeVo group : childUacGroupList) {
menuVo = new MenuVo();
menuVo.setId(group.getId());
if (currentGroupId.equals(group.getId())) {
menuVo.setPid(0L);
} else {
menuVo.setPid(group.getpId());
}
menuVo.setMenuCode(group.getGroupCode());
menuVo.setMenuName(group.getGroupName());
listVo.add(menuVo);
}
return TreeUtil.getChildMenuVos(listVo, 0L);
}
use of com.paascloud.provider.model.vo.GroupZtreeVo in project paascloud-master by paascloud.
the class UacGroupServiceImpl method buildGroupZTreeVoByGroup.
private GroupZtreeVo buildGroupZTreeVoByGroup(UacGroup group) {
GroupZtreeVo vo = new GroupZtreeVo();
vo.setId(group.getId());
vo.setpId(group.getPid());
vo.setName(group.getGroupName());
vo.setType(group.getType());
vo.setStatus(group.getStatus());
vo.setLeaf(group.getLevel());
vo.setLevel(group.getLevel());
vo.setGroupCode(group.getGroupCode());
vo.setContact(group.getContact());
vo.setContactPhone(group.getContactPhone());
vo.setCreatedTime(group.getCreatedTime() == null ? new Date() : group.getCreatedTime());
vo.setCreator(group.getCreator());
vo.setGroupAddress(group.getGroupAddress());
vo.setGroupName(group.getGroupName());
return vo;
}
use of com.paascloud.provider.model.vo.GroupZtreeVo in project paascloud-master by paascloud.
the class UacGroupCommonController method getGroupTreeById.
/**
* 根据当前登录人查询组织列表
*
* @return the group tree by id
*/
@PostMapping(value = "/getGroupTree")
@ApiOperation(httpMethod = "POST", value = "根据当前登录人查询组织列表")
public Wrapper<List<GroupZtreeVo>> getGroupTreeById() {
logger.info("根据当前登录人查询组织列表");
LoginAuthDto loginAuthDto = super.getLoginAuthDto();
Long groupId = loginAuthDto.getGroupId();
UacGroup uacGroup = uacGroupService.queryById(groupId);
List<GroupZtreeVo> tree = uacGroupService.getGroupTree(uacGroup.getId());
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, "操作成功", tree);
}
use of com.paascloud.provider.model.vo.GroupZtreeVo in project paascloud-master by paascloud.
the class UacGroupServiceImpl method updateUacGroupStatusById.
@Override
public int updateUacGroupStatusById(IdStatusDto idStatusDto, LoginAuthDto loginAuthDto) {
Long groupId = idStatusDto.getId();
Integer status = idStatusDto.getStatus();
UacGroup uacGroup = new UacGroup();
uacGroup.setId(groupId);
uacGroup.setStatus(status);
UacGroup group = uacGroupMapper.selectByPrimaryKey(groupId);
if (PublicUtil.isEmpty(group)) {
throw new UacBizException(ErrorCodeEnum.UAC10015001, groupId);
}
if (!UacGroupStatusEnum.contains(status)) {
throw new UacBizException(ErrorCodeEnum.UAC10015002);
}
// 查询所有的组织
List<UacGroup> totalGroupList = uacGroupMapper.selectAll();
List<GroupZtreeVo> totalList = Lists.newArrayList();
GroupZtreeVo zTreeVo;
for (UacGroup vo : totalGroupList) {
zTreeVo = new GroupZtreeVo();
zTreeVo.setId(vo.getId());
totalList.add(zTreeVo);
}
UacGroupUser uacGroupUser = new UacGroupUser();
uacGroupUser.setUserId(loginAuthDto.getUserId());
UacGroupUser groupUser = uacGroupUserMapper.selectOne(uacGroupUser);
// 查询当前登陆人所在的组织信息
UacGroup currentUserUacGroup = uacGroupMapper.selectByPrimaryKey(groupUser.getGroupId());
// 查询当前登陆人能禁用的所有子节点
List<GroupZtreeVo> childGroupList = this.getGroupTree(currentUserUacGroup.getId());
// 计算不能禁用的组织= 所有的组织 - 禁用的所有子节点
totalList.removeAll(childGroupList);
// 判断所选的组织是否在不能禁用的列表里
GroupZtreeVo zTreeVo1 = new GroupZtreeVo();
zTreeVo1.setId(group.getId());
if (totalList.contains(zTreeVo1)) {
throw new UacBizException(ErrorCodeEnum.UAC10011023);
}
if (groupUser.getGroupId().equals(uacGroup.getId()) && UacGroupStatusEnum.ENABLE.getStatus() == group.getStatus()) {
throw new UacBizException(ErrorCodeEnum.UAC10011023);
}
uacGroup.setGroupName(group.getGroupName());
uacGroup.setGroupCode(group.getGroupCode());
uacGroup.setVersion(group.getVersion() + 1);
int result = uacGroupMapper.updateByPrimaryKeySelective(uacGroup);
// 获取当前所选组织的所有子节点
List<GroupZtreeVo> childUacGroupList = this.getGroupTree(uacGroup.getId());
// 批量修改组织状态
if (PublicUtil.isNotEmpty(childUacGroupList)) {
UacGroup childGroup;
for (GroupZtreeVo uacGroup1 : childUacGroupList) {
if (UacGroupStatusEnum.ENABLE.getStatus() == status) {
UacGroup parentGroup = uacGroupMapper.selectByPrimaryKey(uacGroup1.getpId());
if (parentGroup.getStatus() == UacGroupStatusEnum.DISABLE.getStatus()) {
throw new UacBizException(ErrorCodeEnum.UAC10015003);
}
}
childGroup = new UacGroup();
childGroup.setStatus(uacGroup.getStatus());
childGroup.setId(uacGroup1.getId());
result = uacGroupMapper.updateByPrimaryKeySelective(childGroup);
if (result < 1) {
throw new UacBizException(ErrorCodeEnum.UAC10015006, uacGroup1.getId());
}
}
}
return result;
}
Aggregations