From 393ad3138ef534c4c95dd1554614f5998f4fa466 Mon Sep 17 00:00:00 2001
From: hello-hao <923453645@qq.com>
Date: Thu, 16 Mar 2023 17:38:01 +0800
Subject: [PATCH] =?UTF-8?q?update:=E8=B0=83=E6=95=B4=E4=BA=86=E7=99=BE?=
=?UTF-8?q?=E5=BA=A6=E9=89=B4=E5=88=AB=E6=8E=A5=E5=8F=A3=E5=8D=87=E7=BA=A7?=
=?UTF-8?q?=E4=BA=86=E4=BE=9D=E8=B5=96=EF=BC=8C=E6=96=B0=E5=A2=9E=E4=BA=86?=
=?UTF-8?q?key=E7=9A=84=E7=9B=B8=E5=85=B3=E5=AD=97=E6=AE=B5=E4=BF=A1?=
=?UTF-8?q?=E6=81=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 2 +-
.../java/cn/hellohao/TbedApplication.java | 25 +++++++++++--------
.../hellohao/controller/IndexController.java | 4 +--
.../hellohao/service/impl/ClientService.java | 5 ++--
.../hellohao/service/impl/UploadServicel.java | 11 +++++---
.../{SqlHelper.java => RunSqlScript.java} | 5 ----
src/main/resources/mapper/KeysMapper.xml | 6 +++--
7 files changed, 33 insertions(+), 25 deletions(-)
rename src/main/java/cn/hellohao/utils/{SqlHelper.java => RunSqlScript.java} (96%)
diff --git a/pom.xml b/pom.xml
index 12f535e..ad5d0f0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -134,7 +134,7 @@
com.baidu.aip
java-sdk
- 4.11.0
+ 4.16.14
net.coobird
diff --git a/src/main/java/cn/hellohao/TbedApplication.java b/src/main/java/cn/hellohao/TbedApplication.java
index 81f91dd..99f9108 100644
--- a/src/main/java/cn/hellohao/TbedApplication.java
+++ b/src/main/java/cn/hellohao/TbedApplication.java
@@ -41,17 +41,22 @@ public static void main(String[] args) {
@Bean
public static BeanFactoryPostProcessor dependsOnPostProcessor() {
return bf -> {
- // Let beans that need the database depend on the DatabaseStartupValidator
- // like the JPA EntityManagerFactory or Flyway
- String[] flyway = bf.getBeanNamesForType(FirstRun.class);
- Stream.of(flyway)
- .map(bf::getBeanDefinition)
- .forEach(it -> it.setDependsOn("databaseStartupValidator"));
+ try{
+ // Let beans that need the database depend on the DatabaseStartupValidator
+ // like the JPA EntityManagerFactory or Flyway
+ String[] flyway = bf.getBeanNamesForType(FirstRun.class);
+ Stream.of(flyway)
+ .map(bf::getBeanDefinition)
+ .forEach(it -> it.setDependsOn("databaseStartupValidator"));
+
+ String[] jpa = bf.getBeanNamesForType(KeysMapper.class);
+ Stream.of(jpa)
+ .map(bf::getBeanDefinition)
+ .forEach(it -> it.setDependsOn("databaseStartupValidator"));
+ }catch (Exception e){
+ System.out.println("错错错");
+ }
- String[] jpa = bf.getBeanNamesForType(KeysMapper.class);
- Stream.of(jpa)
- .map(bf::getBeanDefinition)
- .forEach(it -> it.setDependsOn("databaseStartupValidator"));
};
}
/**
diff --git a/src/main/java/cn/hellohao/controller/IndexController.java b/src/main/java/cn/hellohao/controller/IndexController.java
index 5d432a6..5a85bf0 100644
--- a/src/main/java/cn/hellohao/controller/IndexController.java
+++ b/src/main/java/cn/hellohao/controller/IndexController.java
@@ -43,9 +43,9 @@ public class IndexController {
@RequestMapping(value = "/")
public String Welcome(Model model, HttpServletRequest httpServletRequest) {
model.addAttribute("name", "服务端程序");
- model.addAttribute("version", "20230101");
+ model.addAttribute("version", "20230316");
model.addAttribute("ip", GetIPS.getIpAddr(httpServletRequest));
- model.addAttribute("links", "tbed.hellohao.cn");
+ model.addAttribute("links", "www.hellohao.cn");
return "welcome";
}
diff --git a/src/main/java/cn/hellohao/service/impl/ClientService.java b/src/main/java/cn/hellohao/service/impl/ClientService.java
index 8e7455f..537ea14 100644
--- a/src/main/java/cn/hellohao/service/impl/ClientService.java
+++ b/src/main/java/cn/hellohao/service/impl/ClientService.java
@@ -198,6 +198,7 @@ public class ClientService {
})
.start();
} else {
+ imgMapper.deleimgForImgUid(imgObj.getImguid());
msg.setCode("5001");
msg.setInfo("上传服务内部错误");
return msg;
@@ -292,8 +293,8 @@ public class ClientService {
imgreview.getSecretKey());
client.setConnectionTimeoutInMillis(5000);
client.setSocketTimeoutInMillis(30000);
- org.json.JSONObject res = client.antiPorn(images.getImgurl());
- res = client.imageCensorUserDefined(images.getImgurl(), EImgType.URL, null);
+// org.json.JSONObject res = client.antiPorn(images.getImgurl());
+ org.json.JSONObject res = client.imageCensorUserDefined(images.getImgurl(), EImgType.URL, null);
com.alibaba.fastjson.JSONArray jsonArray =
JSON.parseArray("[" + res.toString() + "]");
for (Object o : jsonArray) {
diff --git a/src/main/java/cn/hellohao/service/impl/UploadServicel.java b/src/main/java/cn/hellohao/service/impl/UploadServicel.java
index 519ca58..5005c1e 100644
--- a/src/main/java/cn/hellohao/service/impl/UploadServicel.java
+++ b/src/main/java/cn/hellohao/service/impl/UploadServicel.java
@@ -11,6 +11,8 @@ import com.baidu.aip.contentcensor.EImgType;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
@@ -28,6 +30,8 @@ import java.util.*;
*/
@Service
public class UploadServicel {
+
+ private static Logger logger = LoggerFactory.getLogger(UploadServicel.class);
@Autowired private UploadConfigMapper uploadConfigMapper;
@Autowired private KeysMapper keysMapper;
@Autowired private ImgMapper imgMapper;
@@ -200,6 +204,7 @@ public class UploadServicel {
})
.start();
} else {
+ imgMapper.deleimgForImgUid(imgObj.getImguid());
msg.setCode("5001");
msg.setInfo("上传服务内部错误");
return msg;
@@ -333,9 +338,9 @@ public class UploadServicel {
imgreview.getSecretKey());
client.setConnectionTimeoutInMillis(5000);
client.setSocketTimeoutInMillis(30000);
- org.json.JSONObject res = client.antiPorn(images.getImgurl());
- res = client.imageCensorUserDefined(images.getImgurl(), EImgType.URL, null);
- System.err.println("返回的鉴黄json:" + res.toString());
+// org.json.JSONObject res = client.antiPorn(images.getImgurl());
+ org.json.JSONObject res = client.imageCensorUserDefined(images.getImgurl(), EImgType.URL, null);
+ logger.info("百度图像审核返回的JSON:"+res.toString());
com.alibaba.fastjson.JSONArray jsonArray =
JSON.parseArray("[" + res.toString() + "]");
for (Object o : jsonArray) {
diff --git a/src/main/java/cn/hellohao/utils/SqlHelper.java b/src/main/java/cn/hellohao/utils/RunSqlScript.java
similarity index 96%
rename from src/main/java/cn/hellohao/utils/SqlHelper.java
rename to src/main/java/cn/hellohao/utils/RunSqlScript.java
index 1a7372c..a6f4927 100644
--- a/src/main/java/cn/hellohao/utils/SqlHelper.java
+++ b/src/main/java/cn/hellohao/utils/RunSqlScript.java
@@ -1,11 +1,6 @@
package cn.hellohao.utils;
-import org.apache.ibatis.io.Resources;
-import org.apache.ibatis.jdbc.ScriptRunner;
-
-import java.io.IOException;
import java.sql.*;
-import java.util.Properties;
final class RunSqlScript {
diff --git a/src/main/resources/mapper/KeysMapper.xml b/src/main/resources/mapper/KeysMapper.xml
index 003914e..0e3885b 100644
--- a/src/main/resources/mapper/KeysMapper.xml
+++ b/src/main/resources/mapper/KeysMapper.xml
@@ -27,7 +27,7 @@
WHEN storageType=5 THEN '本地'
WHEN storageType=6 THEN '腾讯云'
WHEN storageType=7 THEN 'FTP'
- WHEN storageType=8 THEN 'UFile'
+ WHEN storageType=8 THEN 'S3协议'
ELSE '未知' END AS storageName,
keyname
FROM `keys` GROUP BY storageType,id,storageName,keyname
@@ -49,7 +49,9 @@
Endpoint = #{Endpoint},
Bucketname = #{Bucketname},
RequestAddress = #{RequestAddress},
- keyname = #{keyname}
+ keyname = #{keyname},
+ Region = #{Region},
+ RootPath = #{RootPath}
WHERE
storageType = #{storageType}