This commit is contained in:
s2042968 2025-03-03 14:24:28 +08:00
commit b8142c5ff2
9 changed files with 53 additions and 42 deletions

View File

@ -31,25 +31,25 @@ public class UserEdFileInfoController {
@UserOperation(value = "查看工程树", modelName =UserOperationModuleEnum.USER_PRJ)
@RequestMapping("tree")
public ElectromagneticResult<?> tree() {
return edFileInfoService.tree(DataOwnEnum.USER_PRJ.code);
return edFileInfoService.tree(DataOwnEnum.USER_FILE.code);
}
@UserOperation(value = "创建文件夹", modelName =UserOperationModuleEnum.USER_PRJ)
@RequestMapping("createFolder")
public ElectromagneticResult<?> createFolder(@RequestBody CreateFolderDTO createFolderDTO) {
return edFileInfoService.createFolder(createFolderDTO, DataOwnEnum.USER_PRJ.code);
return edFileInfoService.createFolder(createFolderDTO, DataOwnEnum.USER_FILE.code);
}
@UserOperation(value = "作废文件夹", modelName =UserOperationModuleEnum.USER_PRJ)
@RequestMapping("delete")
public ElectromagneticResult<?> delete(@RequestParam String id) {
return edFileInfoService.delete(id, DataOwnEnum.USER_PRJ.code);
return edFileInfoService.delete(id, DataOwnEnum.USER_FILE.code);
}
@UserOperation(value = "查询文件", modelName =UserOperationModuleEnum.USER_PRJ)
@RequestMapping("info")
public ElectromagneticResult<?> info(@RequestBody FileInfoQueryDTO fileInfoQueryDTO) {
return edFileInfoService.queryEdFileInfo(fileInfoQueryDTO, DataOwnEnum.USER_PRJ.code);
return edFileInfoService.queryEdFileInfo(fileInfoQueryDTO, DataOwnEnum.USER_FILE.code);
}
@UserOperation(value = "上传文件", modelName =UserOperationModuleEnum.USER_PRJ)
@ -57,19 +57,19 @@ public class UserEdFileInfoController {
public ElectromagneticResult<?> upload(@RequestParam("parentId") String parentId,
@RequestParam("file") MultipartFile file,
@RequestParam("strategy") Integer strategy) {
return edFileInfoService.upload(parentId, file, strategy, DataOwnEnum.USER_PRJ.code);
return edFileInfoService.upload(parentId, file, strategy, DataOwnEnum.USER_FILE.code);
}
@UserOperation(value = "下载文件", modelName =UserOperationModuleEnum.USER_PRJ)
@RequestMapping("download")
public ResponseEntity<InputStreamResource> download(@RequestParam String id, HttpServletResponse response) {
return edFileInfoService.download(id, response, DataOwnEnum.USER_PRJ.code);
return edFileInfoService.download(id, response, DataOwnEnum.USER_FILE.code);
}
@UserOperation(value = "更新文件信息", modelName =UserOperationModuleEnum.USER_PRJ)
@RequestMapping("updateFileInfo")
public ElectromagneticResult<?> updateFileInfo(@RequestBody UpdateFileInfoDTO updateFileInfoDTO) {
return edFileInfoService.updateFileInfo(updateFileInfoDTO, DataOwnEnum.USER_PRJ.code);
return edFileInfoService.updateFileInfo(updateFileInfoDTO, DataOwnEnum.USER_FILE.code);
}
@UserOperation(value = "移动文件", modelName =UserOperationModuleEnum.USER_PRJ)
@ -77,7 +77,7 @@ public class UserEdFileInfoController {
public ElectromagneticResult<?> moveFile(@RequestParam("id") String id,
@RequestParam("targetFolderId") String targetFolderId,
@RequestParam("strategy") Integer strategy) {
return edFileInfoService.moveFile(id, targetFolderId, strategy, DataOwnEnum.USER_PRJ.code);
return edFileInfoService.moveFile(id, targetFolderId, strategy, DataOwnEnum.USER_FILE.code);
}
@UserOperation(value = "复制文件", modelName =UserOperationModuleEnum.USER_PRJ)
@ -85,7 +85,7 @@ public class UserEdFileInfoController {
public ElectromagneticResult<?> copyFile(@RequestParam("id") String id,
@RequestParam("targetFolderId") String targetFolderId,
@RequestParam("strategy") Integer strategy) {
return edFileInfoService.copyFile(id, targetFolderId, strategy, DataOwnEnum.USER_PRJ.code);
return edFileInfoService.copyFile(id, targetFolderId, strategy, DataOwnEnum.USER_FILE.code);
}
@UserOperation(value = "查看文件历史版本信息", modelName =UserOperationModuleEnum.USER_PRJ)
@ -103,7 +103,7 @@ public class UserEdFileInfoController {
@UserOperation(value = "查询发布管理", modelName =UserOperationModuleEnum.USER_PRJ)
@RequestMapping(value = "/uploadRecord", method = RequestMethod.GET)
public ElectromagneticResult<?> uploadRecord(@RequestParam int pageNum, @RequestParam int pageSize) {
return edFileInfoService.uploadRecord(pageNum, pageSize, DataOwnEnum.USER_PRJ.code);
return edFileInfoService.uploadRecord(pageNum, pageSize, DataOwnEnum.USER_FILE.code);
}
@UserOperation(value = "查询文件详细信息", modelName =UserOperationModuleEnum.USER_PRJ)
@ -115,13 +115,13 @@ public class UserEdFileInfoController {
@UserOperation(value = "查询子文件集", modelName =UserOperationModuleEnum.USER_PRJ)
@RequestMapping(value = "/queryChildFolder", method = RequestMethod.GET)
public ElectromagneticResult<?> queryChildFolder(@RequestParam String parentId) {
return edFileInfoService.queryChildFolder(parentId, DataOwnEnum.USER_PRJ.code);
return edFileInfoService.queryChildFolder(parentId, DataOwnEnum.USER_FILE.code);
}
@UserOperation(value = "预览文件", modelName =UserOperationModuleEnum.USER_PRJ)
@RequestMapping(value = "preview", method = RequestMethod.GET)
public ResponseEntity<InputStreamResource> preview(@RequestParam String id, HttpServletResponse response) {
return edFileInfoService.preview(id, response, DataOwnEnum.USER_PRJ.code);
return edFileInfoService.preview(id, response, DataOwnEnum.USER_FILE.code);
}
/**

View File

@ -139,17 +139,18 @@ public class CommonService {
return parentId + FILE_TYPE_ENUM.getOrDefault(fileType, "00") + version + timeStr;
}
public List<EdFileInfo> selectAllAdminFolder(String id, boolean isAdminQuery, List<String> accessableIds) {
public List<EdFileInfo> selectAllAdminFolder(String id, List<String> accessibleIds, int dataOwnCode) {
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FOLDER.code)
.eq(EdFileInfo::getDataOwn, DataOwnEnum.SYS_PRJ.code)
.likeRight(EdFileInfo::getFilePath, id);
if (!isAdminQuery) {
queryWrapper.in(EdFileInfo::getId, accessableIds);
if (dataOwnCode == DataOwnEnum.COMMON.code) {
queryWrapper.eq(EdFileInfo::getDataOwn, DataOwnEnum.SYS_PRJ.code);
queryWrapper.in(EdFileInfo::getId, accessibleIds);
} else {
queryWrapper.eq(EdFileInfo::getDataOwn, DataOwnEnum.USER_PRJ.code);
}
return edFileInfoMapper.selectList(queryWrapper);
}
@ -219,24 +220,29 @@ public class CommonService {
}
}
public List<String> queryAllPrjInfo(boolean isAdminQuery, List<String> prjIds, int dataOwnCode) {
public List<String> queryAllPrjInfo(List<String> prjIds, int dataOwnCode) {
try {
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
.select(EdFileInfo::getId)
.eq(EdFileInfo::getDataOwn, dataOwnCode)
.eq(EdFileInfo::getParentId, PRJ_PARENT_ID)
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code);
if (!isAdminQuery) {
if (dataOwnCode == DataOwnEnum.COMMON.code) {
queryWrapper.eq(EdFileInfo::getDataOwn, DataOwnEnum.SYS_PRJ.code);
} else if (dataOwnCode == DataOwnEnum.USER_FILE.code) {
queryWrapper.eq(EdFileInfo::getDataOwn, DataOwnEnum.USER_PRJ.code);
}
if (dataOwnCode == DataOwnEnum.SYS_PRJ.code || dataOwnCode == DataOwnEnum.USER_PRJ.code) {
queryWrapper.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.PUBLISHED.code).in(EdFileInfo::getId, prjIds);
}
List<String> ids = edFileInfoMapper.selectList(queryWrapper).stream().map(EdFileInfo::getId).collect(Collectors.toList());
List<String> projectVOS = new ArrayList<>();
for (String id : ids) {
List<EdFileInfo> edFileInfos = selectAllAdminFolder(id, isAdminQuery, prjIds);
if (!isAdminQuery) {
List<EdFileInfo> edFileInfos = selectAllAdminFolder(id, prjIds, dataOwnCode);
if (dataOwnCode == DataOwnEnum.USER_PRJ.code || dataOwnCode == DataOwnEnum.SYS_PRJ.code) {
edFileInfos = edFileInfos.stream().filter(e -> e.getDataStatus().equals(EleDataStatusEnum.PUBLISHED.code)
|| e.getDataStatus().equals(EleDataStatusEnum.DELETED.code))
.collect(Collectors.toList());
@ -244,7 +250,7 @@ public class CommonService {
edFileInfos = edFileInfos.stream().filter(e -> !e.getDataStatus().equals(EleDataStatusEnum.DELETED.code)).collect(Collectors.toList());
}
// 转换为树
if (isAdminQuery) {
if (dataOwnCode == DataOwnEnum.USER_PRJ.code || dataOwnCode == DataOwnEnum.SYS_PRJ.code) {
TreeNodeConfig config = new TreeNodeConfig();
config.setIdKey(EdFileInfo.Fields.id);
config.setParentIdKey(EdFileInfo.Fields.parentId);
@ -375,7 +381,7 @@ public class CommonService {
}
public Set<String> selectPrjLeafs(int dataOwnCode) {
List<String> prjInfo = queryAllPrjInfo(true, null, dataOwnCode);
List<String> prjInfo = queryAllPrjInfo( null, dataOwnCode);
Set<String> res = new HashSet<>();
prjInfo.forEach(e -> {
ProjectVO projectVO = JSONUtil.toList(e, ProjectVO.class).get(0);

View File

@ -162,10 +162,10 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
@Override
public ElectromagneticResult<?> tree(int dataOwnCode) {
List<String> prjIds = permissionService.getAccessibleTree();
if (CollUtil.isEmpty(prjIds)) {
if (CollUtil.isEmpty(prjIds) && dataOwnCode != DataOwnEnum.USER_FILE.code ) {
return ElectromagneticResultUtil.success(new ArrayList<>());
}
List<String> strings = commonService.queryAllPrjInfo(false, prjIds, dataOwnCode);
List<String> strings = commonService.queryAllPrjInfo(prjIds, dataOwnCode);
List<FileProjectVO> res = new ArrayList<>();
strings.forEach(e -> {
FileProjectVO fileProjectVO = JSONUtil.toList(e, FileProjectVO.class).get(0);

View File

@ -239,7 +239,7 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
*/
@Override
public ElectromagneticResult<?> queryAllPrjInfo(int dataOwnCode) {
List<String> res = commonService.queryAllPrjInfo(true, null, dataOwnCode);
List<String> res = commonService.queryAllPrjInfo(null, dataOwnCode);
List<ProjectVO> projectVOS = new ArrayList<>();
res.forEach(e -> {
ProjectVO projectVO = JSONUtil.toList(e, ProjectVO.class).get(0);
@ -355,11 +355,11 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
String currentUserId = UserThreadLocal.getUserId();
// 把source工程的层级结构copy到目标工程
// 查找source的全部目录
List<EdFileInfo> sourceEdFileInfos = commonService.selectAllAdminFolder(sourceId, true, null);
List<EdFileInfo> sourceEdFileInfos = commonService.selectAllAdminFolder(sourceId, null, dataOwnCode);
List<String> needSavePaths = new ArrayList<>();
// 确定层级最大为prjFolderMaxLength层现在逐层来处理
for (int i = 1; i <= prjFolderMaxLength; ++i) {
List<EdFileInfo> targetEdFileInfos = commonService.selectAllAdminFolder(targetId, true, null);
List<EdFileInfo> targetEdFileInfos = commonService.selectAllAdminFolder(targetId, null, dataOwnCode);
// 先查找source第i层下有那些子集
final int count = i;
// 取source当前层

View File

@ -93,7 +93,8 @@ public class UserServiceImpl implements UserService {
|| Objects.equals(user.getEffectFlag(), EffectFlagEnum.NOT_EFFECTIVE.code)
) {
return false;
} else return user.getInternshipEndDate() == null || !user.getInternshipEndDate().before(now());
}
return user.getInternshipEndDate() == null || !user.getInternshipEndDate().before(now());
}
public String createToken(UserLoginInfo loginInfo) {

View File

@ -1,9 +1,9 @@
#required
spring.application.name=electromagnetic-data
spring.datasource.typd=com.alibaba.druid.pool.DruidDataSource
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/em_data_dev?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=GMT%2B8&allowMultiQueries=true&rewriteBatchedStatements=true
spring.datasource.username=user
spring.datasource.password=123123
spring.datasource.url=jdbc:mysql://139.196.179.195:3306/em_data_dev?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=GMT%2B8&allowMultiQueries=true&rewriteBatchedStatements=true
spring.datasource.username=em_user_dev
spring.datasource.password=Szsd#2O25$dev
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource

View File

@ -1,5 +1,7 @@
//import com.electromagnetic.industry.software.common.enums.DataOwnEnum;
//import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
//import com.electromagnetic.industry.software.manage.Application;
//import com.electromagnetic.industry.software.manage.service.serviceimpl.EdPrjServiceImpl;
//import com.electromagnetic.industry.software.manage.service.EdFileInfoService;
//import org.junit.jupiter.api.Test;
//import org.springframework.boot.test.context.SpringBootTest;
//
@ -9,13 +11,12 @@
//public class Test1 {
//
// @Resource
// private EdPrjServiceImpl edPrjService;
// private EdFileInfoService edFileInfoService;
//
// @Test
// public void testFollow() {
// String sourceId = "100101";
// String targetId = "100323";
// edPrjService.follow(sourceId, targetId);
// public void testTree() {
// ElectromagneticResult<?> tree = edFileInfoService.tree(DataOwnEnum.USER_FILE.code);
// System.out.println("tree = " + tree);
// }
//
//}

View File

@ -8,7 +8,8 @@ public enum DataOwnEnum {
COMMON(0, "上传的文件或者新建的文件夹"),
SYS_PRJ(1, "系统管理员创建的层级"),
USER_PRJ(2, "用户自定义的层级"),
REPO_FILE(3, "库文件");
REPO_FILE(3, "库文件"),
USER_FILE(4, "用户上传的文件或创建的文件夹");
public int code;
public String desc;

View File

@ -25,7 +25,9 @@ public class UserThreadLocal {
}
public static String getUserId() {
return userThread.get().getUserId();
return "1859514019333836800";
// return userThread.get().getUserId();
}
public static String getAdminType() {