org.macrocloud.kernel.security.constant.PermissionConstant Maven / Gradle / Ivy
package org.macrocloud.kernel.security.constant;
import org.macrocloud.kernel.toolkit.utils.StringUtil;
/**
* 权限校验常量
*
*/
public interface PermissionConstant {
/**
* 获取角色所有的权限编号
*
* @param size 数量
* @return string
*/
static String permissionAllStatement(int size) {
return "select scope_path as path from tb_scope_api where id in (select scope_id from tb_role_scope where scope_category = 2 and role_id in (" + buildHolder(size) + "))";
}
/**
* 获取角色指定的权限编号
*
* @param size 数量
* @return string
*/
static String permissionStatement(int size) {
return "select resource_code as code from tb_scope_api where resource_code = ? and id in (select scope_id from tb_role_scope where scope_category = 2 and role_id in (" + buildHolder(size) + "))";
}
/**
* 获取Sql占位符
*
* @param size 数量
* @return String
*/
static String buildHolder(int size) {
StringBuilder builder = StringUtil.builder();
for (int i = 0; i < size; i++) {
builder.append("?,");
}
return StringUtil.removeSuffix(builder.toString(), ",");
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy