|
@@ -55,10 +55,10 @@ public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo> i
|
|
|
String currentYearMonth = dateFormat.format(new Date());
|
|
|
|
|
|
int index = fileName.lastIndexOf(".");
|
|
|
- String fileType = fileName.substring(index+1,fileName.length());
|
|
|
+ String fileType = fileName.substring(index + 1, fileName.length());
|
|
|
|
|
|
//文件保存位置
|
|
|
- File saveDir = new File(fileConfig.getPath()+ "/" +currentYearMonth);
|
|
|
+ File saveDir = new File(fileConfig.getPath() + "/" + currentYearMonth);
|
|
|
if (!saveDir.exists()) {
|
|
|
saveDir.mkdir();
|
|
|
}
|
|
@@ -66,7 +66,7 @@ public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo> i
|
|
|
String uuid = UUID.randomUUID().toString();
|
|
|
// 截取其中的一部分作为随机字符串
|
|
|
String randomStr = uuid.substring(0, 3);
|
|
|
- String newFileName = System.currentTimeMillis()+ randomStr + "." + fileType;
|
|
|
+ String newFileName = System.currentTimeMillis() + randomStr + "." + fileType;
|
|
|
File fileOut = new File(saveDir + File.separator + newFileName);
|
|
|
FileOutputStream fos = new FileOutputStream(fileOut);
|
|
|
fos.write(getData);
|
|
@@ -78,15 +78,15 @@ public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo> i
|
|
|
fileInfo.setBusinessType(businessType);
|
|
|
fileInfo.setSeq(i);
|
|
|
fileInfo.setFileName(newFileName);
|
|
|
- fileInfo.setFileUrl(fileConfig.getUrl() + "/" + newFileName);
|
|
|
+ fileInfo.setFileUrl(fileConfig.getUrl() + "/" + currentYearMonth + "/" + newFileName);
|
|
|
fileInfo.setFilePath(saveDir + File.separator + newFileName);
|
|
|
this.save(fileInfo);
|
|
|
- if(i==0) {
|
|
|
+ if (i == 0) {
|
|
|
ids += fileInfo.getId();
|
|
|
} else {
|
|
|
ids += "," + fileInfo.getId();
|
|
|
}
|
|
|
- System.out.println(fileInfo.getId()+"这是是个ID");
|
|
|
+ System.out.println(fileInfo.getId() + "这是是个ID");
|
|
|
}
|
|
|
return Response.success(ids);
|
|
|
}
|