data permission
This commit is contained in:
parent
e4b64130c8
commit
3941dce9ee
|
|
@ -9,7 +9,7 @@
|
|||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>bonus-smart-canteen</artifactId>
|
||||
<artifactId>bonus-smart-canteen-v2</artifactId>
|
||||
|
||||
<description>
|
||||
bonus-modules-smart-canteen智慧食堂
|
||||
|
|
|
|||
|
|
@ -87,22 +87,45 @@ public class LeNiuDataPermissionHandler {
|
|||
private String getSqlByAliasAndPermissionType(Long userId, String roleCode, DataPermissionTypeEnum permissionType, String alias) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
if (ObjectUtil.equal(DataPermissionTypeEnum.PERMISSION_ORG, permissionType)) {
|
||||
sb.append(" EXISTS ( ").append(" SELECT null FROM sys_role_dept it1")
|
||||
.append(" LEFT JOIN sys_role it2 ON it2.role_id = it1.role_id")
|
||||
.append(" LEFT JOIN sys_user_role it3 ON it1.role_id = it3.role_id")
|
||||
.append(" WHERE it2.del_flag = 0 AND it2.role_key = '").append(roleCode)
|
||||
.append("' AND it3.user_id = ").append(userId)
|
||||
.append(" AND ").append(alias).append(".org_id = it1.dept_id)");
|
||||
}
|
||||
|
||||
if (ObjectUtil.equal(DataPermissionTypeEnum.PERMISSION_AREA, permissionType)) {
|
||||
sb.append(" EXISTS ( ").append(" SELECT null FROM sys_role_area it1")
|
||||
.append(" LEFT JOIN sys_role it2 ON it2.role_id = it1.role_id")
|
||||
.append(" LEFT JOIN sys_user_role it3 ON it1.role_id = it3.role_id")
|
||||
.append(" WHERE it2.del_flag = 0 AND it2.role_key = '").append(roleCode).append("'")
|
||||
.append(" AND it3.user_id = ").append(userId)
|
||||
.append(" AND ").append(alias).append(".area_id = it1.area_id)");
|
||||
if (roleCode.startsWith(RoleCodeV2Enum.ROLE_ADMIN.key())) {
|
||||
return "";
|
||||
} else {
|
||||
if (ObjectUtil.equal(DataPermissionTypeEnum.PERMISSION_ORG, permissionType)) {
|
||||
sb.append(" EXISTS ( ").append(" SELECT null FROM sys_role_dept it1")
|
||||
.append(" LEFT JOIN sys_role it2 ON it2.role_id = it1.role_id")
|
||||
.append(" LEFT JOIN sys_user_role it3 ON it1.role_id = it3.role_id")
|
||||
.append(" WHERE it2.del_flag = 0 AND it2.role_key = '").append(roleCode)
|
||||
.append("' AND it3.user_id = ").append(userId).append(" AND ")
|
||||
.append(alias).append(".org_id = it1.dept_id)");
|
||||
} else if (ObjectUtil.equal(DataPermissionTypeEnum.PERMISSION_AREA, permissionType)) {
|
||||
sb.append(" EXISTS ( ").append(" SELECT null FROM sys_role_area it1")
|
||||
.append(" LEFT JOIN sys_role it2 ON it2.role_id = it1.role_id")
|
||||
.append(" LEFT JOIN sys_user_role it3 ON it1.role_id = it3.role_id")
|
||||
.append(" WHERE it2.del_flag = 0 AND it2.role_key = '").append(roleCode).append("'")
|
||||
.append(" AND it3.user_id = ").append(userId).append(" AND ")
|
||||
.append(alias).append(".area_id = it1.area_id)");
|
||||
} else if (ObjectUtil.equal(DataPermissionTypeEnum.PERMISSION_CANTEEN, permissionType)) {
|
||||
sb.append(" EXISTS ( ").append(" SELECT null FROM sys_role_canteen it1")
|
||||
.append(" LEFT JOIN sys_role it2 ON it2.role_id = it1.role_id")
|
||||
.append(" LEFT JOIN sys_user_role it3 ON it1.role_id = it3.role_id")
|
||||
.append(" WHERE it2.del_flag = 0 AND it2.role_key = '").append(roleCode).append("'")
|
||||
.append(" AND it3.user_id = ").append(userId).append(" AND ")
|
||||
.append(alias).append(".canteen_id = it1.data_id)");
|
||||
} else if (ObjectUtil.equal(DataPermissionTypeEnum.PERMISSION_SUPERMARKET, permissionType)) {
|
||||
sb.append(" EXISTS ( ").append(" SELECT null FROM sys_role_canteen it1")
|
||||
.append(" LEFT JOIN sys_role it2 ON it2.role_id = it1.role_id")
|
||||
.append(" LEFT JOIN sys_user_role it3 ON it1.role_id = it3.role_id")
|
||||
.append(" WHERE it2.del_flag = 0 AND it2.role_key = '").append(roleCode).append("'")
|
||||
.append(" AND it3.user_id = ").append(userId).append(" AND ")
|
||||
.append(alias).append(".supermarket_id = it1.data_id)");
|
||||
} else if (ObjectUtil.equal(DataPermissionTypeEnum.PERMISSION_WAREHOUSE, permissionType)) {
|
||||
sb.append(" EXISTS ( ").append(" SELECT null FROM sys_role_warehouse it1")
|
||||
.append(" LEFT JOIN sys_role it2 ON it2.role_id = it1.role_id")
|
||||
.append(" LEFT JOIN sys_user_role it3 ON it1.role_id = it3.role_id")
|
||||
.append(" WHERE it2.del_flag = 0 AND it2.role_key = '").append(roleCode).append("'")
|
||||
.append(" AND it3.user_id = ").append(userId).append(" AND ")
|
||||
.append(alias).append(".warehouse_id = it1.warehouse_id)");
|
||||
}
|
||||
}
|
||||
|
||||
// if (roleCode.startsWith(RoleCodeV2Enum.ROLE_ADMIN.key())) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue