From 05af9845eb9c10317710a33e94b691d3fb742604 Mon Sep 17 00:00:00 2001 From: TanYibin <5491541@qq.com> Date: Mon, 6 Mar 2023 13:44:23 +0800 Subject: [PATCH] 文件上传下载初版提交 --- .gitignore | 1 + huaheng-wms-core/src/main/java/org/jeecg/modules/system/controller/CommonController.java | 43 +++++++++++++++++++++++++------------------ huaheng-wms-core/src/main/java/org/jeecg/modules/wms/framework/aspectj/ApiLogAspect.java | 556 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- huaheng-wms-core/src/main/java/org/jeecg/modules/wms/framework/aspectj/ApiLoggerAspect.java | 556 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ huaheng-wms-core/src/main/java/org/jeecg/utils/OkHttpUtils.java | 20 ++++++++++---------- huaheng-wms-core/src/main/resources/application-dev.yml | 14 ++++++++------ huaheng-wms-core/src/main/resources/application-prod.yml | 14 ++++++++------ huaheng-wms-core/src/main/resources/application-test.yml | 14 ++++++++------ 8 files changed, 616 insertions(+), 602 deletions(-) delete mode 100644 huaheng-wms-core/src/main/java/org/jeecg/modules/wms/framework/aspectj/ApiLogAspect.java create mode 100644 huaheng-wms-core/src/main/java/org/jeecg/modules/wms/framework/aspectj/ApiLoggerAspect.java diff --git a/.gitignore b/.gitignore index 6ffa8b7..c7411b5 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ **/target **/logs **/static/** +**/upFiles/** ## front **/*.lock diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/system/controller/CommonController.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/system/controller/CommonController.java index 092338c..52b1c6b 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/system/controller/CommonController.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/system/controller/CommonController.java @@ -2,6 +2,8 @@ package org.jeecg.modules.system.controller; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; + +import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.jeecg.common.api.vo.Result; import org.jeecg.common.constant.CommonConstant; @@ -11,6 +13,7 @@ import org.jeecg.common.util.CommonUtils; import org.jeecg.common.util.RestUtil; import org.jeecg.common.util.TokenUtils; import org.jeecg.common.util.oConvertUtils; +import org.jeecg.modules.wms.framework.aspectj.lang.annotation.ApiLogger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpHeaders; @@ -53,6 +56,12 @@ public class CommonController { */ @Value(value = "${jeecg.uploadType}") private String uploadType; + + /** + * 允许上传的文件类型 + */ + @Value(value = "${jeecg.uploadFileType}") + private String uploadFileType; /** * @Author 政辉 @@ -70,29 +79,34 @@ public class CommonController { * @return */ @PostMapping(value = "/upload") + @ApiLogger(apiName = "文件上传", from = "WMS") public Result<?> upload(HttpServletRequest request, HttpServletResponse response) { Result<?> result = new Result<>(); String savePath = ""; String bizPath = request.getParameter("biz"); - // LOWCOD-2580 sys/common/upload接口存在任意文件上传漏洞 if (oConvertUtils.isNotEmpty(bizPath) && (bizPath.contains("../") || bizPath.contains("..\\"))) { - throw new JeecgBootException("上传目录bizPath,格式非法!"); + throw new JeecgBootException("上传路径格式非法!"); } - MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest)request; MultipartFile file = multipartRequest.getFile("file");// 获取上传文件对象 + if (file == null) { + throw new JeecgBootException("未找到上传文件!"); + } if (oConvertUtils.isEmpty(bizPath)) { if (CommonConstant.UPLOAD_TYPE_OSS.equals(uploadType)) { - // 未指定目录,则用阿里云默认目录 upload - bizPath = "upload"; - // result.setMessage("使用阿里云文件上传时,必须添加目录!"); - // result.setSuccess(false); - // return result; + result.setMessage("使用阿里云文件上传时,必须添加目录!"); + result.setSuccess(false); + return result; } else { bizPath = ""; } } + String orgName = file.getOriginalFilename();// 获取文件名 + String suffix = orgName.substring(orgName.lastIndexOf(".") + 1); // 文件后缀 + if (orgName.equals(suffix) || !uploadFileType.contains(suffix)) { + throw new JeecgBootException("上传文件类型非法!"); + } if (CommonConstant.UPLOAD_TYPE_LOCAL.equals(uploadType)) { // update-begin-author:lvdandan date:20200928 for:修改JEditor编辑器本地上传 savePath = this.uploadLocal(file, bizPath); @@ -130,24 +144,17 @@ public class CommonController { * @param bizPath 自定义路径 * @return */ - private String uploadLocal(MultipartFile mf, String bizPath) { + private String uploadLocal(MultipartFile multipartFile, String bizPath) { try { String ctxPath = uploadpath; - String fileName = null; File file = new File(ctxPath + File.separator + bizPath + File.separator); if (!file.exists()) { file.mkdirs();// 创建文件根目录 } - String orgName = mf.getOriginalFilename();// 获取文件名 - orgName = CommonUtils.getFileName(orgName); - if (orgName.indexOf(".") != -1) { - fileName = orgName.substring(0, orgName.lastIndexOf(".")) + "_" + System.currentTimeMillis() + orgName.substring(orgName.lastIndexOf(".")); - } else { - fileName = orgName + "_" + System.currentTimeMillis(); - } + String fileName = CommonUtils.getFileName(multipartFile.getOriginalFilename()); String savePath = file.getPath() + File.separator + fileName; File savefile = new File(savePath); - FileCopyUtils.copy(mf.getBytes(), savefile); + FileCopyUtils.copy(multipartFile.getBytes(), savefile); String dbpath = null; if (oConvertUtils.isNotEmpty(bizPath)) { dbpath = bizPath + File.separator + fileName; diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/framework/aspectj/ApiLogAspect.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/framework/aspectj/ApiLogAspect.java deleted file mode 100644 index eb87a41..0000000 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/framework/aspectj/ApiLogAspect.java +++ /dev/null @@ -1,556 +0,0 @@ -package org.jeecg.modules.wms.framework.aspectj; - -import java.net.InetAddress; -import java.net.URL; -import java.net.UnknownHostException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Set; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.commons.lang.exception.ExceptionUtils; -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Pointcut; -import org.aspectj.lang.reflect.MethodSignature; -import org.jeecg.JeecgSystemApplication; -import org.jeecg.common.api.vo.Result; -import org.jeecg.modules.wms.config.address.entity.Address; -import org.jeecg.modules.wms.config.address.service.IAddressService; -import org.jeecg.modules.wms.framework.aspectj.lang.annotation.ApiLogger; -import org.jeecg.modules.wms.monitor.apiLog.entity.ApiLog; -import org.jeecg.modules.wms.monitor.apiLog.service.IApiLogService; -import org.jeecg.utils.HuahengJwtUtil; -import org.jeecg.utils.ServletUtils; -import org.jeecg.utils.SpringUtils; -import org.jeecg.utils.StringUtils; -import org.jeecg.utils.constant.QuantityConstant; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.scheduling.annotation.Async; -import org.springframework.scheduling.annotation.EnableAsync; -import org.springframework.stereotype.Component; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; - -import okhttp3.Request; -import okhttp3.Response; - -/** - * API调用日志记录处理 - * @author huaheng - */ -@Aspect -@Component -@EnableAsync -public class ApiLogAspect { - private static final Logger log = LoggerFactory.getLogger(ApiLogAspect.class); - - private static IApiLogService apiLogService; - - private static IAddressService addressService; - - @Autowired - public void setApiLogService(IApiLogService apiLogService) { - ApiLogAspect.apiLogService = apiLogService; - } - - @Autowired - public void setAddressService(IAddressService addressService) { - ApiLogAspect.addressService = addressService; - } - - // 配置织入点 - @Pointcut("@annotation(org.jeecg.modules.wms.framework.aspectj.lang.annotation.ApiLogger)") - public void logPointCut() {} - - @Around("logPointCut() && @annotation(apiLogger)") - public Object around(ProceedingJoinPoint point, ApiLogger apiLogger) throws Throwable { - return aroundXXX2Wms(point, apiLogger); - } - - /** 记录第三方系统调用WMS接口的日志 **/ - private Object aroundXXX2Wms(ProceedingJoinPoint point, ApiLogger apiLogger) { - Object ret = null; - ApiLog apiLog = initApiLog(apiLogger, point); - try { - ret = point.proceed(); - } catch (Throwable e) { - setApiLogThrowable(apiLog, e); - ret = Result.error(e.getMessage()); - return ret; - } finally { - if (ret != null) { - finishApiLog(apiLog, ret); - } - } - return ret; - } - -// /** 记录WMS调用第三方接口的日志 **/ -// private Object aroundWms2XXX(ProceedingJoinPoint point, ApiLogger apiLogger) { -// Object ret = null; -// ApiLog log = new ApiLog(); -// -// HttpURLConnection connection = null; -// String body = null; -// -// try { -// connection = (HttpURLConnection)point.getArgs()[0]; -// body = (String)point.getArgs()[1]; -// initApiLog(connection, body); -// ret = point.proceed(); -// } catch (Throwable e) { -// setApiLogThrowable(log, e); -// ret = Result.error(e.getMessage()); -// } finally { -// if (ret != null) { -// finishApiLog(log, connection, ret.toString()); -// } -// } -// return ret; -// } - -// /** -// * 记录响应头信息,保存日志到数据库 -// */ -// public static void finishApiLog(ApiLog log, HttpURLConnection connection, String body) { -// try { -// log.setResponseBody(body); -// log.setResponseTime(new Date()); -// Long duration = log.getResponseTime().getTime() - log.getRequestTime().getTime(); -// log.setDuration(duration.intValue()); -// log.setHttpCode(connection.getResponseCode()); -// -// // 响应头 -// Set<String> keyset = connection.getHeaderFields().keySet(); -// ArrayList<String> headerList = new ArrayList<>(); -// Iterator<String> it = keyset.iterator(); -// while (it.hasNext()) { -// String name = it.next(); -// String header = connection.getHeaderField(name); -// if (name == null || "".equals(name)) { -// // 第一行没有name -// // HTTP/1.1 200 OK -// headerList.add(header); -// } else { -// headerList.add(name + ": " + header); -// } -// } -// log.setResponseHeader(org.apache.commons.lang3.StringUtils.join(headerList, "\n")); -// Result json = JSON.parseObject(body, Result.class); -// log.setRetCode(json.getCode()); -// } catch (Exception e) { -// e.printStackTrace(); -// } finally { -// SpringUtils.getBean(ApiLogAspect.class).saveApiLog(log); -// } -// } - -// /** -// * 根据url,从address表中判断调用的去向 -// */ -// public static void parseUrl(ApiLog log, URL url, String warehouseCode) { -// try { -// String[] spList = url.toString().split("/"); -// String apiName = spList[spList.length - 1]; -// String ip = JeecgSystemApplication.getLocalHostExactAddress().getHostAddress(); -// Address address = addressService.getAddressByUrl(url.toString(), warehouseCode); -// log.setApiName(apiName); -// log.setRequestFrom("WMS"); -// log.setIp(ip); -// log.setResponseBy(address.getParam().toUpperCase()); -// } catch (Exception e) { -// e.printStackTrace(); -// } -// } - -// /** -// * 记录WMS调用第三方系统接口的请求信息 -// * 在HttpUtils.body POST方法中直接调用本类static方法 -// **/ -// public static ApiLog initApiLog(String Method, String urlStr, String body, HttpHeaders headers, String warehouseCode) { -// ApiLog log = new ApiLog(); -// try { -// URL url = new URL(urlStr); -// log.setApiMethod(Method); -// log.setUrl(urlStr); -// log.setRequestTime(new Date()); -// parseUrl(log, url, warehouseCode); -// -// // 请求头 -// Set<String> keySet = headers.keySet(); -// ArrayList<String> headerList = new ArrayList<>(); -// Iterator<String> it = keySet.iterator(); -// while (it.hasNext()) { -// String name = it.next(); -// String header = String.valueOf(headers.getContentType()); -// headerList.add(name + ": " + header); -// } -// -// log.setRequestHeader(org.apache.commons.lang3.StringUtils.join(headerList, "\n")); -// log.setRequestBody(body); -// } catch (Exception e) { -// e.printStackTrace(); -// } -// -// return log; -// } - -// /** -// * 记录WMS调用第三方系统接口的请求信息 -// * 在HttpUtils.body POST方法中直接调用本类static方法 -// **/ -// public static ApiLog initApiLog(HttpURLConnection connection, String body) { -// ApiLog log = new ApiLog(); -// try { -// log.setApiMethod(connection.getRequestMethod()); -// log.setUrl(connection.getURL().toString()); -// log.setRequestTime(new Date()); -// parseUrl(log, connection.getURL()); -// -// // 请求头 -// Set<String> keySet = connection.getRequestProperties().keySet(); -// ArrayList<String> headerList = new ArrayList<>(); -// Iterator<String> it = keySet.iterator(); -// while (it.hasNext()) { -// String name = it.next(); -// String header = connection.getRequestProperty(name); -// headerList.add(name + ":" + header); -// } -// -// log.setRequestHeader(org.apache.commons.lang3.StringUtils.join(headerList, "\n")); -// log.setRequestBody(body); -// } catch (Exception e) { -// e.printStackTrace(); -// } -// -// return log; -// } - - /** - * 记录WMS调用第三方系统接口的请求信息 - * 在OKHttpUtils.bodypost方法中直接调用本类static方法 - * @param apiLog - **/ - public static void initApiLog(ApiLog apiLog, Request request, String body) { - try { - apiLog.setApiMethod(request.method()); - apiLog.setUrl(request.url().toString()); - apiLog.setRequestTime(new Date()); - parseUrl(apiLog, request.url().url()); - apiLog.setRequestHeader(request.headers().toString()); - apiLog.setRequestBody(body); - } catch (Exception e) { - e.printStackTrace(); - } - } - - /** 记录响应头信息 **/ - public static void finishApiLog(ApiLog log, Response response, String responseBody) { - try { - log.setResponseTime(new Date()); - Long duration = log.getResponseTime().getTime() - log.getRequestTime().getTime(); - log.setDuration(duration.intValue()); - if (response == null) { - return; - } - log.setHttpCode(response.code()); - log.setResponseHeader(response.headers().toString()); - log.setResponseBody(responseBody); - Result result = null; - try { - result = JSON.parseObject(responseBody, Result.class); - } catch (Exception ex) { - responseBody = JSON.parse(responseBody).toString(); - result = JSON.parseObject(responseBody, Result.class); - } - log.setRetCode(result.getCode()); - } catch (Exception e) { - e.printStackTrace(); - } finally { - try { - if (StringUtils.isNotEmpty(log.getResponseBody()) && log.getResponseBody().length() > 2001) { - log.setResponseBody(log.getResponseBody().substring(0, 2000) + "...\n"); - } - } catch (Exception e) { - e.printStackTrace(); - } - SpringUtils.getBean(ApiLogAspect.class).saveApiLog(log); - } - } - - /** 根据url,从address表中判断调用的去向 **/ - public static void parseUrl(ApiLog apiLog, URL url) { - try { - String[] spList = url.toString().split("/"); - String apiName = spList[spList.length - 1]; - String ip = JeecgSystemApplication.getLocalHostExactAddress().getHostAddress(); - apiLog.setApiName(apiName); - apiLog.setRequestFrom(HuahengJwtUtil.HUAHENG_SYSTEM_ID); - apiLog.setIp(ip); -// Address address = addressService.getAddressByUrl(url.toString(), QuantityConstant.DEFAULT_WAREHOUSE); -// apiLog.setResponseBy(address.getParam().toUpperCase()); - } catch (Exception e) { - e.printStackTrace(); - } - } - -// /** -// * 记录响应头信息 -// **/ -// public static void finishApiLog(ApiLog log, HttpHeaders headers, String body) { -// try { -// log.setResponseBody(body); -// log.setResponseTime(new Date()); -// Long duration = log.getResponseTime().getTime() - log.getRequestTime().getTime(); -// log.setDuration(duration.intValue()); -// log.setHttpCode(200); -// -// // 响应头 -// Set<String> keyset = headers.keySet(); -// ArrayList<String> headerList = new ArrayList<>(); -// Iterator<String> it = keyset.iterator(); -// while (it.hasNext()) { -// String name = it.next(); -// String header = String.valueOf(headers.getContentType()); -// if (name == null || "".equals(name)) -// // 第一行没有name -// // HTTP/1.1 200 OK -// headerList.add(header); -// else -// headerList.add(name + ": " + header); -// } -// log.setResponseHeader(org.apache.commons.lang3.StringUtils.join(headerList, "\n")); -// Result json = JSON.parseObject(body, Result.class); -// log.setRetCode(json.getCode()); -// } catch (Exception e) { -// e.printStackTrace(); -// } finally { -// SpringUtils.getBean(ApiLogAspect.class).saveApiLog(log); -// } -// } - - private ApiLog initApiLog(ApiLogger apiLogger, ProceedingJoinPoint point) { - ApiLog log = new ApiLog(); - try { - log.setRequestTime(new Date()); - log.setRequestFrom(apiLogger.from()); - log.setResponseBy(apiLogger.to()); - log.setApiName(apiLogger.apiName()); - - HttpServletRequest request = ServletUtils.getRequest(); - String qryStr = request.getQueryString(); - String url = request.getRequestURL().toString(); - if (StringUtils.isNotEmpty(qryStr)) { - url = url + "?" + qryStr; - } - log.setUrl(url); - log.setApiMethod(request.getMethod()); - log.setIp(this.getIpAddr(request)); - - rebuildRequestHeader(log); - rebuildRequestBody(log, request); - - // 如果reqeust中取不到post参数,就从接口方法参数中取json对象 - if (StringUtils.isEmpty(log.getRequestBody())) { - rebuildRequestBody(log, point); - } - - } catch (Exception e) { - e.printStackTrace(); - } - - return log; - } - - private void finishApiLog(ApiLog log, Object ret) { - try { - rebuildResponseHeader(log); - rebuildResponseBody(log, ret); - - log.setResponseTime(new Date()); - Long duration = log.getResponseTime().getTime() - log.getRequestTime().getTime(); - log.setDuration(duration.intValue()); - - HttpServletResponse resp = ServletUtils.getResponse(); - log.setHttpCode(resp.getStatus()); - - if (ret instanceof Result) { - int retCode = ((Result)ret).getCode(); - log.setRetCode(retCode); - } - } catch (Exception e) { - e.printStackTrace(); - } finally { - saveApiLog(log); - } - } - - public static void setApiLogException(ApiLog log, Exception e) { - try { - String exception = ExceptionUtils.getFullStackTrace(e); - String shortExpInfo = e.getMessage() + "\n" + org.apache.commons.lang3.StringUtils.left(exception, 2000) + "..."; - log.setException(shortExpInfo); - } catch (Exception ex) { - ex.printStackTrace(); - } - } - - public static void setApiLogThrowable(ApiLog log, Throwable e) { - try { - String exception = ExceptionUtils.getFullStackTrace(e); - String shortExpInfo = e.getMessage() + "\n" + org.apache.commons.lang3.StringUtils.left(exception, 2000) + "..."; - log.setException(shortExpInfo); - } catch (Exception ex) { - ex.printStackTrace(); - } - } - - private void rebuildRequestHeader(ApiLog log) { - try { - HttpServletRequest req = ServletUtils.getRequest(); - Enumeration names = req.getHeaderNames(); - ArrayList<String> headerList = new ArrayList<>(); - while (names.hasMoreElements()) { - String name = (String)names.nextElement(); - String header = req.getHeader(name); - headerList.add(name + ":" + header); - } - String headers = org.apache.commons.lang3.StringUtils.join(headerList, "\n"); - log.setRequestHeader(headers); - } catch (Exception e) { - e.printStackTrace(); - } - } - - /** 先从post参数中构造request body */ - private void rebuildRequestBody(ApiLog log, HttpServletRequest request) { - try { - Set<String> keySet = request.getParameterMap().keySet(); - Iterator<String> it = keySet.iterator(); - StringBuffer sbf = new StringBuffer(); - while (it.hasNext()) { - String key = it.next(); - String value = request.getParameter(key); - sbf.append(key).append("=").append(value); - if (it.hasNext()) { - sbf.append("&"); - } - } - log.setRequestBody(sbf.toString()); - } catch (Exception e) { - e.printStackTrace(); - } - } - - /** - * 根据接口中的参数构造request body - */ - private void rebuildRequestBody(ApiLog log, ProceedingJoinPoint point) { - try { - if (point.getArgs().length == 1) { - log.setRequestBody(JSONObject.toJSONString(point.getArgs()[0])); - return; - } - - MethodSignature m = (MethodSignature)point.getSignature(); - HashMap<String, Object> map = new HashMap<>(); - Object[] args = point.getArgs(); - for (int i = 0; i < m.getParameterNames().length; i++) { - String name = m.getParameterNames()[i]; -// Class type = m.getParameterTypes()[i]; - if (args[i] instanceof HttpServletRequest) { - continue; - } else { - map.put(name, args[i]); - } - } - - if (!map.isEmpty()) { - if (map.keySet().size() == 1) { - log.setRequestBody(JSONObject.toJSONString(map.values().iterator().next())); - } else { - log.setRequestBody(JSONObject.toJSONString(map)); - } - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - private void rebuildResponseHeader(ApiLog log) { - try { - HttpServletResponse resp = ServletUtils.getResponse(); - Collection names = resp.getHeaderNames(); - ArrayList<String> headerList = new ArrayList<>(); - Iterator<String> it = names.iterator(); - while (it.hasNext()) { - String name = it.next(); - String header = resp.getHeader(name); - headerList.add(name + ": " + header); - } - String headers = org.apache.commons.lang3.StringUtils.join(headerList, "\n"); - log.setResponseHeader(headers); - } catch (Exception e) { - e.printStackTrace(); - } - } - - private void rebuildResponseBody(ApiLog log, Object ret) { - try { - log.setResponseBody(JSONObject.toJSON(ret).toString()); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Async - public void saveApiLog(ApiLog log) { - try { - apiLogService.saveOrUpdate(log); - } catch (Exception e) { - e.printStackTrace(); - } - } - - public String getIpAddr(HttpServletRequest request) { - String ipAddress = request.getHeader("x-forwarded-for"); - if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) { - ipAddress = request.getHeader("Proxy-Client-IP"); - } - if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) { - ipAddress = request.getHeader("WL-Proxy-Client-IP"); - } - if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) { - ipAddress = request.getRemoteAddr(); - if (ipAddress.equals("127.0.0.1") || ipAddress.equals("0:0:0:0:0:0:0:1")) { - // 根据网卡取本机配置的IP - InetAddress inet = null; - try { - inet = InetAddress.getLocalHost(); - } catch (UnknownHostException e) { - e.printStackTrace(); - } - ipAddress = inet.getHostAddress(); - } - } - // 对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割 - // "***.***.***.***".length() = 15 - if (ipAddress != null && ipAddress.length() > 15) { - if (ipAddress.indexOf(",") > 0) { - ipAddress = ipAddress.substring(0, ipAddress.indexOf(",")); - } - } - return ipAddress; - } -} diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/framework/aspectj/ApiLoggerAspect.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/framework/aspectj/ApiLoggerAspect.java new file mode 100644 index 0000000..6f0f486 --- /dev/null +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/framework/aspectj/ApiLoggerAspect.java @@ -0,0 +1,556 @@ +package org.jeecg.modules.wms.framework.aspectj; + +import java.net.InetAddress; +import java.net.URL; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Set; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.lang.exception.ExceptionUtils; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.aspectj.lang.reflect.MethodSignature; +import org.jeecg.JeecgSystemApplication; +import org.jeecg.common.api.vo.Result; +import org.jeecg.modules.wms.config.address.entity.Address; +import org.jeecg.modules.wms.config.address.service.IAddressService; +import org.jeecg.modules.wms.framework.aspectj.lang.annotation.ApiLogger; +import org.jeecg.modules.wms.monitor.apiLog.entity.ApiLog; +import org.jeecg.modules.wms.monitor.apiLog.service.IApiLogService; +import org.jeecg.utils.HuahengJwtUtil; +import org.jeecg.utils.ServletUtils; +import org.jeecg.utils.SpringUtils; +import org.jeecg.utils.StringUtils; +import org.jeecg.utils.constant.QuantityConstant; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Async; +import org.springframework.scheduling.annotation.EnableAsync; +import org.springframework.stereotype.Component; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; + +import okhttp3.Request; +import okhttp3.Response; + +/** + * API调用日志记录处理 + * @author huaheng + */ +@Aspect +@Component +@EnableAsync +public class ApiLoggerAspect { + private static final Logger log = LoggerFactory.getLogger(ApiLoggerAspect.class); + + private static IApiLogService apiLogService; + + private static IAddressService addressService; + + @Autowired + public void setApiLogService(IApiLogService apiLogService) { + ApiLoggerAspect.apiLogService = apiLogService; + } + + @Autowired + public void setAddressService(IAddressService addressService) { + ApiLoggerAspect.addressService = addressService; + } + + // 配置织入点 + @Pointcut("@annotation(org.jeecg.modules.wms.framework.aspectj.lang.annotation.ApiLogger)") + public void logPointCut() {} + + @Around("logPointCut() && @annotation(apiLogger)") + public Object around(ProceedingJoinPoint point, ApiLogger apiLogger) throws Throwable { + return aroundXXX2Wms(point, apiLogger); + } + + /** 记录第三方系统调用WMS接口的日志 **/ + private Object aroundXXX2Wms(ProceedingJoinPoint point, ApiLogger apiLogger) { + Object ret = null; + ApiLog apiLog = initApiLog(apiLogger, point); + try { + ret = point.proceed(); + } catch (Throwable e) { + setApiLogThrowable(apiLog, e); + ret = Result.error(e.getMessage()); + return ret; + } finally { + if (ret != null) { + finishApiLog(apiLog, ret); + } + } + return ret; + } + +// /** 记录WMS调用第三方接口的日志 **/ +// private Object aroundWms2XXX(ProceedingJoinPoint point, ApiLogger apiLogger) { +// Object ret = null; +// ApiLog log = new ApiLog(); +// +// HttpURLConnection connection = null; +// String body = null; +// +// try { +// connection = (HttpURLConnection)point.getArgs()[0]; +// body = (String)point.getArgs()[1]; +// initApiLog(connection, body); +// ret = point.proceed(); +// } catch (Throwable e) { +// setApiLogThrowable(log, e); +// ret = Result.error(e.getMessage()); +// } finally { +// if (ret != null) { +// finishApiLog(log, connection, ret.toString()); +// } +// } +// return ret; +// } + +// /** +// * 记录响应头信息,保存日志到数据库 +// */ +// public static void finishApiLog(ApiLog log, HttpURLConnection connection, String body) { +// try { +// log.setResponseBody(body); +// log.setResponseTime(new Date()); +// Long duration = log.getResponseTime().getTime() - log.getRequestTime().getTime(); +// log.setDuration(duration.intValue()); +// log.setHttpCode(connection.getResponseCode()); +// +// // 响应头 +// Set<String> keyset = connection.getHeaderFields().keySet(); +// ArrayList<String> headerList = new ArrayList<>(); +// Iterator<String> it = keyset.iterator(); +// while (it.hasNext()) { +// String name = it.next(); +// String header = connection.getHeaderField(name); +// if (name == null || "".equals(name)) { +// // 第一行没有name +// // HTTP/1.1 200 OK +// headerList.add(header); +// } else { +// headerList.add(name + ": " + header); +// } +// } +// log.setResponseHeader(org.apache.commons.lang3.StringUtils.join(headerList, "\n")); +// Result json = JSON.parseObject(body, Result.class); +// log.setRetCode(json.getCode()); +// } catch (Exception e) { +// e.printStackTrace(); +// } finally { +// SpringUtils.getBean(ApiLogAspect.class).saveApiLog(log); +// } +// } + +// /** +// * 根据url,从address表中判断调用的去向 +// */ +// public static void parseUrl(ApiLog log, URL url, String warehouseCode) { +// try { +// String[] spList = url.toString().split("/"); +// String apiName = spList[spList.length - 1]; +// String ip = JeecgSystemApplication.getLocalHostExactAddress().getHostAddress(); +// Address address = addressService.getAddressByUrl(url.toString(), warehouseCode); +// log.setApiName(apiName); +// log.setRequestFrom("WMS"); +// log.setIp(ip); +// log.setResponseBy(address.getParam().toUpperCase()); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } + +// /** +// * 记录WMS调用第三方系统接口的请求信息 +// * 在HttpUtils.body POST方法中直接调用本类static方法 +// **/ +// public static ApiLog initApiLog(String Method, String urlStr, String body, HttpHeaders headers, String warehouseCode) { +// ApiLog log = new ApiLog(); +// try { +// URL url = new URL(urlStr); +// log.setApiMethod(Method); +// log.setUrl(urlStr); +// log.setRequestTime(new Date()); +// parseUrl(log, url, warehouseCode); +// +// // 请求头 +// Set<String> keySet = headers.keySet(); +// ArrayList<String> headerList = new ArrayList<>(); +// Iterator<String> it = keySet.iterator(); +// while (it.hasNext()) { +// String name = it.next(); +// String header = String.valueOf(headers.getContentType()); +// headerList.add(name + ": " + header); +// } +// +// log.setRequestHeader(org.apache.commons.lang3.StringUtils.join(headerList, "\n")); +// log.setRequestBody(body); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// +// return log; +// } + +// /** +// * 记录WMS调用第三方系统接口的请求信息 +// * 在HttpUtils.body POST方法中直接调用本类static方法 +// **/ +// public static ApiLog initApiLog(HttpURLConnection connection, String body) { +// ApiLog log = new ApiLog(); +// try { +// log.setApiMethod(connection.getRequestMethod()); +// log.setUrl(connection.getURL().toString()); +// log.setRequestTime(new Date()); +// parseUrl(log, connection.getURL()); +// +// // 请求头 +// Set<String> keySet = connection.getRequestProperties().keySet(); +// ArrayList<String> headerList = new ArrayList<>(); +// Iterator<String> it = keySet.iterator(); +// while (it.hasNext()) { +// String name = it.next(); +// String header = connection.getRequestProperty(name); +// headerList.add(name + ":" + header); +// } +// +// log.setRequestHeader(org.apache.commons.lang3.StringUtils.join(headerList, "\n")); +// log.setRequestBody(body); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// +// return log; +// } + + /** + * 记录WMS调用第三方系统接口的请求信息 + * 在OKHttpUtils.bodypost方法中直接调用本类static方法 + * @param apiLog + **/ + public static void initApiLog(ApiLog apiLog, Request request, String body) { + try { + apiLog.setApiMethod(request.method()); + apiLog.setUrl(request.url().toString()); + apiLog.setRequestTime(new Date()); + parseUrl(apiLog, request.url().url()); + apiLog.setRequestHeader(request.headers().toString()); + apiLog.setRequestBody(body); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** 记录响应头信息 **/ + public static void finishApiLog(ApiLog log, Response response, String responseBody) { + try { + log.setResponseTime(new Date()); + Long duration = log.getResponseTime().getTime() - log.getRequestTime().getTime(); + log.setDuration(duration.intValue()); + if (response == null) { + return; + } + log.setHttpCode(response.code()); + log.setResponseHeader(response.headers().toString()); + log.setResponseBody(responseBody); + Result result = null; + try { + result = JSON.parseObject(responseBody, Result.class); + } catch (Exception ex) { + responseBody = JSON.parse(responseBody).toString(); + result = JSON.parseObject(responseBody, Result.class); + } + log.setRetCode(result.getCode()); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + if (StringUtils.isNotEmpty(log.getResponseBody()) && log.getResponseBody().length() > 2001) { + log.setResponseBody(log.getResponseBody().substring(0, 2000) + "...\n"); + } + } catch (Exception e) { + e.printStackTrace(); + } + SpringUtils.getBean(ApiLoggerAspect.class).saveApiLog(log); + } + } + + /** 根据url,从address表中判断调用的去向 **/ + public static void parseUrl(ApiLog apiLog, URL url) { + try { + String[] spList = url.toString().split("/"); + String apiName = spList[spList.length - 1]; + String ip = JeecgSystemApplication.getLocalHostExactAddress().getHostAddress(); + apiLog.setApiName(apiName); + apiLog.setRequestFrom(HuahengJwtUtil.HUAHENG_SYSTEM_ID); + apiLog.setIp(ip); +// Address address = addressService.getAddressByUrl(url.toString(), QuantityConstant.DEFAULT_WAREHOUSE); +// apiLog.setResponseBy(address.getParam().toUpperCase()); + } catch (Exception e) { + e.printStackTrace(); + } + } + +// /** +// * 记录响应头信息 +// **/ +// public static void finishApiLog(ApiLog log, HttpHeaders headers, String body) { +// try { +// log.setResponseBody(body); +// log.setResponseTime(new Date()); +// Long duration = log.getResponseTime().getTime() - log.getRequestTime().getTime(); +// log.setDuration(duration.intValue()); +// log.setHttpCode(200); +// +// // 响应头 +// Set<String> keyset = headers.keySet(); +// ArrayList<String> headerList = new ArrayList<>(); +// Iterator<String> it = keyset.iterator(); +// while (it.hasNext()) { +// String name = it.next(); +// String header = String.valueOf(headers.getContentType()); +// if (name == null || "".equals(name)) +// // 第一行没有name +// // HTTP/1.1 200 OK +// headerList.add(header); +// else +// headerList.add(name + ": " + header); +// } +// log.setResponseHeader(org.apache.commons.lang3.StringUtils.join(headerList, "\n")); +// Result json = JSON.parseObject(body, Result.class); +// log.setRetCode(json.getCode()); +// } catch (Exception e) { +// e.printStackTrace(); +// } finally { +// SpringUtils.getBean(ApiLogAspect.class).saveApiLog(log); +// } +// } + + private ApiLog initApiLog(ApiLogger apiLogger, ProceedingJoinPoint point) { + ApiLog log = new ApiLog(); + try { + log.setRequestTime(new Date()); + log.setRequestFrom(apiLogger.from()); + log.setResponseBy(apiLogger.to()); + log.setApiName(apiLogger.apiName()); + + HttpServletRequest request = ServletUtils.getRequest(); + String qryStr = request.getQueryString(); + String url = request.getRequestURL().toString(); + if (StringUtils.isNotEmpty(qryStr)) { + url = url + "?" + qryStr; + } + log.setUrl(url); + log.setApiMethod(request.getMethod()); + log.setIp(this.getIpAddr(request)); + + rebuildRequestHeader(log); + rebuildRequestBody(log, request); + + // 如果reqeust中取不到post参数,就从接口方法参数中取json对象 + if (StringUtils.isEmpty(log.getRequestBody())) { + rebuildRequestBody(log, point); + } + + } catch (Exception e) { + e.printStackTrace(); + } + + return log; + } + + private void finishApiLog(ApiLog log, Object ret) { + try { + rebuildResponseHeader(log); + rebuildResponseBody(log, ret); + + log.setResponseTime(new Date()); + Long duration = log.getResponseTime().getTime() - log.getRequestTime().getTime(); + log.setDuration(duration.intValue()); + + HttpServletResponse resp = ServletUtils.getResponse(); + log.setHttpCode(resp.getStatus()); + + if (ret instanceof Result) { + int retCode = ((Result)ret).getCode(); + log.setRetCode(retCode); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + saveApiLog(log); + } + } + + public static void setApiLogException(ApiLog log, Exception e) { + try { + String exception = ExceptionUtils.getFullStackTrace(e); + String shortExpInfo = e.getMessage() + "\n" + org.apache.commons.lang3.StringUtils.left(exception, 2000) + "..."; + log.setException(shortExpInfo); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + public static void setApiLogThrowable(ApiLog log, Throwable e) { + try { + String exception = ExceptionUtils.getFullStackTrace(e); + String shortExpInfo = e.getMessage() + "\n" + org.apache.commons.lang3.StringUtils.left(exception, 2000) + "..."; + log.setException(shortExpInfo); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + private void rebuildRequestHeader(ApiLog log) { + try { + HttpServletRequest req = ServletUtils.getRequest(); + Enumeration names = req.getHeaderNames(); + ArrayList<String> headerList = new ArrayList<>(); + while (names.hasMoreElements()) { + String name = (String)names.nextElement(); + String header = req.getHeader(name); + headerList.add(name + ":" + header); + } + String headers = org.apache.commons.lang3.StringUtils.join(headerList, "\n"); + log.setRequestHeader(headers); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** 先从post参数中构造request body */ + private void rebuildRequestBody(ApiLog log, HttpServletRequest request) { + try { + Set<String> keySet = request.getParameterMap().keySet(); + Iterator<String> it = keySet.iterator(); + StringBuffer sbf = new StringBuffer(); + while (it.hasNext()) { + String key = it.next(); + String value = request.getParameter(key); + sbf.append(key).append("=").append(value); + if (it.hasNext()) { + sbf.append("&"); + } + } + log.setRequestBody(sbf.toString()); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * 根据接口中的参数构造request body + */ + private void rebuildRequestBody(ApiLog log, ProceedingJoinPoint point) { + try { + if (point.getArgs().length == 1) { + log.setRequestBody(JSONObject.toJSONString(point.getArgs()[0])); + return; + } + + MethodSignature m = (MethodSignature)point.getSignature(); + HashMap<String, Object> map = new HashMap<>(); + Object[] args = point.getArgs(); + for (int i = 0; i < m.getParameterNames().length; i++) { + String name = m.getParameterNames()[i]; +// Class type = m.getParameterTypes()[i]; + if (args[i] instanceof HttpServletRequest) { + continue; + } else { + map.put(name, args[i]); + } + } + + if (!map.isEmpty()) { + if (map.keySet().size() == 1) { + log.setRequestBody(JSONObject.toJSONString(map.values().iterator().next())); + } else { + log.setRequestBody(JSONObject.toJSONString(map)); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + private void rebuildResponseHeader(ApiLog log) { + try { + HttpServletResponse resp = ServletUtils.getResponse(); + Collection<String> names = resp.getHeaderNames(); + ArrayList<String> headerList = new ArrayList<>(); + Iterator<String> it = names.iterator(); + while (it.hasNext()) { + String name = it.next(); + String header = resp.getHeader(name); + headerList.add(name + ": " + header); + } + String headers = org.apache.commons.lang3.StringUtils.join(headerList, "\n"); + log.setResponseHeader(headers); + } catch (Exception e) { + e.printStackTrace(); + } + } + + private void rebuildResponseBody(ApiLog log, Object ret) { + try { + log.setResponseBody(JSONObject.toJSON(ret).toString()); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Async + public void saveApiLog(ApiLog log) { + try { + apiLogService.saveOrUpdate(log); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public String getIpAddr(HttpServletRequest request) { + String ipAddress = request.getHeader("x-forwarded-for"); + if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) { + ipAddress = request.getHeader("Proxy-Client-IP"); + } + if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) { + ipAddress = request.getHeader("WL-Proxy-Client-IP"); + } + if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) { + ipAddress = request.getRemoteAddr(); + if (ipAddress.equals("127.0.0.1") || ipAddress.equals("0:0:0:0:0:0:0:1")) { + // 根据网卡取本机配置的IP + InetAddress inet = null; + try { + inet = InetAddress.getLocalHost(); + } catch (UnknownHostException e) { + e.printStackTrace(); + } + ipAddress = inet.getHostAddress(); + } + } + // 对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割 + // "***.***.***.***".length() = 15 + if (ipAddress != null && ipAddress.length() > 15) { + if (ipAddress.indexOf(",") > 0) { + ipAddress = ipAddress.substring(0, ipAddress.indexOf(",")); + } + } + return ipAddress; + } +} diff --git a/huaheng-wms-core/src/main/java/org/jeecg/utils/OkHttpUtils.java b/huaheng-wms-core/src/main/java/org/jeecg/utils/OkHttpUtils.java index 1879e25..82a1ad1 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/utils/OkHttpUtils.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/utils/OkHttpUtils.java @@ -10,7 +10,7 @@ import antlr.StringUtils; import cn.hutool.core.util.StrUtil; import net.bytebuddy.asm.Advice.This; import okhttp3.*; -import org.jeecg.modules.wms.framework.aspectj.ApiLogAspect; +import org.jeecg.modules.wms.framework.aspectj.ApiLoggerAspect; import org.jeecg.modules.wms.monitor.apiLog.entity.ApiLog; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -104,16 +104,16 @@ public class OkHttpUtils { Response response = null; String result = null; try { - ApiLogAspect.initApiLog(apiLog, request, param); + ApiLoggerAspect.initApiLog(apiLog, request, param); response = HTTP_CLIENT.newCall(request).execute(); result = response.body().string(); } catch (Exception e) { String errorString = StrUtil.format("执行GET请求异常,url:{},header:{},param:{},errorMessage:{}", url, JSON.toJSONString(headers), param, e.getMessage()); - ApiLogAspect.setApiLogException(apiLog, e); + ApiLoggerAspect.setApiLogException(apiLog, e); throw new RuntimeException(errorString, e); } finally { - ApiLogAspect.finishApiLog(apiLog, response, result); + ApiLoggerAspect.finishApiLog(apiLog, response, result); } if (response.isSuccessful() && Objects.nonNull(response.body())) {// 调用成功 log.info("执行GET请求成功,url:{},header:{},param:{},result:{}", url, JSON.toJSONString(headers), param, result); @@ -154,16 +154,16 @@ public class OkHttpUtils { Response response = null; String result = null; try { - ApiLogAspect.initApiLog(apiLog, request, param); + ApiLoggerAspect.initApiLog(apiLog, request, param); response = HTTP_CLIENT.newCall(request).execute(); result = response.body().string(); } catch (Exception e) { String errorString = StrUtil.format("执行POST请求异常,url:{},header:{},param:{},errorMessage:{}", url, JSON.toJSONString(headers), param, e.getMessage()); - ApiLogAspect.setApiLogException(apiLog, e); + ApiLoggerAspect.setApiLogException(apiLog, e); throw new RuntimeException(errorString, e); } finally { - ApiLogAspect.finishApiLog(apiLog, response, result); + ApiLoggerAspect.finishApiLog(apiLog, response, result); } if (response.isSuccessful() && Objects.nonNull(response.body())) {// 调用成功 log.info("执行POST请求成功,url:{},header:{},param:{},result:{}", url, JSON.toJSONString(headers), param, result); @@ -196,15 +196,15 @@ public class OkHttpUtils { Response response = null; String result = null; try { - ApiLogAspect.initApiLog(apiLog, request, jsonString); + ApiLoggerAspect.initApiLog(apiLog, request, jsonString); response = HTTP_CLIENT.newCall(request).execute(); result = response.body().string(); } catch (Exception e) { String errorString = StrUtil.format("执行POST请求异常,url:{},header:{},param:{},errorMessage:{}", url, JSON.toJSONString(headers), jsonString, e.getMessage()); - ApiLogAspect.setApiLogException(apiLog, e); + ApiLoggerAspect.setApiLogException(apiLog, e); throw new RuntimeException(errorString); } finally { - ApiLogAspect.finishApiLog(apiLog, response, result); + ApiLoggerAspect.finishApiLog(apiLog, response, result); } if (response.isSuccessful() && Objects.nonNull(response.body())) {// 调用成功 log.info("执行POST请求成功,url:{},header:{},param:{},result:{}", url, JSON.toJSONString(headers), jsonString, result); diff --git a/huaheng-wms-core/src/main/resources/application-dev.yml b/huaheng-wms-core/src/main/resources/application-dev.yml index 908b2b9..7c5bc27 100644 --- a/huaheng-wms-core/src/main/resources/application-dev.yml +++ b/huaheng-wms-core/src/main/resources/application-dev.yml @@ -22,8 +22,8 @@ management: spring: servlet: multipart: - max-file-size: 10MB - max-request-size: 10MB + max-file-size: 100MB + max-request-size: 100MB mail: host: smtp.163.com username: jeecgos@163.com @@ -189,14 +189,16 @@ jeecg: # 签名密钥串(前后端要一致,正式发布请自行修改) signatureSecret: dd05f1c54d63749eda95f9fa6d49v442a # 本地:local\Minio:minio\阿里云:alioss - uploadType: minio + uploadType: local + # 允许上传的文件类型,使用,分割 + uploadFileType: sh path: #文件上传根目录 设置 - upload: /opt/upFiles + upload: ./upFiles #webapp文件路径 - webapp: /opt/webapp + webapp: ./webapp shiro: - excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/category/**,/visual/**,/map/**,/jmreport/bigscreen2/**,/sys/getWarehouseByUserCode,/test/test**,/api/**,/sys/cas/client/validateLogin + excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/category/**,/visual/**,/map/**,/jmreport/bigscreen2/**,/sys/getWarehouseByUserCode,/test/test**,/api/**,/sys/cas/client/validateLogin,/sys/common/static/** #阿里云oss存储和大鱼短信秘钥配置 oss: accessKey: ?? diff --git a/huaheng-wms-core/src/main/resources/application-prod.yml b/huaheng-wms-core/src/main/resources/application-prod.yml index a3311ff..e4ce823 100644 --- a/huaheng-wms-core/src/main/resources/application-prod.yml +++ b/huaheng-wms-core/src/main/resources/application-prod.yml @@ -22,8 +22,8 @@ management: spring: servlet: multipart: - max-file-size: 10MB - max-request-size: 10MB + max-file-size: 100MB + max-request-size: 100MB mail: host: smtp.163.com username: jeecgos@163.com @@ -187,14 +187,16 @@ jeecg: # 签名密钥串(前后端要一致,正式发布请自行修改) signatureSecret: dd05f1c54d63749eda95f9fa6d49v442a # 本地:local\Minio:minio\阿里云:alioss - uploadType: alioss + uploadType: local + # 允许上传的文件类型,使用,分割 + uploadFileType: sh path: #文件上传根目录 设置 - upload: /opt/jeecg-boot/upload + upload: ./upload #webapp文件路径 - webapp: /opt/jeecg-boot/webapp + webapp: ./webapp shiro: - excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/category/**,/visual/**,/map/**,/jmreport/bigscreen2/**,/sys/getWarehouseByUserCode,/test/test**,/api/**,/sys/cas/client/validateLogin + excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/category/**,/visual/**,/map/**,/jmreport/bigscreen2/**,/sys/getWarehouseByUserCode,/test/test**,/api/**,/sys/cas/client/validateLogin,/sys/common/static/** #阿里云oss存储和大鱼短信秘钥配置 oss: accessKey: ?? diff --git a/huaheng-wms-core/src/main/resources/application-test.yml b/huaheng-wms-core/src/main/resources/application-test.yml index d29e03c..c1bc4fc 100644 --- a/huaheng-wms-core/src/main/resources/application-test.yml +++ b/huaheng-wms-core/src/main/resources/application-test.yml @@ -22,8 +22,8 @@ management: spring: servlet: multipart: - max-file-size: 10MB - max-request-size: 10MB + max-file-size: 100MB + max-request-size: 100MB mail: host: smtp.163.com username: jeecgos@163.com @@ -189,14 +189,16 @@ jeecg: # 签名密钥串(前后端要一致,正式发布请自行修改) signatureSecret: dd05f1c54d63749eda95f9fa6d49v442a # 本地:local\Minio:minio\阿里云:alioss - uploadType: minio + uploadType: local + # 允许上传的文件类型,使用,分割 + uploadFileType: sh path: #文件上传根目录 设置 - upload: /opt/upFiles + upload: ./upFiles #webapp文件路径 - webapp: /opt/webapp + webapp: ./webapp shiro: - excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/category/**,/visual/**,/map/**,/jmreport/bigscreen2/**,/sys/getWarehouseByUserCode,/api/**,/sys/cas/client/validateLogin + excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/category/**,/visual/**,/map/**,/jmreport/bigscreen2/**,/sys/getWarehouseByUserCode,/api/**,/sys/cas/client/validateLogin,/sys/common/static/** #阿里云oss存储和大鱼短信秘钥配置 oss: accessKey: ?? -- libgit2 0.22.2