合并development代码到master #1
|
@ -25,7 +25,7 @@ public class BusinessDataEntity {
|
|||
// 父级文件夹
|
||||
private Long parentId = null;
|
||||
// 创建人
|
||||
private Long creatorId = null;
|
||||
private String creatorId = null;
|
||||
// 创建时间
|
||||
private LocalDateTime createTime = null;
|
||||
// 更新时间
|
||||
|
|
|
@ -30,7 +30,7 @@ public class BusinessDataFileEntity {
|
|||
//上传时间
|
||||
private Date uploadTime = null;
|
||||
//上传人id
|
||||
private Long uploaderId = null;
|
||||
private String uploaderId = null;
|
||||
//是否删除
|
||||
private Boolean isDeleted = false;
|
||||
|
||||
|
|
|
@ -43,9 +43,7 @@ public class BusinessDataFileServiceImpl implements BusinessDataFileService {
|
|||
//删除数据库数据
|
||||
if (folderId != null){
|
||||
businessDataFileMapper.delete(null,folderId);
|
||||
System.out.println("888888888走对了");
|
||||
|
||||
return Result.okM("删除,走对了,成功");
|
||||
return Result.okM("删除成功");
|
||||
}
|
||||
|
||||
//删除文件
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.dite.znpt.service.impl;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.dite.znpt.domain.Result;
|
||||
import com.dite.znpt.domain.entity.BusinessDataEntity;
|
||||
import com.dite.znpt.domain.page.PageBean;
|
||||
|
@ -55,9 +56,10 @@ public class BusinessDataServiceImpl implements BusinessDataService {
|
|||
@Override
|
||||
public Result createFolder(String folderName, Long parentId) {
|
||||
// 获取ID
|
||||
Long loginIdAsLong = 888L;
|
||||
// loginIdAsLong = StpUtil.getLoginIdAsLong();
|
||||
//
|
||||
String loginIdAsLong = "未登录用户";
|
||||
if(StpUtil.isLogin()){
|
||||
loginIdAsLong = StpUtil.getLoginIdAsString();
|
||||
}
|
||||
// 文件夹名称不能为空
|
||||
// TODO: 添加文件夹名称校验,后续最好更规范些,写个工具类专门校验,用正则表达式
|
||||
if (folderName == null || folderName.trim().isEmpty()) {
|
||||
|
@ -74,6 +76,15 @@ public class BusinessDataServiceImpl implements BusinessDataService {
|
|||
if (parentId != 0L) {
|
||||
// 获取父文件夹路径
|
||||
targetDir = Paths.get(businessDataMapper.getPath(parentId), folderName1).toFile();
|
||||
} else {
|
||||
// 如果是根目录,检查默认路径是否存在,不存在则创建
|
||||
File defaultPathDir = new File(businessDataPath);
|
||||
if (!defaultPathDir.exists()) {
|
||||
boolean created = defaultPathDir.mkdirs();
|
||||
if (!created) {
|
||||
return Result.error("默认路径创建失败: " + businessDataPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 创建文件夹和新增文件夹路径
|
||||
if (!targetDir.exists()) {
|
||||
|
@ -92,8 +103,7 @@ public class BusinessDataServiceImpl implements BusinessDataService {
|
|||
LocalDateTime.now(),
|
||||
LocalDateTime.now(),
|
||||
false,
|
||||
targetDir.getAbsolutePath()
|
||||
);
|
||||
targetDir.getAbsolutePath());
|
||||
// 插入到数据库
|
||||
businessDataMapper.insert(businessDataEntity);
|
||||
return Result.okM("文件夹创建成功");
|
||||
|
@ -107,31 +117,6 @@ public class BusinessDataServiceImpl implements BusinessDataService {
|
|||
return businessDataMapper.getPath(parentId);
|
||||
}
|
||||
|
||||
// @ApiOperation("删除文件夹")
|
||||
// @Override
|
||||
// public Result delete(Long folderId) {
|
||||
// // 获取文件夹路径
|
||||
// String folderPath = businessDataMapper.getPath(folderId);
|
||||
//
|
||||
// // 创建File对象并删除文件夹
|
||||
// File folder = new File(folderPath);
|
||||
// if (folder.exists()) {
|
||||
// boolean deleted = folder.delete();
|
||||
// if (!deleted) {
|
||||
// // throw new RuntimeException("文件夹删除失败: " + folderPath);
|
||||
// // TODO: 以后可以用全局异常处理器捕获,或者用try catch捕获
|
||||
// return Result.error("文件夹删除失败: " + folderPath);
|
||||
// }
|
||||
// //删除数据库中文件夹的数据
|
||||
// businessDataMapper.delete(folderId);
|
||||
// //删除文件夹下文件的数据
|
||||
// businessDataFileService.delete(folderId);
|
||||
// return Result.okM("删除成功");
|
||||
// } else {
|
||||
// // throw new RuntimeException("文件夹不存在: " + folderPath);
|
||||
// return Result.error("文件夹不存在: " + folderPath);
|
||||
// }
|
||||
// }
|
||||
@ApiOperation("删除文件夹")
|
||||
@Override
|
||||
public Result delete(Long folderId) {
|
||||
|
@ -161,13 +146,13 @@ public class BusinessDataServiceImpl implements BusinessDataService {
|
|||
return Result.error("文件夹不存在: " + folderPath);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("重命名文件夹")
|
||||
@Override
|
||||
public Result reName(Long folderId, String newName) {
|
||||
// 获取文件夹路径
|
||||
String folderPath = businessDataMapper.getPath(folderId);
|
||||
String newPath = folderPath.substring(0, folderPath.lastIndexOf('\\')) + "\\" + newName;
|
||||
System.out.printf("7777777"+newPath);
|
||||
//
|
||||
// //想命名的原文件的路径
|
||||
// File file = new File("f:/a/a.xlsx");
|
||||
|
@ -187,11 +172,8 @@ public class BusinessDataServiceImpl implements BusinessDataService {
|
|||
null,
|
||||
now,
|
||||
null,
|
||||
newPath
|
||||
);
|
||||
System.out.println(businessDataEntity);
|
||||
newPath);
|
||||
businessDataMapper.reName(businessDataEntity);
|
||||
return Result.okM("重命名成功");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.dite.znpt.web.controller;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.dite.znpt.domain.Result;
|
||||
import com.dite.znpt.domain.entity.BusinessDataFileEntity;
|
||||
import com.dite.znpt.domain.page.PageBean;
|
||||
|
@ -53,6 +54,10 @@ public class BusinessDataFileController {
|
|||
@PostMapping("/add")
|
||||
public Result add(@RequestParam("file") MultipartFile file,
|
||||
@RequestParam Long folderId) {
|
||||
String loginIdAsLong = "未登录用户";
|
||||
if(StpUtil.isLogin()){
|
||||
loginIdAsLong = StpUtil.getLoginIdAsString();
|
||||
}
|
||||
|
||||
if (file.isEmpty()) {
|
||||
return Result.error("上传文件为空");
|
||||
|
@ -75,9 +80,9 @@ public class BusinessDataFileController {
|
|||
fileEntity.setFileName(file.getOriginalFilename());
|
||||
fileEntity.setFilePath(uploadDir + "\\" + file.getOriginalFilename());
|
||||
fileEntity.setFileType(file.getContentType());
|
||||
fileEntity.setFileSize(file.getSize());
|
||||
fileEntity.setFileSize(file.getSize()/1024);
|
||||
fileEntity.setUploadTime(new Date());
|
||||
fileEntity.setUploaderId(0L);
|
||||
fileEntity.setUploaderId(loginIdAsLong);
|
||||
System.out.println(uploadDir + "\\" + file.getOriginalFilename());
|
||||
businessDataFileService.add(fileEntity);
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
# 开发环境配置
|
||||
server:
|
||||
# 服务器的HTTP端口,默认为8080
|
||||
|
||||
port: 8888
|
||||
|
||||
# 数据源配置
|
||||
|
|
Loading…
Reference in New Issue