1. 更新语法检查

This commit is contained in:
黄昕 2024-03-07 17:00:01 +08:00
parent 9f1d990647
commit a9ce4ede8f
5 changed files with 17 additions and 16 deletions

View File

@ -13,9 +13,9 @@ import org.springframework.security.core.AuthenticationException;
@Getter
@Setter
public class CommonAuthException extends AuthenticationException {
private ErrorCode err;
private final ErrorCode err;
private String[] description;
private final String[] description;
/**
* Instantiates a new Common auth exception.

View File

@ -31,8 +31,8 @@ public class RequestBodyFilter implements Filter {
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException,
ServletException {
ServletRequest requestWrapper = null;
if (servletRequest instanceof HttpServletRequest) {
requestWrapper = new RequestBodyCacheWrapper((HttpServletRequest) servletRequest);
if (servletRequest instanceof HttpServletRequest httpServletRequest) {
requestWrapper = new RequestBodyCacheWrapper(httpServletRequest);
}
//获取请求中的流如何将取出来的字符串再次转换成流然后把它放入到新request对象中
// 在chain.doFiler方法中传递新的request对象

View File

@ -58,9 +58,9 @@ public class CasbinAuthorizeUtils {
// 添加角色资源权限
roleResourceService.getRoleResourceByRoleId(role.getId()).forEach(k -> {
e.addPermissionForUser(role.getName(), k.getResources().getPath(), k.getResources().getHttpMethod(),
k.getAuthorize() ? "allow" : "deny");
Boolean.TRUE.equals(k.getAuthorize()) ? "allow" : "deny");
log.trace("++++++[{}, {}, {}: {}]", role.getName(), k.getResources().getPath(),
k.getResources().getHttpMethod(), k.getAuthorize() ? "allow" : "deny");
k.getResources().getHttpMethod(), Boolean.TRUE.equals(k.getAuthorize()) ? "allow" : "deny");
});
// 缓存当前权限验证器
@ -85,7 +85,7 @@ public class CasbinAuthorizeUtils {
}
// 角色被禁用
if (!user.getRole().getAvailable()) {
if (Boolean.FALSE.equals(user.getRole().getAvailable())) {
return false;
}
@ -96,13 +96,11 @@ public class CasbinAuthorizeUtils {
for (String s : e.getImplicitRolesForUser(user.getRole().getName())) {
Enforcer se = CasbinAuthorizeUtils.ENFORCER_POOL.get(s);
if (s != null) {
if (se.enforce(s, url, httpMethod)) {
if (s != null && (se.enforce(s, url, httpMethod))) {
return true;
}
}
}
}
return false;
}
}

View File

@ -9,6 +9,9 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serial;
import java.io.Serializable;
/**
* 权限(Role)表实体类
*
@ -20,7 +23,9 @@ import lombok.NoArgsConstructor;
@Table("rbac_role")
@AllArgsConstructor
@NoArgsConstructor
public class Role {
public class Role implements Serializable {
@Serial
private static final long serialVersionUID = -132325343L;
/**
* id
*/

View File

@ -38,9 +38,8 @@ public class CommonFrameworkApi {
@EncryptionProtocol
@DecryptionProtocol
@PostMapping("/version")
@ResponseBody
@OperationLogAnnotation(OperationModule = "通用模块", OperationType = "读取", OperationDesc = "获取当前系统版本信息")
public ProtocolResp<? extends BaseRespStatus> getVersion() {
public ProtocolResp<VersionResp> getVersion() {
return ProtocolResp.result(VersionResp.builder()
.version(VersionInfo.builder()
.commitId(prgVer.getCommitId())
@ -59,10 +58,9 @@ public class CommonFrameworkApi {
* @return the version v 2
*/
@GetMapping("/version")
@ResponseBody
@EncryptionProtocol
@OperationLogAnnotation(OperationModule = "通用模块", OperationType = "读取", OperationDesc = "获取当前系统版本信息")
public ProtocolResp<? extends BaseRespStatus> getVersionV2() {
public ProtocolResp<VersionResp> getVersionV2() {
return ProtocolResp.result(VersionResp.builder()
.version(VersionInfo.builder()
.commitId(prgVer.getCommitId())