|
@@ -1,7 +1,9 @@
|
|
package com.huimv.process.service.impl;
|
|
package com.huimv.process.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.huimv.process.dao.entity.ImageCatalogEntity;
|
|
import com.huimv.process.dao.entity.ImagePathEntity;
|
|
import com.huimv.process.dao.entity.ImagePathEntity;
|
|
|
|
+import com.huimv.process.dao.repo.ImageCatalogRepo;
|
|
import com.huimv.process.dao.repo.ImagePathEntityRepository;
|
|
import com.huimv.process.dao.repo.ImagePathEntityRepository;
|
|
import com.huimv.process.service.IImageService;
|
|
import com.huimv.process.service.IImageService;
|
|
import com.huimv.process.utils.PictureUtil;
|
|
import com.huimv.process.utils.PictureUtil;
|
|
@@ -38,6 +40,8 @@ public class ImageServiceImpl implements IImageService {
|
|
private RestTemplate restTemplate;
|
|
private RestTemplate restTemplate;
|
|
@Autowired
|
|
@Autowired
|
|
private com.huimv.process.utils.utils utils;
|
|
private com.huimv.process.utils.utils utils;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ImageCatalogRepo imageCatalogRepo;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @Method : saveImage
|
|
* @Method : saveImage
|
|
@@ -56,10 +60,10 @@ public class ImageServiceImpl implements IImageService {
|
|
String userDir = System.getProperty("user.dir");
|
|
String userDir = System.getProperty("user.dir");
|
|
if (os.toLowerCase().indexOf("windows") != -1) {
|
|
if (os.toLowerCase().indexOf("windows") != -1) {
|
|
// Windows
|
|
// Windows
|
|
- uploadPath = "\\" + uploadPath + "\\";
|
|
|
|
|
|
+ uploadPath = "\\" + uploadPath + "\\"+name+"\\";
|
|
} else {
|
|
} else {
|
|
// Linux
|
|
// Linux
|
|
- uploadPath = "/" + uploadPath + "/";
|
|
|
|
|
|
+ uploadPath = "/" + uploadPath + "/"+name+"/";
|
|
}
|
|
}
|
|
// 时间戳
|
|
// 时间戳
|
|
long timeMillis = System.currentTimeMillis();
|
|
long timeMillis = System.currentTimeMillis();
|
|
@@ -67,6 +71,11 @@ public class ImageServiceImpl implements IImageService {
|
|
File dir = new File(uploadPath);
|
|
File dir = new File(uploadPath);
|
|
if (!dir.exists()) { // && dir.isDirectory()
|
|
if (!dir.exists()) { // && dir.isDirectory()
|
|
dir.mkdirs();
|
|
dir.mkdirs();
|
|
|
|
+ // 目录入库
|
|
|
|
+ ImageCatalogEntity imageCatalogEntity = new ImageCatalogEntity();
|
|
|
|
+ imageCatalogEntity.setCatalogName(name);
|
|
|
|
+ imageCatalogEntity.setCatalogPath(name);
|
|
|
|
+ imageCatalogRepo.saveAndFlush(imageCatalogEntity);
|
|
}
|
|
}
|
|
// type1
|
|
// type1
|
|
// String imgPath = uploadPath + name + "_"+ timeMillis + ".jpg";
|
|
// String imgPath = uploadPath + name + "_"+ timeMillis + ".jpg";
|