fix: 修复组织机构相关bug

1. 新增、修改组织机构清理当前用户组织树缓存
2. setOrg 方法取出没必要的 id去重
3. 超级管理员只查看自己的数据
4. 组织机构不可删除BUG
pull/9/head
Parker 3 years ago
parent c2138f379c
commit 5362be8ad6

@ -982,9 +982,9 @@ public class UserUtil {
UserModel user = getUser();
// 如果是超级管理员 则不进行租户处理
// 如果是超级管理员 则不进行租户处理 默认为0
if(StringUtils.equals(SUPER_ADMIN, user.getUsername())){
return null;
return "0";
}
return user.getTenantId();
}

@ -15,7 +15,8 @@
select
count(0)
from
sys_user_org_ref
sys_user_org_ref ref
left join sys_user u on u.id = ref.user_id
${ew.customSqlSegment}
</select>

@ -32,6 +32,7 @@ import org.opsli.core.base.service.impl.CrudServiceImpl;
import org.opsli.core.persistence.querybuilder.GenQueryBuilder;
import org.opsli.core.persistence.querybuilder.QueryBuilder;
import org.opsli.core.persistence.querybuilder.chain.QueryTenantHandler;
import org.opsli.core.utils.UserUtil;
import org.opsli.modulars.system.SystemMsg;
import org.opsli.modulars.system.org.entity.SysOrg;
import org.opsli.modulars.system.org.mapper.SysOrgMapper;
@ -101,6 +102,11 @@ public class SysOrgServiceImpl extends CrudServiceImpl<SysOrgMapper, SysOrg, Sys
sysOrgModel.getId());
}
// 刷新当前用户缓存
UserUtil.refreshUserOrgs(UserUtil.getUser().getId());
UserUtil.refreshUserDefOrg(UserUtil.getUser().getId());
return super.insert(model);
}
@ -159,6 +165,10 @@ public class SysOrgServiceImpl extends CrudServiceImpl<SysOrgMapper, SysOrg, Sys
this.updateChildrenParentIdsByParentId(sysOrgModel.getId());
}
// 刷新当前用户缓存
UserUtil.refreshUserOrgs(UserUtil.getUser().getId());
UserUtil.refreshUserDefOrg(UserUtil.getUser().getId());
// 修改
return updateRet;
}
@ -317,7 +327,8 @@ public class SysOrgServiceImpl extends CrudServiceImpl<SysOrgMapper, SysOrg, Sys
// 如果有租户还在被引用 则不允许删除该租户
QueryWrapper<SysOrg> queryWrapper = new QueryWrapper<>();
queryWrapper.in("org_id",
queryWrapper.eq("u.deleted", DictType.NO_YES_NO.getValue());
queryWrapper.in("ref.org_id",
orgIdList
);
Integer count = mapper.hasUse(queryWrapper);

@ -96,13 +96,6 @@ public class RoleRestController extends BaseRestController<SysRole, RoleModel, I
QueryBuilder<SysRole> queryBuilder = new WebQueryBuilder<>(entityClazz, request.getParameterMap());
QueryWrapper<SysRole> wrapper = queryBuilder.build();
UserModel user = UserUtil.getUser();
// 如果是超级管理员 则查询为空的角色
if(StringUtils.equals(UserUtil.SUPER_ADMIN, user.getUsername())){
// 角色分页 增加租户权限
wrapper.isNull(FieldUtil.humpToUnderline(MyBatisConstants.FIELD_TENANT));
}
Page<SysRole, RoleModel> page = new Page<>(pageNo, pageSize);
page.setQueryWrapper(wrapper);
page = IService.findPage(page);

@ -149,10 +149,6 @@ public class UserOrgRefServiceImpl extends ServiceImpl<UserOrgRefMapper, SysUser
boolean izExistOrg = false;
if(!CollUtil.isEmpty(orgRefList)){
// 去重
orgRefList = ListDistinctUtil.distinct(
orgRefList, Comparator.comparing(SysUserOrgRef::getId));
// 批量保存
izExistOrg = super.saveBatch(orgRefList);
}

Loading…
Cancel
Save