合并development代码到master #1

Merged
cuizhibin merged 21 commits from development into master 2025-08-11 09:25:53 +08:00
6 changed files with 66 additions and 82 deletions
Showing only changes of commit 2a4ac18052 - Show all commits

View File

@ -25,7 +25,7 @@ public class BusinessDataEntity {
// 父级文件夹 // 父级文件夹
private Long parentId = null; private Long parentId = null;
// 创建人 // 创建人
private Long creatorId = null; private String creatorId = null;
// 创建时间 // 创建时间
private LocalDateTime createTime = null; private LocalDateTime createTime = null;
// 更新时间 // 更新时间

View File

@ -30,7 +30,7 @@ public class BusinessDataFileEntity {
//上传时间 //上传时间
private Date uploadTime = null; private Date uploadTime = null;
//上传人id //上传人id
private Long uploaderId = null; private String uploaderId = null;
//是否删除 //是否删除
private Boolean isDeleted = false; private Boolean isDeleted = false;

View File

@ -43,9 +43,7 @@ public class BusinessDataFileServiceImpl implements BusinessDataFileService {
//删除数据库数据 //删除数据库数据
if (folderId != null){ if (folderId != null){
businessDataFileMapper.delete(null,folderId); businessDataFileMapper.delete(null,folderId);
System.out.println("888888888走对了"); return Result.okM("删除成功");
return Result.okM("删除,走对了,成功");
} }
//删除文件 //删除文件

View File

@ -1,5 +1,6 @@
package com.dite.znpt.service.impl; package com.dite.znpt.service.impl;
import cn.dev33.satoken.stp.StpUtil;
import com.dite.znpt.domain.Result; import com.dite.znpt.domain.Result;
import com.dite.znpt.domain.entity.BusinessDataEntity; import com.dite.znpt.domain.entity.BusinessDataEntity;
import com.dite.znpt.domain.page.PageBean; import com.dite.znpt.domain.page.PageBean;
@ -55,9 +56,10 @@ public class BusinessDataServiceImpl implements BusinessDataService {
@Override @Override
public Result createFolder(String folderName, Long parentId) { public Result createFolder(String folderName, Long parentId) {
// 获取ID // 获取ID
Long loginIdAsLong = 888L; String loginIdAsLong = "未登录用户";
// loginIdAsLong = StpUtil.getLoginIdAsLong(); if(StpUtil.isLogin()){
// loginIdAsLong = StpUtil.getLoginIdAsString();
}
// 文件夹名称不能为空 // 文件夹名称不能为空
// TODO: 添加文件夹名称校验,后续最好更规范些写个工具类专门校验用正则表达式 // TODO: 添加文件夹名称校验,后续最好更规范些写个工具类专门校验用正则表达式
if (folderName == null || folderName.trim().isEmpty()) { if (folderName == null || folderName.trim().isEmpty()) {
@ -74,6 +76,15 @@ public class BusinessDataServiceImpl implements BusinessDataService {
if (parentId != 0L) { if (parentId != 0L) {
// 获取父文件夹路径 // 获取父文件夹路径
targetDir = Paths.get(businessDataMapper.getPath(parentId), folderName1).toFile(); 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()) { if (!targetDir.exists()) {
@ -92,8 +103,7 @@ public class BusinessDataServiceImpl implements BusinessDataService {
LocalDateTime.now(), LocalDateTime.now(),
LocalDateTime.now(), LocalDateTime.now(),
false, false,
targetDir.getAbsolutePath() targetDir.getAbsolutePath());
);
// 插入到数据库 // 插入到数据库
businessDataMapper.insert(businessDataEntity); businessDataMapper.insert(businessDataEntity);
return Result.okM("文件夹创建成功"); return Result.okM("文件夹创建成功");
@ -107,31 +117,6 @@ public class BusinessDataServiceImpl implements BusinessDataService {
return businessDataMapper.getPath(parentId); 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("删除文件夹") @ApiOperation("删除文件夹")
@Override @Override
public Result delete(Long folderId) { public Result delete(Long folderId) {
@ -161,13 +146,13 @@ public class BusinessDataServiceImpl implements BusinessDataService {
return Result.error("文件夹不存在: " + folderPath); return Result.error("文件夹不存在: " + folderPath);
} }
} }
@ApiOperation("重命名文件夹") @ApiOperation("重命名文件夹")
@Override @Override
public Result reName(Long folderId, String newName) { public Result reName(Long folderId, String newName) {
// 获取文件夹路径 // 获取文件夹路径
String folderPath = businessDataMapper.getPath(folderId); String folderPath = businessDataMapper.getPath(folderId);
String newPath = folderPath.substring(0, folderPath.lastIndexOf('\\')) + "\\" + newName; String newPath = folderPath.substring(0, folderPath.lastIndexOf('\\')) + "\\" + newName;
System.out.printf("7777777"+newPath);
// //
// //想命名的原文件的路径 // //想命名的原文件的路径
// File file = new File("f:/a/a.xlsx"); // File file = new File("f:/a/a.xlsx");
@ -187,11 +172,8 @@ public class BusinessDataServiceImpl implements BusinessDataService {
null, null,
now, now,
null, null,
newPath newPath);
);
System.out.println(businessDataEntity);
businessDataMapper.reName(businessDataEntity); businessDataMapper.reName(businessDataEntity);
return Result.okM("重命名成功"); return Result.okM("重命名成功");
} }
} }

View File

@ -1,5 +1,6 @@
package com.dite.znpt.web.controller; package com.dite.znpt.web.controller;
import cn.dev33.satoken.stp.StpUtil;
import com.dite.znpt.domain.Result; import com.dite.znpt.domain.Result;
import com.dite.znpt.domain.entity.BusinessDataFileEntity; import com.dite.znpt.domain.entity.BusinessDataFileEntity;
import com.dite.znpt.domain.page.PageBean; import com.dite.znpt.domain.page.PageBean;
@ -53,6 +54,10 @@ public class BusinessDataFileController {
@PostMapping("/add") @PostMapping("/add")
public Result add(@RequestParam("file") MultipartFile file, public Result add(@RequestParam("file") MultipartFile file,
@RequestParam Long folderId) { @RequestParam Long folderId) {
String loginIdAsLong = "未登录用户";
if(StpUtil.isLogin()){
loginIdAsLong = StpUtil.getLoginIdAsString();
}
if (file.isEmpty()) { if (file.isEmpty()) {
return Result.error("上传文件为空"); return Result.error("上传文件为空");
@ -75,9 +80,9 @@ public class BusinessDataFileController {
fileEntity.setFileName(file.getOriginalFilename()); fileEntity.setFileName(file.getOriginalFilename());
fileEntity.setFilePath(uploadDir + "\\" + file.getOriginalFilename()); fileEntity.setFilePath(uploadDir + "\\" + file.getOriginalFilename());
fileEntity.setFileType(file.getContentType()); fileEntity.setFileType(file.getContentType());
fileEntity.setFileSize(file.getSize()); fileEntity.setFileSize(file.getSize()/1024);
fileEntity.setUploadTime(new Date()); fileEntity.setUploadTime(new Date());
fileEntity.setUploaderId(0L); fileEntity.setUploaderId(loginIdAsLong);
System.out.println(uploadDir + "\\" + file.getOriginalFilename()); System.out.println(uploadDir + "\\" + file.getOriginalFilename());
businessDataFileService.add(fileEntity); businessDataFileService.add(fileEntity);

View File

@ -1,7 +1,6 @@
# 开发环境配置 # 开发环境配置
server: server:
# 服务器的HTTP端口默认为8080 # 服务器的HTTP端口默认为8080
port: 8888 port: 8888
# 数据源配置 # 数据源配置