mirror of
https://gitee.com/dromara/sa-token.git
synced 2026-02-27 16:50:24 +08:00
修复 sa-token-dialect-thymeleaf 模块代码警告
This commit is contained in:
@@ -51,12 +51,12 @@ public class SaTokenDialect extends AbstractProcessorDialect {
|
|||||||
* 构造方言对象,使用自定义参数
|
* 构造方言对象,使用自定义参数
|
||||||
*
|
*
|
||||||
* @param name 方言名称
|
* @param name 方言名称
|
||||||
* @param recedence 优先级
|
* @param precedence 优先级
|
||||||
* @param stpLogic 使用的 StpLogic 对象
|
* @param stpLogic 使用的 StpLogic 对象
|
||||||
*/
|
*/
|
||||||
public SaTokenDialect(String name, int recedence, StpLogic stpLogic) {
|
public SaTokenDialect(String name, int precedence, StpLogic stpLogic) {
|
||||||
// 名称、前缀、优先级
|
// 名称、前缀、优先级
|
||||||
super(name, name, recedence);
|
super(name, name, precedence);
|
||||||
this.stpLogic = stpLogic;
|
this.stpLogic = stpLogic;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,24 +65,24 @@ public class SaTokenDialect extends AbstractProcessorDialect {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Set<IProcessor> getProcessors(String prefix) {
|
public Set<IProcessor> getProcessors(String prefix) {
|
||||||
return new HashSet<IProcessor>(Arrays.asList(
|
return new HashSet<>(Arrays.asList(
|
||||||
// 登录判断
|
// 登录判断
|
||||||
new SaTokenTagProcessor(prefix, "login", value -> stpLogic.isLogin()),
|
new SaTokenTagProcessor(prefix, "login", value -> stpLogic.isLogin()),
|
||||||
new SaTokenTagProcessor(prefix, "notLogin", value -> stpLogic.isLogin() == false),
|
new SaTokenTagProcessor(prefix, "notLogin", value -> ! stpLogic.isLogin()),
|
||||||
|
|
||||||
// 角色判断
|
// 角色判断
|
||||||
new SaTokenTagProcessor(prefix, "hasRole", value -> stpLogic.hasRole(value)),
|
new SaTokenTagProcessor(prefix, "hasRole", value -> stpLogic.hasRole(value)),
|
||||||
new SaTokenTagProcessor(prefix, "hasRoleOr", value -> stpLogic.hasRoleOr(toArray(value))),
|
new SaTokenTagProcessor(prefix, "hasRoleOr", value -> stpLogic.hasRoleOr(toArray(value))),
|
||||||
new SaTokenTagProcessor(prefix, "hasRoleAnd", value -> stpLogic.hasRoleAnd(toArray(value))),
|
new SaTokenTagProcessor(prefix, "hasRoleAnd", value -> stpLogic.hasRoleAnd(toArray(value))),
|
||||||
new SaTokenTagProcessor(prefix, "lackRole", value -> stpLogic.hasRole(value) == false),
|
new SaTokenTagProcessor(prefix, "lackRole", value -> ! stpLogic.hasRole(value)),
|
||||||
|
|
||||||
// 权限判断
|
// 权限判断
|
||||||
new SaTokenTagProcessor(prefix, "hasPermission", value -> stpLogic.hasPermission(value)),
|
new SaTokenTagProcessor(prefix, "hasPermission", value -> stpLogic.hasPermission(value)),
|
||||||
new SaTokenTagProcessor(prefix, "hasPermissionOr", value -> stpLogic.hasPermissionOr(toArray(value))),
|
new SaTokenTagProcessor(prefix, "hasPermissionOr", value -> stpLogic.hasPermissionOr(toArray(value))),
|
||||||
new SaTokenTagProcessor(prefix, "hasPermissionAnd", value -> stpLogic.hasPermissionAnd(toArray(value))),
|
new SaTokenTagProcessor(prefix, "hasPermissionAnd", value -> stpLogic.hasPermissionAnd(toArray(value))),
|
||||||
new SaTokenTagProcessor(prefix, "lackPermission", value -> stpLogic.hasPermission(value) == false)
|
new SaTokenTagProcessor(prefix, "lackPermission", value -> ! stpLogic.hasPermission(value))
|
||||||
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -92,7 +92,7 @@ public class SaTokenDialect extends AbstractProcessorDialect {
|
|||||||
*/
|
*/
|
||||||
public String[] toArray(String str) {
|
public String[] toArray(String str) {
|
||||||
List<String> list = SaFoxUtil.convertStringToList(str);
|
List<String> list = SaFoxUtil.convertStringToList(str);
|
||||||
return list.toArray(new String[list.size()]);
|
return list.toArray(new String[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,13 +34,13 @@ public class SaTokenTagProcessor extends AbstractAttributeTagProcessor {
|
|||||||
|
|
||||||
Function <String, Boolean> fun;
|
Function <String, Boolean> fun;
|
||||||
|
|
||||||
public SaTokenTagProcessor(final String dialectPrefix, String arrtName, Function <String, Boolean> fun) {
|
public SaTokenTagProcessor(final String dialectPrefix, String attrName, Function <String, Boolean> fun) {
|
||||||
super(
|
super(
|
||||||
TemplateMode.HTML, // This processor will apply only to HTML mode
|
TemplateMode.HTML, // This processor will apply only to HTML mode
|
||||||
dialectPrefix, // Prefix to be applied to name for matching
|
dialectPrefix, // Prefix to be applied to name for matching
|
||||||
null, // No tag name: match any tag name
|
null, // No tag name: match any tag name
|
||||||
false, // No prefix to be applied to tag name
|
false, // No prefix to be applied to tag name
|
||||||
arrtName, // Name of the attribute that will be matched
|
attrName, // Name of the attribute that will be matched
|
||||||
true, // Apply dialect prefix to attribute name
|
true, // Apply dialect prefix to attribute name
|
||||||
10000, // Precedence (inside dialect's own precedence)
|
10000, // Precedence (inside dialect's own precedence)
|
||||||
true); // Remove the matched attribute afterwards
|
true); // Remove the matched attribute afterwards
|
||||||
@@ -53,9 +53,9 @@ public class SaTokenTagProcessor extends AbstractAttributeTagProcessor {
|
|||||||
final AttributeName attributeName, final String attributeValue,
|
final AttributeName attributeName, final String attributeValue,
|
||||||
final IElementTagStructureHandler structureHandler) {
|
final IElementTagStructureHandler structureHandler) {
|
||||||
// 执行表达式返回值为false,则删除这个标签
|
// 执行表达式返回值为false,则删除这个标签
|
||||||
if(this.fun.apply(attributeValue) == false) {
|
if( ! this.fun.apply(attributeValue)) {
|
||||||
structureHandler.removeElement();
|
structureHandler.removeElement();
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user