use of io.choerodon.core.exception.CommonException in project knowledgebase-service by open-hand.
the class WorkSpaceServiceImpl method fillAttribute.
private void fillAttribute(Map<Long, UserDO> userDOMap, Map<String, FileVO> finalLongFileVOMap, WorkSpaceInfoVO workSpaceInfoVO) {
UserDO userDO = userDOMap.get(workSpaceInfoVO.getCreatedBy());
UserDO updateUser = userDOMap.get(workSpaceInfoVO.getLastUpdatedBy());
workSpaceInfoVO.setCreateUser(userDO);
workSpaceInfoVO.setLastUpdatedUser(updateUser);
// 填充属性
switch(WorkSpaceType.valueOf(workSpaceInfoVO.getType().toUpperCase())) {
case FILE:
// 文件计算大小
if (finalLongFileVOMap != null) {
FileVO fileVO = finalLongFileVOMap.get(workSpaceInfoVO.getFileKey());
if (fileVO != null) {
workSpaceInfoVO.setFileSize(fileVO.getFileSize());
}
} else {
workSpaceInfoVO.setFileSize(0L);
}
break;
case DOCUMENT:
case FOLDER:
// 计算子项 这里也只管直接子项
// 查询该工作空间的直接子项
WorkSpaceDTO workSpaceDTO = new WorkSpaceDTO();
workSpaceDTO.setParentId(workSpaceInfoVO.getId());
List<WorkSpaceDTO> spaceDTOS = workSpaceMapper.select(workSpaceDTO);
if (CollectionUtils.isEmpty(spaceDTOS)) {
workSpaceInfoVO.setSubFiles(0L);
} else {
List<WorkSpaceDTO> files = spaceDTOS.stream().filter(spaceDTO1 -> StringUtils.equalsIgnoreCase(spaceDTO1.getType(), WorkSpaceType.FILE.getValue())).collect(Collectors.toList());
List<WorkSpaceDTO> documents = spaceDTOS.stream().filter(spaceDTO1 -> StringUtils.equalsIgnoreCase(spaceDTO1.getType(), WorkSpaceType.DOCUMENT.getValue())).collect(Collectors.toList());
List<WorkSpaceDTO> folders = spaceDTOS.stream().filter(spaceDTO1 -> StringUtils.equalsIgnoreCase(spaceDTO1.getType(), WorkSpaceType.FOLDER.getValue())).collect(Collectors.toList());
workSpaceInfoVO.setSubFiles(Long.valueOf(files.size()));
workSpaceInfoVO.setSubDocuments(Long.valueOf(documents.size()));
workSpaceInfoVO.setSubFolders(Long.valueOf(folders.size()));
}
break;
default:
throw new CommonException("Unsupported knowledge space type");
}
}
use of io.choerodon.core.exception.CommonException in project knowledgebase-service by open-hand.
the class WorkSpaceServiceImpl method queryWorkSpaceInfo.
@Override
public WorkSpaceInfoVO queryWorkSpaceInfo(Long organizationId, Long projectId, Long workSpaceId, String searchStr) {
WorkSpaceDTO workSpaceDTO = this.baseQueryByIdWithOrg(organizationId, projectId, workSpaceId);
// 根据WorkSpace的类型返回相应的值
switch(WorkSpaceType.valueOf(workSpaceDTO.getType().toUpperCase())) {
case FOLDER:
// todo 前端点击文件夹的时候应该不会发送请求???? 就展开下面的结构就行了???
// 查询文件夹下子项
WorkSpaceInfoVO workSpaceInfoVO = new WorkSpaceInfoVO();
workSpaceInfoVO.setWorkSpace(buildTreeVO(workSpaceDTO, Collections.emptyList()));
workSpaceInfoVO.setDelete(workSpaceDTO.getDelete());
return workSpaceInfoVO;
case DOCUMENT:
return getWorkSpaceInfoVO(organizationId, projectId, workSpaceId, searchStr, workSpaceDTO);
case FILE:
WorkSpaceInfoVO file = new WorkSpaceInfoVO();
FileVO fileDTOByFileKey = expandFileClient.getFileDTOByFileKey(organizationId, workSpaceDTO.getFileKey());
file.setFileType(CommonUtil.getFileType(fileDTOByFileKey.getFileKey()));
file.setTitle(CommonUtil.getFileName(fileDTOByFileKey.getFileKey()));
file.setUrl(fileDTOByFileKey.getFileUrl());
file.setKey(CommonUtil.getFileId(fileDTOByFileKey.getFileKey()));
BeanUtils.copyProperties(file, workSpaceDTO);
file.setWorkSpace(buildTreeVO(workSpaceDTO, Collections.emptyList()));
file.setDelete(workSpaceDTO.getDelete());
return file;
default:
throw new CommonException("Unsupported knowledge space type");
}
}
use of io.choerodon.core.exception.CommonException in project knowledgebase-service by open-hand.
the class WorkSpaceServiceImpl method removeWorkSpaceAndPage.
@Override
public void removeWorkSpaceAndPage(Long organizationId, Long projectId, Long workspaceId, Boolean isAdmin) {
WorkSpaceDTO workSpaceDTO = this.baseQueryById(organizationId, projectId, workspaceId);
if (StringUtils.equalsIgnoreCase(workSpaceDTO.getType(), WorkSpaceType.FILE.getValue()) || StringUtils.equalsIgnoreCase(workSpaceDTO.getType(), WorkSpaceType.FOLDER.getValue())) {
workSpaceDTO.setDelete(true);
this.baseUpdate(workSpaceDTO);
} else if (StringUtils.equalsIgnoreCase(workSpaceDTO.getType(), WorkSpaceType.DOCUMENT.getValue())) {
WorkSpacePageDTO workSpacePageDTO = workSpacePageService.selectByWorkSpaceId(workspaceId);
if (Boolean.FALSE.equals(isAdmin)) {
Long currentUserId = DetailsHelper.getUserDetails().getUserId();
PageDTO pageDTO = pageRepository.baseQueryById(organizationId, projectId, workSpacePageDTO.getPageId());
if (!workSpacePageDTO.getCreatedBy().equals(currentUserId) && !pageDTO.getCreatedBy().equals(currentUserId)) {
throw new CommonException(ERROR_WORKSPACE_ILLEGAL);
}
}
workSpaceDTO.setDelete(true);
this.baseUpdate(workSpaceDTO);
// 删除agile关联的workspace
agileFeignOperator.deleteByworkSpaceId(projectId == null ? organizationId : projectId, workspaceId);
} else {
throw new CommonException("Unsupported knowledge space type");
}
}
use of io.choerodon.core.exception.CommonException in project knowledgebase-service by open-hand.
the class DataFixServiceImpl method buildInitData.
private List<InitKnowledgeBaseTemplateVO> buildInitData() {
List<InitKnowledgeBaseTemplateVO> list = new ArrayList<>();
try {
String template = HtmlUtil.loadHtmlTemplate("/htmlTemplate/InitTemplate.html");
String[] split = template.split("<div/>");
InitKnowledgeBaseTemplateVO knowledgeBaseTemplateA = new InitKnowledgeBaseTemplateVO();
knowledgeBaseTemplateA.setName("会议记录");
List<PageCreateVO> pageCreateVOSA = new ArrayList<>();
String meetingMinutes = "记录重大会议的参会情况狂,以及会议内容、会议讨论输出的内容。";
String productPlan = "产品规划会产出当前迭代的完成任务项,以及下个迭代预计进行的任务项。";
String reviewConference = "敏捷过程中的一个重要会议,总结陈述迭代进行的优缺点,以及对应的整改方案。";
pageCreateVOSA.add(new PageCreateVO(0L, "会议纪要", meetingMinutes, split[2], WorkSpaceType.DOCUMENT.getValue()));
pageCreateVOSA.add(new PageCreateVO(0L, "产品规划会", productPlan, split[4], WorkSpaceType.DOCUMENT.getValue()));
pageCreateVOSA.add(new PageCreateVO(0L, "敏捷迭代回顾会议", reviewConference, split[5], WorkSpaceType.DOCUMENT.getValue()));
knowledgeBaseTemplateA.setTemplatePage(pageCreateVOSA);
list.add(knowledgeBaseTemplateA);
InitKnowledgeBaseTemplateVO knowledgeBaseTemplateB = new InitKnowledgeBaseTemplateVO();
knowledgeBaseTemplateB.setName("产品研发");
List<PageCreateVO> pageCreateVOSB = new ArrayList<>();
String prdDescription = "PRD可以将产品设计思路清晰的展现给团队人员,便于他们快速理解产品,同时可以记录需求的变更历史,以便于快速了解功能的变化。";
String technicalDocuments = "产品开发过程中所用框架的说明,接口设计说明,帮助前后端开发人员快速了解技术相关的设计。";
String competitiveAnalysis = "包含对市场的分析,竞品情况的了解,分析出自己产品的优劣势,产出分析结果和应对建议。";
pageCreateVOSB.add(new PageCreateVO(0L, "技术文档", technicalDocuments, split[1], WorkSpaceType.DOCUMENT.getValue()));
pageCreateVOSB.add(new PageCreateVO(0L, "竞品分析", competitiveAnalysis, split[3], WorkSpaceType.DOCUMENT.getValue()));
pageCreateVOSB.add(new PageCreateVO(0L, "产品需求文档PRD", prdDescription, split[0], WorkSpaceType.DOCUMENT.getValue()));
knowledgeBaseTemplateB.setTemplatePage(pageCreateVOSB);
list.add(knowledgeBaseTemplateB);
InitKnowledgeBaseTemplateVO knowledgeBaseTemplateC = new InitKnowledgeBaseTemplateVO();
knowledgeBaseTemplateC.setName("产品测试");
List<PageCreateVO> pageCreateVOSC = new ArrayList<>();
String testPlan = "根据产品质量等级结合产品研发现状,确定测试范围、确定测试需求、制定测试策略、确定测试方法、确定测试资源、制定测试风险应对方案、评估测试交付件,预估迭代功能测试和SIT/UAT测试的工作量,进行人员和进度的安排。";
pageCreateVOSC.add(new PageCreateVO(0L, "产品测试计划", testPlan, split[6], WorkSpaceType.DOCUMENT.getValue()));
knowledgeBaseTemplateC.setTemplatePage(pageCreateVOSC);
list.add(knowledgeBaseTemplateC);
} catch (IOException e) {
throw new CommonException(e);
}
return list;
}
use of io.choerodon.core.exception.CommonException in project knowledgebase-service by open-hand.
the class PageCommentServiceImpl method delete.
@Override
public void delete(Long organizationId, Long projectId, Long id, Boolean isAdmin) {
PageCommentDTO comment = pageCommentRepository.baseQueryById(id);
pageRepository.checkById(organizationId, projectId, comment.getPageId());
if (Boolean.FALSE.equals(isAdmin)) {
Long currentUserId = DetailsHelper.getUserDetails().getUserId();
if (!comment.getCreatedBy().equals(currentUserId)) {
throw new CommonException(ERROR_ILLEGAL);
}
}
pageCommentRepository.baseDelete(id);
}
Aggregations