use of com.paascloud.provider.model.domain.UacGroup in project paascloud-master by paascloud.
the class UacGroupServiceImpl method queryById.
@Override
@Transactional(readOnly = true, rollbackFor = Exception.class)
public UacGroup queryById(Long groupId) {
Preconditions.checkArgument(PublicUtil.isNotEmpty(groupId), "组织Id不能为空");
UacGroup query = new UacGroup();
query.setId(groupId);
return uacGroupMapper.selectOne(query);
}
use of com.paascloud.provider.model.domain.UacGroup 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;
}
use of com.paascloud.provider.model.domain.UacGroup in project paascloud-master by paascloud.
the class UacGroupServiceImpl method getGroupTreeListByUserId.
@Override
@Transactional(readOnly = true, rollbackFor = Exception.class)
public List<MenuVo> getGroupTreeListByUserId(Long userId) {
UacGroupUser groupUser = uacGroupUserMapper.getByUserId(userId);
Long groupId = groupUser.getGroupId();
// 查询当前登陆人所在的组织信息
UacGroup currentUserUacGroup = uacGroupMapper.selectByPrimaryKey(groupId);
// 获取当前所选组织的所有子节点
List<GroupZtreeVo> childUacGroupList = this.getGroupTree(currentUserUacGroup.getId());
return this.buildGroupTree(childUacGroupList, groupId);
}
use of com.paascloud.provider.model.domain.UacGroup in project paascloud-master by paascloud.
the class UacGroupServiceImpl method bindUacUser4Group.
/**
* Bind uac user 4 group int.
*
* @param groupBindUserReqDto the group bind user req dto
* @param authResDto the auth res dto
*/
@Override
public void bindUacUser4Group(GroupBindUserReqDto groupBindUserReqDto, LoginAuthDto authResDto) {
if (groupBindUserReqDto == null) {
logger.error("参数不能为空");
throw new IllegalArgumentException("参数不能为空");
}
Long groupId = groupBindUserReqDto.getGroupId();
Long loginUserId = authResDto.getUserId();
List<Long> userIdList = groupBindUserReqDto.getUserIdList();
if (null == groupId) {
throw new IllegalArgumentException("組織ID不能为空");
}
UacGroup group = uacGroupMapper.selectByPrimaryKey(groupId);
if (group == null) {
logger.error("找不到角色信息 groupId={}", groupId);
throw new UacBizException(ErrorCodeEnum.UAC10015001, groupId);
}
if (PublicUtil.isNotEmpty(userIdList) && userIdList.contains(loginUserId)) {
logger.error("不能操作当前登录用户 userId={}", loginUserId);
throw new UacBizException(ErrorCodeEnum.UAC10011023);
}
// 查询超级管理员用户Id集合
List<Long> superUserList = uacRoleUserMapper.listSuperUser(GlobalConstant.Sys.SUPER_MANAGER_ROLE_ID);
List<Long> unionList = Collections3.intersection(userIdList, superUserList);
if (PublicUtil.isNotEmpty(userIdList) && PublicUtil.isNotEmpty(unionList)) {
logger.error("不能操作超级管理员用户 超级用户={}", unionList);
throw new UacBizException(ErrorCodeEnum.UAC10011023);
}
// 1. 先取消对该角色的用户绑定(不包含超级管理员用户)
List<UacGroupUser> groupUsers = uacGroupUserMapper.listByGroupId(groupId);
if (PublicUtil.isNotEmpty(groupUsers)) {
uacGroupUserMapper.deleteExcludeSuperMng(groupId, GlobalConstant.Sys.SUPER_MANAGER_ROLE_ID);
}
if (PublicUtil.isEmpty(userIdList)) {
// 取消该角色的所有用户的绑定
logger.info("取消绑定所有非超级管理员用户成功");
return;
}
// 绑定所选用户
for (Long userId : userIdList) {
UacUser uacUser = uacUserService.queryByUserId(userId);
if (PublicUtil.isEmpty(uacUser)) {
logger.error("找不到绑定的用户 userId={}", userId);
throw new UacBizException(ErrorCodeEnum.UAC10011024, userId);
}
UacGroupUser uacGroupUser = new UacGroupUser();
uacGroupUser.setUserId(userId);
uacGroupUser.setGroupId(groupId);
uacGroupUserMapper.insertSelective(uacGroupUser);
}
}
use of com.paascloud.provider.model.domain.UacGroup in project paascloud-master by paascloud.
the class UacGroupServiceImpl method getById.
@Override
@Transactional(readOnly = true, rollbackFor = Exception.class)
public UacGroup getById(Long id) {
UacGroup uacGroup = uacGroupMapper.selectByPrimaryKey(id);
if (PublicUtil.isEmpty(uacGroup)) {
throw new UacBizException(ErrorCodeEnum.UAC10015001, id);
}
UacGroup parentGroup = uacGroupMapper.selectByPrimaryKey(uacGroup.getPid());
if (parentGroup != null) {
uacGroup.setParentGroupCode(parentGroup.getGroupCode());
uacGroup.setParentGroupName(parentGroup.getGroupName());
}
// 处理饿了吗级联菜单回显地址
Long provinceId = uacGroup.getProvinceId();
Long cityId = uacGroup.getCityId();
Long areaId = uacGroup.getAreaId();
Long streetId = uacGroup.getStreetId();
List<Long> addressList = Lists.newArrayList();
if (provinceId != null) {
addressList.add(provinceId);
}
if (cityId != null) {
addressList.add(cityId);
}
if (areaId != null) {
addressList.add(areaId);
}
if (streetId != null) {
addressList.add(streetId);
}
uacGroup.setAddressList(addressList);
return uacGroup;
}
Aggregations