Browse Source

Merge remote-tracking branch 'origin/huji'

xing.li 3 years ago
parent
commit
87e1b9a120

+ 20 - 20
src/main/java/com/ads/business/service/impl/FileServiceImpl.java

@@ -14,27 +14,27 @@ import java.nio.file.StandardOpenOption;
 @Service
 @Service
 public class FileServiceImpl implements FileService {
 public class FileServiceImpl implements FileService {
 
 
-	@Autowired
-	private GetPictureConfigInData pictureConfig;
+    @Autowired
+    private GetPictureConfigInData pictureConfig;
 
 
-	@Override
-	public GetPicturePathOutData createUploadPath(String pictureName) {
-		// 上传文件的保存路径
-		Path storePath = Paths.get(pictureConfig.getBasePath(), pictureConfig.getUploadPath(), pictureName);
-		// 上传文件的显示路径
-		String serverPath = new StringBuilder(pictureConfig.getServerBasePath()).append("/").append(pictureConfig.getUploadPath()).append("/")
-		        .append(pictureName).toString();
-		return new GetPicturePathOutData(serverPath, storePath);
-	}
+    @Override
+    public GetPicturePathOutData createUploadPath(String pictureName) {
+        // 上传文件的保存路径
+        Path storePath = Paths.get(pictureConfig.getBasePath(), pictureConfig.getUploadPath(), pictureConfig.getSourceBasePath(), pictureName);
+        // 上传文件的显示路径
+        String serverPath = new StringBuilder(pictureConfig.getServerBasePath()).append("/").append(pictureConfig.getUploadPath()).append("/")
+                .append(pictureName).toString();
+        return new GetPicturePathOutData(serverPath, storePath);
+    }
 
 
-	@Override
-	public void savePicture(byte[] bytes, GetPicturePathOutData picturePath) throws Exception {
-		Path storePath = picturePath.getStoragePath();
-		Path parentPath = storePath.getParent();
-		if (!Files.exists(parentPath)) {
-			Files.createDirectories(parentPath);
-		}
-		Files.write(storePath, bytes, StandardOpenOption.CREATE);
-	}
+    @Override
+    public void savePicture(byte[] bytes, GetPicturePathOutData picturePath) throws Exception {
+        Path storePath = picturePath.getStoragePath();
+        Path parentPath = storePath.getParent();
+        if (!Files.exists(parentPath)) {
+            Files.createDirectories(parentPath);
+        }
+        Files.write(storePath, bytes, StandardOpenOption.CREATE);
+    }
 
 
 }
 }

+ 5 - 0
src/main/java/com/ads/common/data/GetPictureConfigInData.java

@@ -21,6 +21,11 @@ public class GetPictureConfigInData implements Serializable{
 	// 图片访问根目录
 	// 图片访问根目录
 	private String serverBasePath;
 	private String serverBasePath;
 
 
+	/**
+	 * 源文件存目录
+	 */
+	private String sourceBasePath;
+
 	// 上传目录
 	// 上传目录
 	private String uploadPath;
 	private String uploadPath;
 
 

+ 1 - 0
src/main/resources/config/application-release.yml

@@ -41,6 +41,7 @@ pict:
   basePath: /data/opt/project/ads/file
   basePath: /data/opt/project/ads/file
   serverBasePath: file
   serverBasePath: file
   uploadPath: upload
   uploadPath: upload
+  sourceBasePath: source
   serverPath: http://safe-api.hsay.com:19050/
   serverPath: http://safe-api.hsay.com:19050/