From 59bc47c6cce33fe083ccd43fde87cc1d6e4edabe Mon Sep 17 00:00:00 2001 From: "1378012178@qq.com" <1378012178@qq.com> Date: Tue, 15 Apr 2025 09:45:47 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81121=EF=BC=88=E6=96=B0uat=EF=BC=89?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E9=85=8D=E7=BD=AE=202=E3=80=81=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E6=96=87=E4=BB=B6=E6=97=B6=E5=A4=B4=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0content-length?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/controller/CommonController.java | 18 ++++++++----- .../src/main/resources/application-uat.yml | 26 ++++++++++++------- .../src/main/resources/bootstrap.yml | 16 ++++++++++++ pom.xml | 21 +++++++++++---- 4 files changed, 59 insertions(+), 22 deletions(-) create mode 100644 nursing-unit-system/nu-system-start/src/main/resources/bootstrap.yml diff --git a/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/controller/CommonController.java b/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/controller/CommonController.java index c4abb88..239c605 100644 --- a/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/controller/CommonController.java +++ b/nursing-unit-system/nu-system-biz/src/main/java/org/jeecg/modules/system/controller/CommonController.java @@ -210,14 +210,14 @@ public class CommonController { public void view(HttpServletRequest request, HttpServletResponse response) { // ISO-8859-1 ==> UTF-8 进行编码转换 String imgPath = extractPathFromPattern(request); - if(oConvertUtils.isEmpty(imgPath) || CommonConstant.STRING_NULL.equals(imgPath)){ + if (oConvertUtils.isEmpty(imgPath) || CommonConstant.STRING_NULL.equals(imgPath)) { return; } // 其余处理略 InputStream inputStream = null; OutputStream outputStream = null; try { - imgPath = imgPath.replace("..", "").replace("../",""); + imgPath = imgPath.replace("..", "").replace("../", ""); if (imgPath.endsWith(SymbolConstant.COMMA)) { imgPath = imgPath.substring(0, imgPath.length() - 1); } @@ -227,15 +227,20 @@ public class CommonController { String filePath = uploadpath + File.separator + imgPath; File file = new File(filePath); - if(!file.exists()){ + if (!file.exists()) { response.setStatus(404); - log.error("文件["+imgPath+"]不存在.."); + log.error("文件[" + imgPath + "]不存在.."); return; - //throw new RuntimeException(); } + + // 获取文件大小并设置Content-Length + long fileLength = file.length(); + response.setHeader("Content-Length", String.valueOf(fileLength)); + // 设置强制下载不打开 response.setContentType("application/force-download"); - response.addHeader("Content-Disposition", "attachment;fileName=" + new String(file.getName().getBytes("UTF-8"),"iso-8859-1")); + response.addHeader("Content-Disposition", "attachment;fileName=" + new String(file.getName().getBytes("UTF-8"), "iso-8859-1")); + inputStream = new BufferedInputStream(new FileInputStream(filePath)); outputStream = response.getOutputStream(); byte[] buf = new byte[1024]; @@ -264,7 +269,6 @@ public class CommonController { } } } - } // /** diff --git a/nursing-unit-system/nu-system-start/src/main/resources/application-uat.yml b/nursing-unit-system/nu-system-start/src/main/resources/application-uat.yml index f72255a..5f595b5 100644 --- a/nursing-unit-system/nu-system-start/src/main/resources/application-uat.yml +++ b/nursing-unit-system/nu-system-start/src/main/resources/application-uat.yml @@ -1,5 +1,5 @@ server: - port: 8080 + port: 8082 tomcat: max-swallow-size: -1 error: @@ -7,7 +7,7 @@ server: include-stacktrace: ALWAYS include-message: ALWAYS servlet: - context-path: /nursing-unit + context-path: /nursing-unit-nacos compression: enabled: true min-response-size: 1024 @@ -20,6 +20,12 @@ management: include: metrics,jeecghttptrace spring: + application: + name: nursing-unit-nacos + cloud: + nacos: + discovery: + service-name: nursing-unit-nacos # flyway配置 flyway: # 是否启用flyway @@ -163,10 +169,10 @@ spring: slow-sql-millis: 5000 datasource: master: - url: jdbc:mysql://localhost:40521/nursing_unit?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai + url: jdbc:mysql://mysql8-prod:3306/nursing_unit?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai # url: jdbc:mysql://localhost:3306/nursing_unit_001?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai - username: root - password: BLXC@123. + username: fw8864sshdang + password: uGDBkM25I6nZCNM2 driver-class-name: com.mysql.cj.jdbc.Driver # 多数据源配置 #multi-datasource1: @@ -176,10 +182,10 @@ spring: #driver-class-name: com.mysql.cj.jdbc.Driver #redis 配置 redis: - database: 0 - host: 127.0.0.1 + database: 1 + host: redis port: 6379 - password: + password: uUgrUus4JAYuwxzo #mybatis plus 设置 mybatis-plus: mapper-locations: classpath*:org/jeecg/**/xml/*Mapper.xml,classpath*:com/nu/**/xml/*Mapper.xml @@ -225,9 +231,9 @@ jeecg: app: http://localhost:8051 path: #文件上传根目录 设置 - upload: /opt/upFiles + upload: /opt/nu/upFiles #webapp文件路径 - webapp: /opt/webapp + webapp: /opt/nu/webapp shiro: excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/bigscreen/category/**,/bigscreen/visual/**,/bigscreen/map/**,/jmreport/bigscreen2/** #阿里云oss存储和大鱼短信秘钥配置 diff --git a/nursing-unit-system/nu-system-start/src/main/resources/bootstrap.yml b/nursing-unit-system/nu-system-start/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..a868296 --- /dev/null +++ b/nursing-unit-system/nu-system-start/src/main/resources/bootstrap.yml @@ -0,0 +1,16 @@ +spring: + cloud: + nacos: + discovery: + server-addr: ${config.server-addr} + namespace: ${config.namespace} + group: ${config.group} + username: ${config.username} + password: ${config.password} + config: + server-addr: ${config.server-addr} + namespace: ${config.namespace} + group: ${config.group} + file-extension: yaml + username: ${config.username} + password: ${config.password} diff --git a/pom.xml b/pom.xml index 86a79bf..8840e97 100644 --- a/pom.xml +++ b/pom.xml @@ -150,6 +150,17 @@ commonmark ${commonmark.version} + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + @@ -465,7 +476,7 @@ dev - true + false @@ -517,21 +528,21 @@ uat - false + true uat - jeecg-boot-nacos:8848 + 121.36.88.64 DEFAULT_GROUP - + fw8864nasadn - + JINisgIngV82G2