update:调整数据类型,删除逻辑

feat:sout在log文件中显示
This commit is contained in:
hello-hao
2023-03-17 17:41:10 +08:00
parent 393ad3138e
commit 8ebdbf6cee
18 changed files with 326 additions and 211 deletions
@@ -0,0 +1,44 @@
package cn.hellohao.config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import javax.annotation.PostConstruct;
import java.io.PrintStream;
import java.util.function.Consumer;
@Configuration
public class LogSystemProxy {
private final static Logger log = LoggerFactory.getLogger("proxy.system.log");
@PostConstruct
public void initProxy(){
log.debug("LogSystemProxy init .....");
System.setOut(getLoggerProxy(StdType.OUT));
System.setErr(getLoggerProxy(StdType.ERR));
}
private enum StdType{
OUT(System.out, log::info),
ERR(System.err, log::error),
;
PrintStream stream;
Consumer<String> consumer;
StdType(PrintStream stream,Consumer<String> consumer){
this.stream = stream;
this.consumer = consumer;
}
}
private PrintStream getLoggerProxy(StdType stdType){
return new PrintStream(stdType.stream){
@Override
public void print(String s) {
stdType.stream.print(s);
stdType.consumer.accept(s);
}
};
}
}
@@ -0,0 +1,52 @@
package cn.hellohao.config;
import lombok.Data;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.ThreadPoolExecutor;
//线程池
@Configuration
@EnableAsync
public class PoolConfig {
ThreadPoolProperties properties = new ThreadPoolProperties();
@Bean(name = "taskExecutor")
public ThreadPoolTaskExecutor taskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(properties.getCorePoolSize());
executor.setMaxPoolSize(properties.getMaxPoolSize());
executor.setQueueCapacity(properties.getQueueCapacity());
executor.setThreadNamePrefix(properties.getThreadNamePrefix());
executor.setKeepAliveSeconds(properties.getKeepAliveTime());
executor.setWaitForTasksToCompleteOnShutdown(properties.isWaitForTasksToCompleteOnShutdown());
executor.setAwaitTerminationSeconds(properties.getAwaitTerminationSeconds());
// 设置任务拒绝策略
/**
* 4种
* ThreadPoolExecutor类有几个内部实现类来处理这类情况:
- AbortPolicy 丢弃任务,抛RejectedExecutionException
- CallerRunsPolicy 由该线程调用线程运行。直接调用Runnable的run方法运行。
- DiscardPolicy 抛弃策略,直接丢弃这个新提交的任务
- DiscardOldestPolicy 抛弃旧任务策略,从队列中踢出最先进入队列(最后一个执行)的任务
* 实现RejectedExecutionHandler接口,可自定义处理器
*/
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
return executor;
}
@Data
class ThreadPoolProperties {
private int corePoolSize = 5;
private int maxPoolSize = 50;
private int keepAliveTime = 15;
private int queueCapacity = 6;
private String threadNamePrefix = "Tbed-Thread";
private boolean allowCoreThreadTimeout = false;
private boolean waitForTasksToCompleteOnShutdown = false;
private int awaitTerminationSeconds;
}
}
@@ -472,9 +472,9 @@ public class AdminController {
msg.setInfo("为获取到图像信息");
return msg;
}
List<Integer> imgIds = new ArrayList<Integer>();
List<Long> imgIds = new ArrayList<Long>();
for (int i = 0; i < split.length; i++) {
Integer imgid = Integer.valueOf(split[i]);
Long imgid = Long.valueOf(split[i]);
Images image = imgService.selectByPrimaryKey(imgid);
if (!subject.hasRole("admin")) {
if (!image.getUserid().equals(user.getId())) {
@@ -486,7 +486,7 @@ public class AdminController {
if (imgIds.size() == 0) {
msg.setCode("110404");
} else {
deleimages.dele(uuid, imgIds.stream().toArray(Integer[]::new));
deleimages.dele(uuid, imgIds.stream().toArray(Long[]::new));
msg.setCode("200");
}
return msg;
@@ -42,10 +42,10 @@ public class IndexController {
@RequestMapping(value = "/")
public String Welcome(Model model, HttpServletRequest httpServletRequest) {
model.addAttribute("name", "服务端程序");
model.addAttribute("version", "20230316");
model.addAttribute("name", "服务端程序(开源版)");
model.addAttribute("version", "20230318");
model.addAttribute("ip", GetIPS.getIpAddr(httpServletRequest));
model.addAttribute("links", "www.hellohao.cn");
model.addAttribute("links", "https://github.com/Hello-hao/tbed");
return "welcome";
}
+5 -6
View File
@@ -1,12 +1,11 @@
package cn.hellohao.dao;
import java.util.List;
import cn.hellohao.pojo.Images;
import cn.hellohao.pojo.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import cn.hellohao.pojo.Images;
import java.util.List;
@Mapper
public interface ImgMapper {
@@ -17,18 +16,18 @@ public interface ImgMapper {
Integer countimg(@Param("userid") Integer userid);
Integer deleimg(@Param("id") Integer id);
Integer deleimg(@Param("id") Long id);
Integer deleimgForImgUid(@Param("imguid") String imguid);
Images selectByPrimaryKey(@Param("id") Integer id);
Images selectByPrimaryKey(@Param("id") Long id);
Integer counts(@Param("userid") Integer userid);
Integer setImg(Images images);
Integer deleimgname(@Param("imgname") String imgname);
Integer deleall(@Param("id") Integer id);
Integer deleall(@Param("id") Long id);
List<Images> gettimeimg(@Param("time") String time);
+4 -4
View File
@@ -4,7 +4,7 @@ public class Images {
// 默认的时间字符串格式
//id, imgname, imgurl, userid
private Integer id;
private Long id;
private String imgname;
private String imgurl;
private Integer userid;
@@ -52,7 +52,7 @@ public class Images {
this.imguid = imguid;
}
public Images(Integer id, String imgname, String imgurl, Integer userid, String sizes, String abnormal, Integer source,
public Images(Long id, String imgname, String imgurl, Integer userid, String sizes, String abnormal, Integer source,
Integer imgtype, String updatetime, String username, Integer storageType, String starttime, String stoptime,
String explains, String md5key, String notes, String useridlist, String imguid, String albumtitle,
String password, Integer selecttype,Long countNum,Integer monthNum,String yyyy,
@@ -93,11 +93,11 @@ public class Images {
}
public Integer getId() {
public Long getId() {
return id;
}
public void setId(Integer id) {
public void setId(Long id) {
this.id = id;
}
@@ -1,27 +1,25 @@
package cn.hellohao.service;
import java.util.List;
import cn.hellohao.pojo.User;
import org.apache.ibatis.annotations.Param;
import cn.hellohao.pojo.Images;
import cn.hellohao.pojo.User;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public interface ImgService {
List<Images> selectimg(Images images);
Integer insertImgData(Images images);
Integer deleimg(Integer id);
Integer deleimg(Long id);
Integer deleimgForImgUid(String imguid);
Integer countimg(Integer userid);
Images selectByPrimaryKey(Integer id);
Images selectByPrimaryKey(Long id);
Integer counts(Integer userid);
@@ -29,7 +27,7 @@ public interface ImgService {
Integer deleimgname(String imgname);
Integer deleall(Integer id);
Integer deleall(Long id);
List<Images> gettimeimg(String time);
@@ -3,12 +3,8 @@ package cn.hellohao.service.impl;
import cn.hellohao.dao.*;
import cn.hellohao.pojo.*;
import cn.hellohao.service.ImgTempService;
import cn.hellohao.service.SysConfigService;
import cn.hellohao.utils.*;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baidu.aip.contentcensor.AipContentCensor;
import com.baidu.aip.contentcensor.EImgType;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -28,7 +24,6 @@ import java.util.*;
@Service
public class ClientService {
@Autowired private SysConfigService sysConfigService;
@Autowired private UserMapper userMapper;
@Autowired private KeysMapper keysMapper;
@Autowired private UploadConfigMapper uploadConfigMapper;
@@ -36,6 +31,7 @@ public class ClientService {
@Autowired private ImgreviewMapper imgreviewMapper;
@Autowired private ImgTempService imgTempService;
@Autowired private GetSource getSource;
@Autowired private ImgViolationJudgeServiceImpl imgViolationJudgeService;
public Msg uploadImg(
HttpServletRequest request, MultipartFile multipartFile, String email, String pass,Integer setday) {
@@ -164,16 +160,6 @@ public class ClientService {
List<Images> images = imgMapper.selectImgUrlByMD5(md5key);
if (images.size() > 0) {
jsonObject.put("url", images.get(0).getImgurl());
// Keys imgFromKey = keysService.selectKeys(images.get(0).getSource());
// if (imgFromKey.getStorageType().equals(5)) {
// jsonObject.put(
// "url",
// imgFromKey.getRequestAddress()
// + "/ota/"
// + images.get(0).getImgname());
// } else {
// jsonObject.put("url", images.get(0).getImgurl());
// }
jsonObject.put("name", file.getName());
jsonObject.put("size", images.get(0).getSizes());
msg.setData(jsonObject);
@@ -192,11 +178,7 @@ public class ClientService {
jsonObject.put("url", imgObj.getImgurl());
jsonObject.put("name", imgObj.getImgname());
jsonObject.put("size", imgObj.getSizes());
new Thread(
() -> {
LegalImageCheck(imgObj);
})
.start();
imgViolationJudgeService.LegalImageCheck(imgObj,key);
} else {
imgMapper.deleimgForImgUid(imgObj.getImguid());
msg.setCode("5001");
@@ -266,67 +248,4 @@ public class ClientService {
return msg;
}
// 图片鉴黄
private synchronized void LegalImageCheck(Images images) {
Imgreview imgreview = null;
try {
imgreview = imgreviewMapper.selectByusing(1);
} catch (Exception e) {
Print.warning("获取鉴别程序的时候发生错误");
e.printStackTrace();
}
if(imgreview==null){
System.out.println("没有找到可用的图像鉴别进程");
}else{
LegalImageCheckForBaiDu(imgreview, images);
}
}
private void LegalImageCheckForBaiDu(Imgreview imgreview, Images images) {
if (imgreview.getUsing() == 1) {
try {
AipContentCensor client =
new AipContentCensor(
imgreview.getAppId(),
imgreview.getApiKey(),
imgreview.getSecretKey());
client.setConnectionTimeoutInMillis(5000);
client.setSocketTimeoutInMillis(30000);
// 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) {
JSONObject jsonObject = (JSONObject) o;
com.alibaba.fastjson.JSONArray data = jsonObject.getJSONArray("data");
Integer conclusionType = jsonObject.getInteger("conclusionType");
if (conclusionType != null) {
if (conclusionType == 2) {
for (Object datum : data) {
JSONObject imgdata = (JSONObject) datum;
if (imgdata.getInteger("type") == 1) {
Images img = new Images();
img.setImgname(images.getImgname());
img.setViolation("1[1]");
imgMapper.setImg(img);
Imgreview imgv = new Imgreview();
imgv.setId(1);
Integer count = imgreview.getCount();
System.out.println("违法图片总数:" + count);
imgv.setCount(count + 1);
imgreviewMapper.updateByPrimaryKeySelective(imgv);
System.err.println("存在非法图片,进行处理操作");
}
}
}
}
}
} catch (Exception e) {
System.out.println("图像鉴黄线程执行过程中出现异常");
e.printStackTrace();
}
}
}
}
@@ -26,7 +26,7 @@ public class ImgServiceImpl implements ImgService {
}
@Override
public Integer deleimg(Integer id) {
public Integer deleimg(Long id) {
// TODO Auto-generated method stub
return imgMapper.deleimg(id);
}
@@ -36,7 +36,7 @@ public class ImgServiceImpl implements ImgService {
return imgMapper.deleimgForImgUid(imguid);
}
public Images selectByPrimaryKey(Integer id) {
public Images selectByPrimaryKey(Long id) {
return imgMapper.selectByPrimaryKey(id);
}
@@ -63,7 +63,7 @@ public class ImgServiceImpl implements ImgService {
}
@Override
public Integer deleall(Integer id) {
public Integer deleall(Long id) {
return imgMapper.deleall(id);
}
@@ -0,0 +1,116 @@
package cn.hellohao.service.impl;
import cn.hellohao.dao.ImgMapper;
import cn.hellohao.dao.ImgreviewMapper;
import cn.hellohao.pojo.Images;
import cn.hellohao.pojo.Imgreview;
import cn.hellohao.pojo.Keys;
import cn.hellohao.pojo.Msg;
import cn.hellohao.utils.FirstRun;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baidu.aip.contentcensor.AipContentCensor;
import com.baidu.aip.contentcensor.EImgType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class ImgViolationJudgeServiceImpl {
private static Logger logger = LoggerFactory.getLogger(FirstRun.class);
@Autowired
ImgreviewServiceImpl imgreviewService;
@Autowired ImgMapper imgMapper;
@Autowired deleImages deleimages;
@Autowired private ImgreviewMapper imgreviewMapper;
//synchronized
@Async("taskExecutor")
public void LegalImageCheck(Images images, Keys keys) {
Imgreview imgreview = null;
try {
imgreview = imgreviewService.selectByusing(1);
} catch (Exception e) {
logger.error("获取鉴别程序的时候发生错误");
e.printStackTrace();
}
// 判断哪个鉴别平台
if (null != imgreview) {
LegalImageCheckForBaiDu(imgreview, images, keys);
}
}
private void LegalImageCheckForBaiDu(Imgreview imgreview, Images images, Keys keys) {
// Imgreview imgreview = imgreviewService.selectByPrimaryKey(1);
if (imgreview.getUsing() == 1) {
logger.info("非法图像鉴别进程启动-BaiDu");
try {
AipContentCensor client =
new AipContentCensor(
imgreview.getAppId(),
imgreview.getApiKey(),
imgreview.getSecretKey());
client.setConnectionTimeoutInMillis(5000);
client.setSocketTimeoutInMillis(30000);
// 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) {
JSONObject jsonObject =
(JSONObject) o;
com.alibaba.fastjson.JSONArray data = jsonObject.getJSONArray("data");
Integer conclusionType = jsonObject.getInteger("conclusionType");
if (conclusionType != null) {
if (conclusionType == 2) {
// 1:合规,2:不合规,3:疑似,4:审核失败
for (Object datum : data) {
JSONObject imgdata =
(JSONObject) datum;
if (imgdata.getInteger("type") == 1) {
logger.info("存在非法图片,进行处理操作");
// type参数
// 0:百度官方违禁图库、1:色情识别、2:暴恐识别、3:恶心图识别、4:广告检测、5:政治敏感识别、6:图像质量检测、7:用户图像黑名单、8:用户图像白名单、10:用户头像审核、11:百度官方违禁词库、12:图文审核、13:自定义文本黑名单、14:自定义文本白名单、15:EasyDL自定义模型、16:敏感旗帜标志识别、21:不良场景识别、24:直播场景审核
// 存在非法图片,进行处理操作
Images img = new Images();
img.setImgname(images.getImgname());
img.setViolation("1[1]"); // 数字是鉴别平台的主键ID,括号是非法的类型,参考上面的注释
imgMapper.setImg(img);
// 计入总数
Imgreview imgv = new Imgreview();
imgv.setId(1);
Integer count = imgreview.getCount();
imgv.setCount(count + 1);
imgreviewMapper.updateByPrimaryKeySelective(imgv);
Images imgObj =
imgMapper.selectImgUrlByImgUID(images.getImguid());
Msg dele = deleimages.dele2(Long.toString(imgObj.getId()));
List<Long> ids = (List<Long>) dele.getData();
if (!ids.contains(imgObj.getId())) {
logger.error("检测到违规图像,但是数据库删除失败");
}
}
}
}
}
}
} catch (Exception e) {
logger.error("图像鉴黄线程执行过程中出现异常");
e.printStackTrace();
}
}
}
}
@@ -4,6 +4,8 @@ import cn.hellohao.auth.filter.SubjectFilter;
import cn.hellohao.dao.KeysMapper;
import cn.hellohao.pojo.Keys;
import cn.hellohao.utils.Print;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
@@ -23,6 +25,7 @@ import java.util.List;
@Order(2)
public class InitializationStorage implements CommandLineRunner {
private static Logger logger = LoggerFactory.getLogger(InitializationStorage.class);
@Value("${CROS_ALLOWED_ORIGINS}")
private String allowedOrigins;
@@ -4,10 +4,7 @@ import cn.hellohao.dao.*;
import cn.hellohao.pojo.*;
import cn.hellohao.service.ImgTempService;
import cn.hellohao.utils.*;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baidu.aip.contentcensor.AipContentCensor;
import com.baidu.aip.contentcensor.EImgType;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
@@ -36,9 +33,10 @@ public class UploadServicel {
@Autowired private KeysMapper keysMapper;
@Autowired private ImgMapper imgMapper;
@Autowired private UserMapper userMapper;
@Autowired private ImgreviewMapper imgreviewMapper;
@Autowired private ImgTempService imgTempService;
@Autowired private GetSource getSource;
@Autowired deleImages deleimages;
@Autowired ImgViolationJudgeServiceImpl imgViolationJudgeService;
public Msg uploadForLoc(
HttpServletRequest request,
@@ -198,11 +196,12 @@ public class UploadServicel {
jsonObject.put("url", imgObj.getImgurl());
jsonObject.put("name", imgObj.getImgname());
jsonObject.put("imguid", imgObj.getImguid());
new Thread(
() -> {
LegalImageCheck(imgObj);
})
.start();
imgViolationJudgeService.LegalImageCheck(imgObj,key);
// new Thread(
// () -> {
// LegalImageCheck(imgObj);
// })
// .start();
} else {
imgMapper.deleimgForImgUid(imgObj.getImguid());
msg.setCode("5001");
@@ -313,70 +312,6 @@ public class UploadServicel {
return msg;
}
private synchronized void LegalImageCheck(Images images) {
System.out.println("非法图像鉴别进程启动");
Imgreview imgreview = null;
try {
imgreview = imgreviewMapper.selectByusing(1);
} catch (Exception e) {
Print.warning("获取鉴别程序的时候发生错误");
e.printStackTrace();
}
if (null != imgreview) {
LegalImageCheckForBaiDu(imgreview, images);
}
}
private void LegalImageCheckForBaiDu(Imgreview imgreview, Images images) {
System.out.println("非法图像鉴别进程启动-BaiDu");
if (imgreview.getUsing() == 1) {
try {
AipContentCensor client =
new AipContentCensor(
imgreview.getAppId(),
imgreview.getApiKey(),
imgreview.getSecretKey());
client.setConnectionTimeoutInMillis(5000);
client.setSocketTimeoutInMillis(30000);
// 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) {
com.alibaba.fastjson.JSONObject jsonObject =
(com.alibaba.fastjson.JSONObject) o;
com.alibaba.fastjson.JSONArray data = jsonObject.getJSONArray("data");
Integer conclusionType = jsonObject.getInteger("conclusionType");
if (conclusionType != null) {
if (conclusionType == 2) {
for (Object datum : data) {
com.alibaba.fastjson.JSONObject imgdata =
(com.alibaba.fastjson.JSONObject) datum;
if (imgdata.getInteger("type") == 1) {
Images img = new Images();
img.setImgname(images.getImgname());
img.setViolation("1[1]");
imgMapper.setImg(img);
Imgreview imgv = new Imgreview();
imgv.setId(1);
Integer count = imgreview.getCount();
System.out.println("违法图片总数:" + count);
imgv.setCount(count + 1);
imgreviewMapper.updateByPrimaryKeySelective(imgv);
System.err.println("存在非法图片,进行处理操作");
}
}
}
}
}
} catch (Exception e) {
System.out.println("图像鉴黄线程执行过程中出现异常");
e.printStackTrace();
}
}
}
// 计算时间
public static String plusDay(int setday) {
@@ -32,11 +32,11 @@ public class deleImages {
@Autowired private KeysServiceImpl keysService;
@Autowired private IRedisService iRedisService;
public Msg dele(String uuid, Integer... imgIds) {
public Msg dele(String uuid, Long... imgIds) {
Msg msg = new Msg();
MyProgress myProgress = new MyProgress();
myProgress.InitializeDelImg();
List<Integer> ids = new ArrayList<>();
List<Long> ids = new ArrayList<>();
int successCount = 0;
List<String> errorIds = new ArrayList<>();
for (int i = 0; i < imgIds.length; i++) {
@@ -111,9 +111,50 @@ public class deleImages {
return msg;
}
public static void main(String[] args) {
MyProgress myProgress = new MyProgress();
myProgress.InitializeDelImg();
System.out.println(JSONObject.toJSONString(myProgress));
public Msg dele2(String... imgIds) {
Msg msg = new Msg();
List<Long> ids = new ArrayList<>();
for (int i = 0; i < imgIds.length; i++) {
try {
Images image = imgService.selectByPrimaryKey(Long.valueOf(imgIds[i]));
Keys key = keysService.selectKeys(image.getSource());
if (key.getStorageType() == 1) {
nosImageupload.delNOS(key.getId(), image);
} else if (key.getStorageType() == 2) {
ossImageupload.delOSS(key.getId(), image);
} else if (key.getStorageType() == 3) {
ussImageupload.delUSS(key.getId(), image);
} else if (key.getStorageType() == 4) {
kodoImageupload.delKODO(key.getId(), image);
} else if (key.getStorageType() == 5) {
LocUpdateImg.deleteLOCImg(image);
} else if (key.getStorageType() == 6) {
cosImageupload.delCOS(key.getId(), image);
} else if (key.getStorageType() == 7) {
ftpService.delFTP(key.getId(), image);
} else if (key.getStorageType() == 8) {
s3Imageupload.deleS3(key.getId(), image);
} else {
System.err.println("未获取到对象存储参数,删除失败。");
}
try {
imgAndAlbumService.deleteImgAndAlbum(image.getImgurl());
imgTempService.delImgAndExp(image.getImguid());
imgService.deleimg(image.getId());
ids.add(image.getId());
} catch (Exception e) {
e.printStackTrace();
System.err.println(image.getImgname() + ":图片数据库记录时发生错误");
}
} catch (Exception e) {
System.err.println("删除的时候发生了一些异常");
// ids.add(Long.valueOf(imgIds[i]));
e.printStackTrace();
}
}
msg.setData(ids);
return msg;
}
}
@@ -1,11 +1,15 @@
package cn.hellohao.utils;
import cn.hellohao.config.GlobalConstant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import java.io.*;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.util.Properties;
import java.util.UUID;
@@ -16,7 +20,7 @@ import java.util.UUID;
*/
@Configuration
public class FirstRun implements InitializingBean {
private static Logger logger = LoggerFactory.getLogger(FirstRun.class);
@Value("${spring.datasource.username}")
private String jdbcusername;
@@ -34,13 +38,12 @@ public class FirstRun implements InitializingBean {
public void afterPropertiesSet() {
if(!DockerWebHost.contains("null")){
contentToTxt("/hellohaotbed/webapps/hellohao/config.json", "{\"serverHost\": \""+DockerWebHost+"\"}");
System.out.println("====>"+DockerWebHost);
}
isWindows();
RunSqlScript.USERNAME = jdbcusername;
RunSqlScript.PASSWORD = jdbcpass;
RunSqlScript.DBURL = jdbcurl;
Print.Normal("正在校验数据库参数...");
logger.info("正在校验数据库参数...");
RunSqlScript.RunInsert(dynamic);
RunSqlScript.RunInsert(compressed);
@@ -109,7 +112,6 @@ public class FirstRun implements InitializingBean {
Print.Normal("Add table.confdata");
}
// RunSqlScript.RunInsert(inddx_md5key);
RunSqlScript.RunInsert("UPDATE tbed.`keys` SET `Endpoint` = '0' WHERE `id` = 8");
RunSqlScript.RunInsert("ALTER TABLE tbed.`user` MODIFY id int auto_increment;");
Print.Normal("Stage success");
@@ -7,7 +7,7 @@ public class MyProgress {
private int delSuccessCount=0;//已经成功的个数
private List<String> delErrorImgListt = new ArrayList<>();//已经失败的图片
private int delOCT=0; //控制开关
private List<Integer> delSuccessImgList = new ArrayList<>(); //删除成功的图片
private List<Long> delSuccessImgList = new ArrayList<>(); //删除成功的图片
public void InitializeDelImg(){
this.delSuccessCount=0;//已经成功的个数
@@ -19,7 +19,7 @@ public class MyProgress {
public MyProgress() {
}
public MyProgress(int delSuccessCount, List<String> delErrorImgListt, int delOCT, List<Integer> delSuccessImgList) {
public MyProgress(int delSuccessCount, List<String> delErrorImgListt, int delOCT, List<Long> delSuccessImgList) {
this.delSuccessCount = delSuccessCount;
this.delErrorImgListt = delErrorImgListt;
this.delOCT = delOCT;
@@ -50,11 +50,11 @@ public class MyProgress {
this.delOCT = delOCT;
}
public List<Integer> getDelSuccessImgList() {
public List<Long> getDelSuccessImgList() {
return delSuccessImgList;
}
public void setDelSuccessImgList(List<Integer> delSuccessImgList) {
public void setDelSuccessImgList(List<Long> delSuccessImgList) {
this.delSuccessImgList = delSuccessImgList;
}
+1 -1
View File
@@ -49,5 +49,5 @@ spring.datasource.druid.stat-view-servlet.login-username=hellohao@dealer
spring.datasource.druid.stat-view-servlet.login-password=52BNmXPJL0rQQ3CU
spring.datasource.druid.stat-view-servlet.allow=127.0.0.1
spring.datasource.druid.web-stat-filter.exclusions=false
log4j.logger.cn.hellohao.dao=DEBUG
#log4j.logger.cn.hellohao.dao=DEBUG
log4j2.formatMsgNoLookups=True
+11 -9
View File
@@ -125,18 +125,20 @@
</appender>
<!--name包下的类的日志输出-->
<logger name="cn.hellohao" additivity="true" level="DEBUG" >
<logger name="cn.hellohao" additivity="false" level="DEBUG" >
<appender-ref ref="CONSOLE" />
<!-- <appender-ref ref="INFO" />-->
<appender-ref ref="INFO" />
<appender-ref ref="DEBUG" />
<appender-ref ref="ERROR" />
</logger>
<logger name="proxy.system.log" additivity="false">
<appender-ref ref="INFO" />
<appender-ref ref="DEBUG" />
<appender-ref ref="ERROR" />
</logger>
<!-- root级别 DEBUG -->
<root level="DEBUG">
<!-- 控制台输出 -->
<!-- <appender-ref ref="CONSOLE"/>-->
<!-- 不管什么包下的日志都输出文件 -->
<appender-ref ref="DEBUG"/>
<appender-ref ref="ERROR" />
</root>
<!-- <root level="DEBUG">-->
<!-- </root>-->
</configuration>
+7 -3
View File
@@ -121,7 +121,7 @@
select count(*) from imgdata where userid = #{userid}
</select>
<delete id="deleimg" parameterType="integer">
<delete id="deleimg" parameterType="Long">
DELETE FROM imgdata WHERE id=#{id}
</delete>
@@ -129,7 +129,7 @@
DELETE FROM imgdata WHERE imguid = #{imguid}
</delete>
<select id="selectByPrimaryKey" parameterType="integer" resultType="cn.hellohao.pojo.Images">
<select id="selectByPrimaryKey" parameterType="Long" resultType="cn.hellohao.pojo.Images">
select * from imgdata where id = #{id}
</select>
@@ -154,6 +154,10 @@
<if test="idname!=null and idname!=''">
idname=#{idname}
</if>
<if test="violation!=null and violation!=''">
violation=#{violation}
</if>
</set>
where imgname=#{imgname}
</update>
@@ -163,7 +167,7 @@
</delete>
<!-- 批量删除-->
<delete id="deleall" parameterType="integer">
<delete id="deleall" parameterType="Long">
DELETE FROM imgdata WHERE id = #{id}
</delete>