mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-03-08 07:41:09 +08:00
update 优化 !pr835 相关代码
This commit is contained in:
@@ -4,6 +4,7 @@ import cn.dev33.satoken.annotation.SaCheckLogin;
|
|||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
import cn.dev33.satoken.annotation.SaCheckRole;
|
import cn.dev33.satoken.annotation.SaCheckRole;
|
||||||
import cn.dev33.satoken.annotation.SaIgnore;
|
import cn.dev33.satoken.annotation.SaIgnore;
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
import io.swagger.v3.oas.models.Operation;
|
import io.swagger.v3.oas.models.Operation;
|
||||||
import org.dromara.common.doc.core.model.SaTokenSecurityMetadata;
|
import org.dromara.common.doc.core.model.SaTokenSecurityMetadata;
|
||||||
import org.springframework.web.method.HandlerMethod;
|
import org.springframework.web.method.HandlerMethod;
|
||||||
@@ -113,13 +114,13 @@ public class SaTokenJavadocResolver implements SaTokenMetadataResolver {
|
|||||||
Object type = getAnnotationValue(annotation, "type");
|
Object type = getAnnotationValue(annotation, "type");
|
||||||
Object orRole = getAnnotationValue(annotation, "orRole");
|
Object orRole = getAnnotationValue(annotation, "orRole");
|
||||||
|
|
||||||
String[] values = convertToStringArray(value);
|
String[] values = Convert.toStrArray(value);
|
||||||
String modeStr = mode != null ? mode.toString() : "AND";
|
String modeStr = mode != null ? mode.toString() : "AND";
|
||||||
String typeStr = type != null ? type.toString() : "";
|
String typeStr = type != null ? type.toString() : "";
|
||||||
String[] orRoles = convertToStringArray(orRole);
|
String[] orRoles = Convert.toStrArray(orRole);
|
||||||
|
|
||||||
metadata.addPermission(values, modeStr, typeStr, orRoles);
|
metadata.addPermission(values, modeStr, typeStr, orRoles);
|
||||||
} catch (Exception e) {
|
} catch (Exception ignore) {
|
||||||
// 忽略解析错误
|
// 忽略解析错误
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -153,12 +154,12 @@ public class SaTokenJavadocResolver implements SaTokenMetadataResolver {
|
|||||||
Object mode = getAnnotationValue(annotation, "mode");
|
Object mode = getAnnotationValue(annotation, "mode");
|
||||||
Object type = getAnnotationValue(annotation, "type");
|
Object type = getAnnotationValue(annotation, "type");
|
||||||
|
|
||||||
String[] values = convertToStringArray(value);
|
String[] values = Convert.toStrArray(value);
|
||||||
String modeStr = mode != null ? mode.toString() : "AND";
|
String modeStr = mode != null ? mode.toString() : "AND";
|
||||||
String typeStr = type != null ? type.toString() : "";
|
String typeStr = type != null ? type.toString() : "";
|
||||||
|
|
||||||
metadata.addRole(values, modeStr, typeStr);
|
metadata.addRole(values, modeStr, typeStr);
|
||||||
} catch (Exception e) {
|
} catch (Exception ignore) {
|
||||||
// 忽略解析错误
|
// 忽略解析错误
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -181,20 +182,4 @@ public class SaTokenJavadocResolver implements SaTokenMetadataResolver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 转换为字符串数组
|
|
||||||
*/
|
|
||||||
private String[] convertToStringArray(Object value) {
|
|
||||||
if (value == null) {
|
|
||||||
return new String[0];
|
|
||||||
}
|
|
||||||
if (value instanceof String[]) {
|
|
||||||
return (String[])value;
|
|
||||||
}
|
|
||||||
if (value instanceof String) {
|
|
||||||
return new String[] {(String)value};
|
|
||||||
}
|
|
||||||
return new String[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -228,6 +228,8 @@ public class OpenApiHandler extends OpenAPIService {
|
|||||||
else
|
else
|
||||||
securityParser.buildSecurityRequirement(securityRequirements, operation);
|
securityParser.buildSecurityRequirement(securityRequirements, operation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (javadocProvider.isPresent()) {
|
||||||
String description = javadocProvider.get().getMethodJavadocDescription(handlerMethod.getMethod());
|
String description = javadocProvider.get().getMethodJavadocDescription(handlerMethod.getMethod());
|
||||||
String summary = javadocProvider.get().getFirstSentence(description);
|
String summary = javadocProvider.get().getFirstSentence(description);
|
||||||
if (StringUtils.isNotBlank(description)){
|
if (StringUtils.isNotBlank(description)){
|
||||||
@@ -243,6 +245,8 @@ public class OpenApiHandler extends OpenAPIService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
operation.setDescription(description);
|
operation.setDescription(description);
|
||||||
|
}
|
||||||
|
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,13 +8,13 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SaToken 权限测试
|
* SaToken 权限测试 接口文档输出测试
|
||||||
*
|
*
|
||||||
* @author AprilWind
|
* @author AprilWind
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/demo/SaToken")
|
@RequestMapping("/demo/saTokenDoc")
|
||||||
public class SaTokenTestController {
|
public class SaTokenTestController {
|
||||||
|
|
||||||
// ====================== 基础场景:单一校验规则 ======================
|
// ====================== 基础场景:单一校验规则 ======================
|
||||||
|
|||||||
Reference in New Issue
Block a user