BMS计费引擎模块数据权限隔离修改调整

This commit is contained in:
秦鸿展
2026-02-25 15:34:15 +08:00
parent e30aef6305
commit 2706bb3225
4 changed files with 74 additions and 8 deletions
@@ -45,10 +45,40 @@ public class BillingRulesApplicationService {
public List<BillingRulesPO> queryList(BillingRulesDO billingRulesDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null){
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1){
billingRulesDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
if (loginUser != null && loginUser.getUserPo() != null) {
Long userOrganizationId = loginUser.getUserPo().getOrganizationId();
Long frontendOrganizationId = billingRulesDO.getOrganizationId(); // 前端传递的 organizationId
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己且 topOrganizationId=2827
if (userOrganizationId != null && userOrganizationId == 2827L) {
// 南光组织(organizationId=2827):可以查询所有组织的数据
if (frontendOrganizationId != null) {
// 前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
billingRulesDO.setOrganizationId(frontendOrganizationId);
billingRulesDO.setTopOrganizationId(null); // 明确设置为 null,避免使用 topOrganizationId 条件
} else {
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
billingRulesDO.setOrganizationId(null);
billingRulesDO.setTopOrganizationId(null);
}
} else {
// 其他组织:设置organizationId为当前组织ID,并且设置topOrganizationId=2827
// 如果前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
if (frontendOrganizationId != null && userOrganizationId != null) {
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
if (!frontendOrganizationId.equals(userOrganizationId)) {
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
billingRulesDO.setOrganizationId(userOrganizationId);
}
// 如果前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
} else {
// 前端没有传递 organizationId,使用当前登录用户的组织ID
if (userOrganizationId != null) {
billingRulesDO.setOrganizationId(userOrganizationId);
}
}
// 对于非2827组织,必须设置 topOrganizationId=2827
billingRulesDO.setTopOrganizationId(2827L);
}
}
return billingRulesDomainService.queryList(billingRulesDO);
@@ -48,10 +48,40 @@ public class DocumentTypeApplicationService {
public List<DocumentTypePO> queryList(DocumentTypeDO documentTypeDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null){
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1){
documentTypeDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
if (loginUser != null && loginUser.getUserPo() != null) {
Long userOrganizationId = loginUser.getUserPo().getOrganizationId();
Long frontendOrganizationId = documentTypeDO.getOrganizationId(); // 前端传递的 organizationId
// 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己且 topOrganizationId=2827
if (userOrganizationId != null && userOrganizationId == 2827L) {
// 南光组织(organizationId=2827):可以查询所有组织的数据
if (frontendOrganizationId != null) {
// 前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
documentTypeDO.setOrganizationId(frontendOrganizationId);
documentTypeDO.setTopOrganizationId(null); // 明确设置为 null,避免使用 topOrganizationId 条件
} else {
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
documentTypeDO.setOrganizationId(null);
documentTypeDO.setTopOrganizationId(null);
}
} else {
// 其他组织:设置organizationId为当前组织ID,并且设置topOrganizationId=2827
// 如果前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
if (frontendOrganizationId != null && userOrganizationId != null) {
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
if (!frontendOrganizationId.equals(userOrganizationId)) {
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
documentTypeDO.setOrganizationId(userOrganizationId);
}
// 如果前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
} else {
// 前端没有传递 organizationId,使用当前登录用户的组织ID
if (userOrganizationId != null) {
documentTypeDO.setOrganizationId(userOrganizationId);
}
}
// 对于非2827组织,必须设置 topOrganizationId=2827
documentTypeDO.setTopOrganizationId(2827L);
}
}
return documentTypeDomainService.queryList(documentTypeDO);
@@ -100,6 +100,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="billingRulesDO.createByName != null and billingRulesDO.createByName != ''">
AND create_by_name like concat('%', #{billingRulesDO.createByName}, '%')
</if>
<if test="billingRulesDO.organizationId != null">
and organization_id = #{billingRulesDO.organizationId}
</if>
</sql>
</mapper>
@@ -89,6 +89,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{code}
</foreach>
</if>
<if test="documentTypeDO.organizationId != null">
and organization_id = #{documentTypeDO.organizationId}
</if>
</sql>
</mapper>