|
@@ -18,6 +18,7 @@ import com.redxun.common.service.impl.SuperServiceImpl;
|
|
|
import com.redxun.common.tool.IdGenerator;
|
|
|
import com.redxun.common.tool.StringUtils;
|
|
|
import com.redxun.common.utils.ContextUtil;
|
|
|
+import com.redxun.dto.user.OsGroupDto;
|
|
|
import com.redxun.dto.user.OsUserDto;
|
|
|
import com.redxun.knowledge.album.entity.dao.AlbumCatalogueKnowledge;
|
|
|
import com.redxun.knowledge.album.mapper.AlbumCatalogueKnowledgeMapper;
|
|
@@ -160,6 +161,7 @@ public class KnowledgeServiceImpl extends SuperServiceImpl<KnowledgeMapper, Know
|
|
|
knowledge.setCreateTime(new Date());
|
|
|
knowledge.setUpdateBy(users.getUserId());
|
|
|
knowledge.setUpdateTime(new Date());
|
|
|
+ knowledge.setAllowDownload(knowledgeDto.getAllowDownload());
|
|
|
if (!ObjectUtil.valueAllNull(knowledgeDto.getOrganizationIds())){
|
|
|
String organizationId = JSON.toJSON(knowledgeDto.getOrganizationIds()).toString();
|
|
|
knowledge.setOrganizationId(organizationId);
|
|
@@ -253,6 +255,25 @@ public class KnowledgeServiceImpl extends SuperServiceImpl<KnowledgeMapper, Know
|
|
|
if (!StringUtils.isEmpty(knowledge.getCategoryId())){
|
|
|
knowledgeVo.setKnowledgeCategoryAdminVo(knowledgeCategoryService.findAllParentByCategoryId(knowledge.getCategoryId()));
|
|
|
}
|
|
|
+ //指定了附件下载权限会判断
|
|
|
+ if (StringUtils.isNotEmpty(knowledge.getAllowDownload())){
|
|
|
+ //附件下载权限
|
|
|
+ knowledgeVo.setIsAllowDownload(isAllowDownload(knowledge.getAllowDownload()));
|
|
|
+ //附件可下载人员或部门字符串复制
|
|
|
+ List<String> allowDownloadList = Arrays.asList(knowledge.getAllowDownload().split(","));
|
|
|
+ String allowDownloadNameResult = allowDownloadList.parallelStream().map(h -> {
|
|
|
+ String allowDownloadName = null;
|
|
|
+ OsUserDto osUserDto = userService.queryOsUserDto(h);
|
|
|
+ if (osUserDto != null) {
|
|
|
+ allowDownloadName = osUserDto.getFullName();
|
|
|
+ } else {
|
|
|
+ OsGroupDto osGroupDto = userService.findDeptByDeptId(h);
|
|
|
+ allowDownloadName = osGroupDto.getName();
|
|
|
+ }
|
|
|
+ return allowDownloadName;
|
|
|
+ }).collect(Collectors.joining(","));
|
|
|
+ knowledgeVo.setAllowDownload(allowDownloadNameResult);
|
|
|
+ }
|
|
|
if (knowledge.getIsDraft() == 0){
|
|
|
return knowledgeVo;
|
|
|
}
|
|
@@ -374,6 +395,26 @@ public class KnowledgeServiceImpl extends SuperServiceImpl<KnowledgeMapper, Know
|
|
|
} else {
|
|
|
e.setIsWithdraw(1);
|
|
|
}
|
|
|
+ //指定了附件下载权限会判断
|
|
|
+ if (StringUtils.isNotEmpty(e.getAllowDownload())){
|
|
|
+ //附件下载权限
|
|
|
+ e.setIsAllowDownload(isAllowDownload(e.getAllowDownload()));
|
|
|
+ //附件可下载人员或部门字符串赋值
|
|
|
+ List<String> allowDownloadList = Arrays.asList(e.getAllowDownload().split(","));
|
|
|
+ String allowDownloadNameResult = allowDownloadList.parallelStream().map(h -> {
|
|
|
+ String allowDownloadName = null;
|
|
|
+ OsUserDto osUserDto = userService.queryOsUserDto(h);
|
|
|
+ if (osUserDto != null) {
|
|
|
+ allowDownloadName = osUserDto.getFullName();
|
|
|
+ } else {
|
|
|
+ OsGroupDto osGroupDto = userService.findDeptByDeptId(h);
|
|
|
+ allowDownloadName = osGroupDto.getName();
|
|
|
+ }
|
|
|
+ return allowDownloadName;
|
|
|
+ }).collect(Collectors.joining(","));
|
|
|
+ e.setAllowDownload(allowDownloadNameResult);
|
|
|
+ }
|
|
|
+
|
|
|
});
|
|
|
return page;
|
|
|
}
|
|
@@ -975,4 +1016,28 @@ public class KnowledgeServiceImpl extends SuperServiceImpl<KnowledgeMapper, Know
|
|
|
knowledgeMapper.updateById(knowledge);
|
|
|
knowledgeApproveMapper.deleteByKnowledgeId(knowledgeId);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 判断是否有下载附件权限(有权限 返回0; 没权限 返回1)
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Integer isAllowDownload(String allowDownload){
|
|
|
+ String userId = userService.queryLoginUser();
|
|
|
+ List<String> deptAuthority = knowledgeApproveMapper.deptAuthority(userId); //部门权限字符串
|
|
|
+ boolean flag = false;
|
|
|
+ for (int i = 0; i < deptAuthority.size(); i++) {
|
|
|
+ if (deptAuthority.get(i).contains(allowDownload)) {
|
|
|
+ flag = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<String> approverIdList = Arrays.asList(allowDownload.split(","));
|
|
|
+ // 如果有权限
|
|
|
+ if (!approverIdList.contains(userId) && !flag) {
|
|
|
+ // 不是该部门的人,不能查看
|
|
|
+ return 1;
|
|
|
+ } else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|