|
|
@ -24,16 +24,20 @@ import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
|
|
|
import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;
|
|
|
|
import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;
|
|
|
|
import ${basePackage}.config.ActionConfig;
|
|
|
|
import ${basePackage}.config.ActionConfig;
|
|
|
|
import ${basePackage}.frame.auth.LocalData;
|
|
|
|
import ${basePackage}.frame.auth.LocalData;
|
|
|
|
|
|
|
|
import ${basePackage}.frame.auth.Token;
|
|
|
|
import ${basePackage}.frame.base.BaseRequest;
|
|
|
|
import ${basePackage}.frame.base.BaseRequest;
|
|
|
|
import ${basePackage}.frame.base.BaseResponse;
|
|
|
|
import ${basePackage}.frame.base.BaseResponse;
|
|
|
|
import ${basePackage}.frame.base.ErrorType;
|
|
|
|
import ${basePackage}.frame.base.ErrorType;
|
|
|
|
import ${basePackage}.frame.base.Screen;
|
|
|
|
import ${basePackage}.frame.base.Screen;
|
|
|
|
import ${basePackage}.frame.auth.Token;
|
|
|
|
|
|
|
|
import ${basePackage}.frame.utils.AESUtil;
|
|
|
|
import ${basePackage}.frame.utils.AESUtil;
|
|
|
|
import ${basePackage}.frame.utils.LogUtil;
|
|
|
|
import ${basePackage}.frame.utils.LogUtil;
|
|
|
|
import ${basePackage}.frame.utils.MD5Util;
|
|
|
|
import ${basePackage}.frame.utils.MD5Util;
|
|
|
|
import ${basePackage}.frame.utils.MapperUtil;
|
|
|
|
import ${basePackage}.frame.utils.MapperUtil;
|
|
|
|
import ${basePackage}.frame.utils.RequestUtil;
|
|
|
|
import ${basePackage}.frame.utils.RequestUtil;
|
|
|
|
|
|
|
|
import ${basePackage}.frame.utils.StringUtil;
|
|
|
|
|
|
|
|
import ${basePackage}.module.system.mgr.TokensManager;
|
|
|
|
|
|
|
|
import ${basePackage}.module.system.req.TokensBuildRequest;
|
|
|
|
|
|
|
|
import ${basePackage}.module.system.rsp.TokensBuildResponse;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
@ -305,7 +309,6 @@ public class GlobalController implements ErrorController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(path = "/api/{module}/{target}/{method}", method = RequestMethod.POST)
|
|
|
|
@RequestMapping(path = "/api/{module}/{target}/{method}", method = RequestMethod.POST)
|
|
|
|
@ResponseBody
|
|
|
|
@ResponseBody
|
|
|
|
public String api(
|
|
|
|
public String api(
|
|
|
@ -356,9 +359,22 @@ public class GlobalController implements ErrorController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 权限验证
|
|
|
|
// 权限验证
|
|
|
|
if (!LocalData.getToken().hasRes(httpServletRequest.getServletPath())) {
|
|
|
|
if (StringUtil.isNotEmpty(token)) {
|
|
|
|
response.addError(ErrorType.BUSINESS_ERROR, "[" + httpServletRequest.getServletPath() + "]未授权的资源!");
|
|
|
|
TokensManager tokensManager = LocalData.getBean(TokensManager.class);
|
|
|
|
return AESUtil.encrypt2Base64(MapperUtil.toJson(response).getBytes(), appSecret);
|
|
|
|
TokensBuildRequest tokensBuildRequest = new TokensBuildRequest();
|
|
|
|
|
|
|
|
tokensBuildRequest.setToken(token);
|
|
|
|
|
|
|
|
TokensBuildResponse tokensBuildResponse = tokensManager.build(tokensBuildRequest, LocalData.getSysToken());
|
|
|
|
|
|
|
|
LocalData.setToken(tokensBuildResponse.getToken());
|
|
|
|
|
|
|
|
if (!LocalData.getToken().hasRes(httpServletRequest.getServletPath())) {
|
|
|
|
|
|
|
|
response.addError(ErrorType.BUSINESS_ERROR, "[" + httpServletRequest.getServletPath() + "]未授权的资源!");
|
|
|
|
|
|
|
|
return AESUtil.encrypt2Base64(MapperUtil.toJson(response).getBytes(), appSecret);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
String excluded = LocalData.getEnvironment().getProperty("web.url.auth.excluded", "") + ",/api/system/User/login";
|
|
|
|
|
|
|
|
if (!excluded.contains(excluded)) {
|
|
|
|
|
|
|
|
response.addError(ErrorType.BUSINESS_ERROR, "请通过登录接口获取Token!");
|
|
|
|
|
|
|
|
return AESUtil.encrypt2Base64(MapperUtil.toJson(response).getBytes(), appSecret);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 开始处理业务
|
|
|
|
// 开始处理业务
|
|
|
|