|
|
|
@ -1,12 +1,5 @@
|
|
|
|
|
package ${basePackage}.action;
|
|
|
|
|
|
|
|
|
|
import ${basePackage}.config.ActionConfig;
|
|
|
|
|
import ${basePackage}.frame.auth.LocalData;
|
|
|
|
|
import ${basePackage}.frame.base.*;
|
|
|
|
|
import ${basePackage}.frame.utils.AESUtil;
|
|
|
|
|
import ${basePackage}.frame.utils.LogUtil;
|
|
|
|
|
import ${basePackage}.frame.utils.MD5Util;
|
|
|
|
|
import ${basePackage}.frame.utils.MapperUtil;
|
|
|
|
|
import com.fasterxml.jackson.core.TreeNode;
|
|
|
|
|
import org.springframework.beans.BeansException;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
@ -15,13 +8,31 @@ import org.springframework.boot.web.servlet.error.ErrorController;
|
|
|
|
|
import org.springframework.http.MediaType;
|
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
|
import org.springframework.ui.Model;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
|
|
|
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
import org.springframework.web.servlet.DispatcherServlet;
|
|
|
|
|
import org.springframework.web.servlet.LocaleResolver;
|
|
|
|
|
import org.springframework.web.servlet.View;
|
|
|
|
|
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
|
|
|
|
import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;
|
|
|
|
|
import ${basePackage}.config.ActionConfig;
|
|
|
|
|
import ${basePackage}.frame.auth.LocalData;
|
|
|
|
|
import ${basePackage}.frame.base.BaseRequest;
|
|
|
|
|
import ${basePackage}.frame.base.BaseResponse;
|
|
|
|
|
import ${basePackage}.frame.base.ErrorType;
|
|
|
|
|
import ${basePackage}.frame.base.Screen;
|
|
|
|
|
import ${basePackage}.frame.base.Token;
|
|
|
|
|
import ${basePackage}.frame.utils.AESUtil;
|
|
|
|
|
import ${basePackage}.frame.utils.LogUtil;
|
|
|
|
|
import ${basePackage}.frame.utils.MD5Util;
|
|
|
|
|
import ${basePackage}.frame.utils.MapperUtil;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
@ -225,8 +236,8 @@ public class GlobalController implements ErrorController {
|
|
|
|
|
@PathVariable String module,
|
|
|
|
|
@PathVariable String target,
|
|
|
|
|
@PathVariable String method,
|
|
|
|
|
HttpServletRequest request,
|
|
|
|
|
HttpServletResponse response,
|
|
|
|
|
HttpServletRequest httpServletRequest,
|
|
|
|
|
HttpServletResponse httpServletResponse,
|
|
|
|
|
@RequestBody(required = false) String data,
|
|
|
|
|
@RequestParam(name = "file", required = false) MultipartFile file) {
|
|
|
|
|
try {
|
|
|
|
@ -256,9 +267,9 @@ public class GlobalController implements ErrorController {
|
|
|
|
|
for (int i = 0; i < parameters.length; i++) {
|
|
|
|
|
Parameter parameter = parameters[i];
|
|
|
|
|
if (parameter.getType() == HttpServletRequest.class) {
|
|
|
|
|
arg[i] = request;
|
|
|
|
|
arg[i] = httpServletRequest;
|
|
|
|
|
} else if (parameter.getType() == HttpServletResponse.class) {
|
|
|
|
|
arg[i] = response;
|
|
|
|
|
arg[i] = httpServletResponse;
|
|
|
|
|
} else if (parameter.getType() == TreeNode.class) {
|
|
|
|
|
arg[i] = MapperUtil.toTree(data);
|
|
|
|
|
} else if (parameter.getType() == String.class) {
|
|
|
|
@ -298,8 +309,10 @@ public class GlobalController implements ErrorController {
|
|
|
|
|
@RequestParam(required = false) String appKey,
|
|
|
|
|
@RequestParam(required = false) String sign,
|
|
|
|
|
@RequestParam(required = false) Long timestamp,
|
|
|
|
|
@RequestParam(required = false) Long token,
|
|
|
|
|
@RequestParam(required = false) String encryptData) {
|
|
|
|
|
@RequestParam(required = false) String token,
|
|
|
|
|
@RequestParam(required = false) String encryptData,
|
|
|
|
|
HttpServletRequest httpServletRequest,
|
|
|
|
|
HttpServletResponse httpServletResponse) {
|
|
|
|
|
BaseResponse response = new BaseResponse();
|
|
|
|
|
if (appKey == null) {
|
|
|
|
|
response.addError(ErrorType.BUSINESS_ERROR, "应用码参数[appKey]不存在!");
|
|
|
|
@ -336,13 +349,10 @@ public class GlobalController implements ErrorController {
|
|
|
|
|
return AESUtil.encrypt2Base64(MapperUtil.toJson(response).getBytes(), appSecret);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 权限验证 todo 模拟权限验证
|
|
|
|
|
{
|
|
|
|
|
Token tokenPO = new Token();
|
|
|
|
|
tokenPO.setId(token != null ? token : 0L);
|
|
|
|
|
tokenPO.setUserId(0L);
|
|
|
|
|
tokenPO.setUserName("admin");
|
|
|
|
|
LocalData.setToken(tokenPO);
|
|
|
|
|
// 权限验证
|
|
|
|
|
if (!LocalData.getToken().hasResource(httpServletRequest.getServletPath())) {
|
|
|
|
|
response.addError(ErrorType.BUSINESS_ERROR, "[" + httpServletRequest.getServletPath() + "]未授权的资源!");
|
|
|
|
|
return AESUtil.encrypt2Base64(MapperUtil.toJson(response).getBytes(), appSecret);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 开始处理业务
|
|
|
|
@ -369,7 +379,11 @@ public class GlobalController implements ErrorController {
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < parameters.length; i++) {
|
|
|
|
|
Parameter parameter = parameters[i];
|
|
|
|
|
if (BaseRequest.class.isAssignableFrom(parameter.getType())) {
|
|
|
|
|
if (parameter.getType() == HttpServletRequest.class) {
|
|
|
|
|
arg[i] = httpServletRequest;
|
|
|
|
|
} else if (parameter.getType() == HttpServletResponse.class) {
|
|
|
|
|
arg[i] = httpServletResponse;
|
|
|
|
|
} else if (BaseRequest.class.isAssignableFrom(parameter.getType())) {
|
|
|
|
|
arg[i] = MapperUtil.toJava(data, parameter.getType());
|
|
|
|
|
} else if (parameter.getType() == TreeNode.class) {
|
|
|
|
|
arg[i] = MapperUtil.toTree(data);
|
|
|
|
|