类 UserDataPowerService
java.lang.Object
net.sohelp.boot.admin.core.service.power.UserDataPowerService
数据权限服务类,用于根据用户权限类型生成相应的数据访问控制SQL片段。
- 从以下版本开始:
- 2023/8/2 13:51
- 作者:
- AaronFung
-
构造器概要
构造器 -
方法概要
-
构造器详细资料
-
UserDataPowerService
public UserDataPowerService()
-
-
方法详细资料
-
getPowerSQL
@Comment("\u83b7\u53d6\u6570\u636e\u6743\u9650SQL") public String getPowerSQL(String fieldName, int loginUserId) throws SQLException 根据用户的权限类型和ID,生成对应的数据权限SQL条件语句。权限类型说明: - power_type = 1:机构权限,查询该用户所在机构下所有用户的ID - power_type = 2:自定义权限,直接使用用户配置的可见用户列表 - power_type = 3:角色权限,查找具有相同角色的所有用户ID(当前实现存在逻辑问题)
- 参数:
fieldName- 查询字段名,通常是用户表中的某个外键字段如"user_id"loginUserId- 当前登录用户的ID- 返回:
- 返回一个可用于WHERE子句的SQL字符串,例如:" user_id in (1,2,3)" 或 " 1=1 "
- 抛出:
SQLException- 当数据库操作异常或用户不存在时抛出此异常
-