优化代码,解决已知问题。
This commit is contained in:
parent
6ca5b5cec5
commit
f22aad8b27
|
|
@ -25,7 +25,7 @@ import java.io.IOException;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/data/ed/file")
|
@RequestMapping("/data/ed/file")
|
||||||
public class EdFileInfoController {
|
public class SysEdFileInfoController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private EdFileInfoService edFileInfoService;
|
private EdFileInfoService edFileInfoService;
|
||||||
|
|
@ -21,7 +21,7 @@ import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/data/ed/prj")
|
@RequestMapping("/data/ed/prj")
|
||||||
public class ProjectController {
|
public class SysProjectController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private EdPrjService edPrjService;
|
private EdPrjService edPrjService;
|
||||||
|
|
@ -311,6 +311,7 @@ public class CommonService {
|
||||||
LambdaQueryWrapper<EdFileInfo> prjQueryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
LambdaQueryWrapper<EdFileInfo> prjQueryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
||||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
||||||
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FOLDER.code)
|
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FOLDER.code)
|
||||||
|
.eq(EdFileInfo::getDataOwn, DataOwnEnum.SYS_PRJ.code)
|
||||||
.likeRight(EdFileInfo::getFilePath, id);
|
.likeRight(EdFileInfo::getFilePath, id);
|
||||||
|
|
||||||
if (querySource == PrjQuerySource.SYS_DB.value) {
|
if (querySource == PrjQuerySource.SYS_DB.value) {
|
||||||
|
|
@ -377,7 +378,7 @@ public class CommonService {
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Integer, List<String>> queryRepoPrjTree(int querySource, Object returnType) {
|
public Map<Integer, List<String>> queryRepoPrjTree(int querySource, List<String> accessibleIds, Object returnType) {
|
||||||
|
|
||||||
Map<Integer, List<String>> map = new HashMap<>();
|
Map<Integer, List<String>> map = new HashMap<>();
|
||||||
try {
|
try {
|
||||||
|
|
@ -387,6 +388,10 @@ public class CommonService {
|
||||||
.eq(EdFileInfo::getDataOwn, DataOwnEnum.REPO_PRJ.code)
|
.eq(EdFileInfo::getDataOwn, DataOwnEnum.REPO_PRJ.code)
|
||||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
||||||
.eq(EdFileInfo::getParentId, PRJ_PARENT_ID);
|
.eq(EdFileInfo::getParentId, PRJ_PARENT_ID);
|
||||||
|
if (CollUtil.isNotEmpty(accessibleIds)) {
|
||||||
|
queryWrapper.in(EdFileInfo::getId, accessibleIds);
|
||||||
|
}
|
||||||
|
|
||||||
List<String> prjIds = edFileInfoMapper.selectList(queryWrapper).stream().map(EdFileInfo::getId).collect(Collectors.toList());
|
List<String> prjIds = edFileInfoMapper.selectList(queryWrapper).stream().map(EdFileInfo::getId).collect(Collectors.toList());
|
||||||
|
|
||||||
for (String id : prjIds) {
|
for (String id : prjIds) {
|
||||||
|
|
@ -395,6 +400,9 @@ public class CommonService {
|
||||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
||||||
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FOLDER.code)
|
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FOLDER.code)
|
||||||
.likeRight(EdFileInfo::getFilePath, id);
|
.likeRight(EdFileInfo::getFilePath, id);
|
||||||
|
if (CollUtil.isNotEmpty(accessibleIds)) {
|
||||||
|
queryWrapper.in(EdFileInfo::getId, accessibleIds);
|
||||||
|
}
|
||||||
|
|
||||||
if (querySource == PrjQuerySource.REPO_DB.value) {
|
if (querySource == PrjQuerySource.REPO_DB.value) {
|
||||||
prjQueryWrapper.and(qr -> qr.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.WAIT_DELETED.code)
|
prjQueryWrapper.and(qr -> qr.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.WAIT_DELETED.code)
|
||||||
|
|
@ -508,7 +516,7 @@ public class CommonService {
|
||||||
} else if (DataOwnEnum.isUserCode(dataOwnCode)) {
|
} else if (DataOwnEnum.isUserCode(dataOwnCode)) {
|
||||||
prjInfo = queryUserPrjTree(PrjQuerySource.USER_DB.value, new FileProjectVO()).getOrDefault(PrjQuerySource.USER_DB.value, new ArrayList<>());
|
prjInfo = queryUserPrjTree(PrjQuerySource.USER_DB.value, new FileProjectVO()).getOrDefault(PrjQuerySource.USER_DB.value, new ArrayList<>());
|
||||||
} else {
|
} else {
|
||||||
prjInfo = queryRepoPrjTree(PrjQuerySource.REPO_DB.value, new FileProjectVO()).getOrDefault(PrjQuerySource.REPO_DB.value, new ArrayList<>());
|
prjInfo = queryRepoPrjTree(PrjQuerySource.REPO_DB.value, accessibleIds, new FileProjectVO()).getOrDefault(PrjQuerySource.REPO_DB.value, new ArrayList<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String info : prjInfo) {
|
for (String info : prjInfo) {
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,6 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
|
|
||||||
.eq(ObjUtil.equals(pars.getDataStatus(), EleDataStatusEnum.NOT_PUBLISHED.code), EdFileInfo::getDataStatus, EleDataStatusEnum.NOT_PUBLISHED.code)
|
.eq(ObjUtil.equals(pars.getDataStatus(), EleDataStatusEnum.NOT_PUBLISHED.code), EdFileInfo::getDataStatus, EleDataStatusEnum.NOT_PUBLISHED.code)
|
||||||
.eq(ObjUtil.equals(pars.getDataStatus(), EleDataStatusEnum.PUBLISHED.code), EdFileInfo::getDataStatus, EleDataStatusEnum.PUBLISHED.code)
|
.eq(ObjUtil.equals(pars.getDataStatus(), EleDataStatusEnum.PUBLISHED.code), EdFileInfo::getDataStatus, EleDataStatusEnum.PUBLISHED.code)
|
||||||
// .eq(ObjUtil.equals(pars.getDataStatus(), EleDataStatusEnum.OCCUPY.code), EdFileInfo::getDataStatus, EleDataStatusEnum.OCCUPY.code)
|
|
||||||
|
|
||||||
.eq(StrUtil.isNotEmpty(pars.getFileType()), EdFileInfo::getFileType, pars.getFileType())
|
.eq(StrUtil.isNotEmpty(pars.getFileType()), EdFileInfo::getFileType, pars.getFileType())
|
||||||
.orderByAsc(ObjUtil.equals(pars.getCreatedTime(), 0), EdFileInfo::getCreatedTime)
|
.orderByAsc(ObjUtil.equals(pars.getCreatedTime(), 0), EdFileInfo::getCreatedTime)
|
||||||
|
|
@ -220,7 +219,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
} else if (querySource == PrjQuerySource.USER_DB.value) {
|
} else if (querySource == PrjQuerySource.USER_DB.value) {
|
||||||
map = commonService.queryUserPrjTree(querySource, new FileProjectVO());
|
map = commonService.queryUserPrjTree(querySource, new FileProjectVO());
|
||||||
} else {
|
} else {
|
||||||
map = commonService.queryRepoPrjTree(querySource, new FileProjectVO());
|
map = commonService.queryRepoPrjTree(querySource, accessibleIds, new FileProjectVO());
|
||||||
}
|
}
|
||||||
List<String> strings = map.getOrDefault(querySource, new ArrayList<>());
|
List<String> strings = map.getOrDefault(querySource, new ArrayList<>());
|
||||||
List<FileProjectVO> res = new ArrayList<>();
|
List<FileProjectVO> res = new ArrayList<>();
|
||||||
|
|
|
||||||
|
|
@ -230,12 +230,15 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
|
||||||
Assert.isTrue(EleCommonUtil.isFileNameValid(folderName), NAME_VALID_MSG);
|
Assert.isTrue(EleCommonUtil.isFileNameValid(folderName), NAME_VALID_MSG);
|
||||||
// 检查当前目录下有文件,如果有则不允许添加
|
// 检查当前目录下有文件,如果有则不允许添加
|
||||||
long count = this.baseMapper.selectCount(Wrappers.lambdaQuery(EdFileInfo.class)
|
long count = this.baseMapper.selectCount(Wrappers.lambdaQuery(EdFileInfo.class)
|
||||||
.eq(EdFileInfo::getFileType, EleDataTypeEnum.FILE.code)
|
|
||||||
.eq(EdFileInfo::getDataOwn, dataOwnCode)
|
|
||||||
.eq(EdFileInfo::getParentId, parentId)
|
.eq(EdFileInfo::getParentId, parentId)
|
||||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code));
|
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code));
|
||||||
Assert.isTrue(count == 0, StrFormatter.format("该层级目录下存在文件,不允许再定义层级目录。父目录id {},子集名称 {}", parentId, folderName));
|
|
||||||
Assert.isTrue(commonService.notExistSameFolder(parentId, folderName, dataOwnCode), "子集名已经存在");
|
if (count > 0) {
|
||||||
|
return ElectromagneticResultUtil.fail("-1", StrFormatter.format("该层级目录下存在文件或者文件夹,不允许再定义层级目录。父目录id {},子集名称 {}", parentId, folderName));
|
||||||
|
}
|
||||||
|
if (!commonService.notExistSameFolder(parentId, folderName, dataOwnCode)) {
|
||||||
|
return ElectromagneticResultUtil.fail("-1", StrFormatter.format("子集名称 {} 已经存在,parent id {}", folderName, parentId));
|
||||||
|
}
|
||||||
int id = Integer.parseInt(this.baseMapper.maxPrjId());
|
int id = Integer.parseInt(this.baseMapper.maxPrjId());
|
||||||
String folderId = String.valueOf(id + 1);
|
String folderId = String.valueOf(id + 1);
|
||||||
ElectromagneticResult<?> electromagneticResult = commonService.addFolder(parentId, folderName, true, folderId, null, dataOwnCode);
|
ElectromagneticResult<?> electromagneticResult = commonService.addFolder(parentId, folderName, true, folderId, null, dataOwnCode);
|
||||||
|
|
@ -256,11 +259,11 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
|
||||||
*/
|
*/
|
||||||
Map<Integer, List<String>> map;
|
Map<Integer, List<String>> map;
|
||||||
if (querySource == PrjQuerySource.SYS_PRJ.value) {
|
if (querySource == PrjQuerySource.SYS_PRJ.value) {
|
||||||
map = commonService.querySysPrjTree(querySource, null, new ProjectVO());
|
map = commonService.querySysPrjTree(PrjQuerySource.SYS_PRJ.value, null, new ProjectVO());
|
||||||
} else if (querySource == PrjQuerySource.USER_PRJ.value) {
|
} else if (querySource == PrjQuerySource.USER_PRJ.value) {
|
||||||
map = commonService.queryUserPrjTree(querySource, new ProjectVO());
|
map = commonService.queryUserPrjTree(PrjQuerySource.USER_PRJ.value, new ProjectVO());
|
||||||
} else {
|
} else {
|
||||||
map = commonService.queryRepoPrjTree(querySource, new ProjectVO());
|
map = commonService.queryRepoPrjTree(PrjQuerySource.REPO_PRJ.value, null, new ProjectVO());
|
||||||
}
|
}
|
||||||
List<String> res = map.getOrDefault(querySource, new ArrayList<>());
|
List<String> res = map.getOrDefault(querySource, new ArrayList<>());
|
||||||
List<ProjectVO> projectVOS = new ArrayList<>();
|
List<ProjectVO> projectVOS = new ArrayList<>();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue