Commit 65172649 authored by 雍欢's avatar 雍欢

改造附件下载逻辑、删除逻辑、复制逻辑、修改排序号逻辑

parent eaff27b8
...@@ -57,7 +57,6 @@ public class AttachmentApplicationImpl extends BaseApplication implements Attach ...@@ -57,7 +57,6 @@ public class AttachmentApplicationImpl extends BaseApplication implements Attach
attachmentConfiguration.buildDetails(); attachmentConfiguration.buildDetails();
attachmentConfiguration = (AttachmentConfiguration) this.commonDomainService.saveBaseInfoWithFolderEntity(attachmentConfiguration, attachmentConfiguration = (AttachmentConfiguration) this.commonDomainService.saveBaseInfoWithFolderEntity(attachmentConfiguration,
configurationRepository); configurationRepository);
return attachmentConfiguration.getId(); return attachmentConfiguration.getId();
} }
...@@ -153,10 +152,8 @@ public class AttachmentApplicationImpl extends BaseApplication implements Attach ...@@ -153,10 +152,8 @@ public class AttachmentApplicationImpl extends BaseApplication implements Attach
@Transactional @Transactional
public void deleteAttachment(String id, Boolean verifyCreator) { public void deleteAttachment(String id, Boolean verifyCreator) {
this.checkIdNotBlank(id); this.checkIdNotBlank(id);
List<String> ids = new ArrayList<>(1);
List<String> ids = new ArrayList<String>(1);
ids.add(id); ids.add(id);
deleteAttachmentsByIds(ids, verifyCreator); deleteAttachmentsByIds(ids, verifyCreator);
} }
...@@ -168,6 +165,7 @@ public class AttachmentApplicationImpl extends BaseApplication implements Attach ...@@ -168,6 +165,7 @@ public class AttachmentApplicationImpl extends BaseApplication implements Attach
throw new ApplicationException("不能删除其他人上传的文件。"); throw new ApplicationException("不能删除其他人上传的文件。");
} }
} }
checkAttachmentSecretLevel(attachment);
attachment.setStatus(Attachment.Status.DELETED.getId()); attachment.setStatus(Attachment.Status.DELETED.getId());
} }
...@@ -181,7 +179,6 @@ public class AttachmentApplicationImpl extends BaseApplication implements Attach ...@@ -181,7 +179,6 @@ public class AttachmentApplicationImpl extends BaseApplication implements Attach
List<Attachment> attachments = this.attachmentRepository.findAll(ids); List<Attachment> attachments = this.attachmentRepository.findAll(ids);
Assert.notNull(ids.size() == attachments.size(), MessageSourceContext.getMessage(MessageConstants.IDS_EXIST_INVALID_ID, "附件")); Assert.notNull(ids.size() == attachments.size(), MessageSourceContext.getMessage(MessageConstants.IDS_EXIST_INVALID_ID, "附件"));
internalDeleteAttachments(attachments, verifyCreator); internalDeleteAttachments(attachments, verifyCreator);
} }
...@@ -202,12 +199,17 @@ public class AttachmentApplicationImpl extends BaseApplication implements Attach ...@@ -202,12 +199,17 @@ public class AttachmentApplicationImpl extends BaseApplication implements Attach
@Override @Override
public Attachment loadAttachment(String id) { public Attachment loadAttachment(String id) {
this.checkIdNotBlank(id); this.checkIdNotBlank(id);
return this.attachmentRepository.findOne(id); Attachment attachment = this.attachmentRepository.findOne(id);
checkAttachmentSecretLevel(attachment);
return attachment;
} }
@Override @Override
public void updateAttachmentsSequence(Map<String, Integer> params) { public void updateAttachmentsSequence(Map<String, Integer> params) {
Assert.notEmpty(params, "参数params不能为空。"); Assert.notEmpty(params, "参数params不能为空。");
params.keySet().stream().map(attachmentRepository::findOne)
.forEach(this::checkAttachmentSecretLevel);
this.commonDomainService.updateSequence(Attachment.class, params); this.commonDomainService.updateSequence(Attachment.class, params);
} }
...@@ -220,17 +222,26 @@ public class AttachmentApplicationImpl extends BaseApplication implements Attach ...@@ -220,17 +222,26 @@ public class AttachmentApplicationImpl extends BaseApplication implements Attach
return attachments; return attachments;
} }
AttachmentConfiguration attachmentConfiguration = attachmentConfigurationRepository.findByCode(bizKindId); AttachmentConfiguration attachmentConfiguration = attachmentConfigurationRepository.findByCode(bizKindId);
if (attachmentConfiguration != null) { if (attachmentConfiguration != null && Objects.equals(attachmentConfiguration.getEnableSecret(), 1)) {
if (Objects.equals(attachmentConfiguration.getEnableSecret(), 1)) {
Person person = orgApplication.loadPerson(ThreadLocalUtil.getOperator().getUserId()); Person person = orgApplication.loadPerson(ThreadLocalUtil.getOperator().getUserId());
return attachments.stream() return attachments.stream()
.filter(attachment -> matchingSecretLevel(person, attachment)) .filter(attachment -> matchingSecretLevel(person, attachment))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
}
return attachments; return attachments;
} }
private void checkAttachmentSecretLevel(Attachment attachment) {
if (attachment == null) {
return;
}
AttachmentConfiguration attachmentConfiguration = attachmentConfigurationRepository.findByCode(attachment.getBizKindId());
if (attachmentConfiguration != null && Objects.equals(attachmentConfiguration.getEnableSecret(), 1)) {
Person person = orgApplication.loadPerson(ThreadLocalUtil.getOperator().getUserId());
Assert.isTrue(matchingSecretLevel(person, attachment), String.format("人员密级[%s]与附件密级[%s]不匹配", person.getPersonSecurityGrade(), attachment.getSecretLevel()));
}
}
/** /**
* 判断人员密级是否与附件密级匹配 * 判断人员密级是否与附件密级匹配
*/ */
...@@ -314,6 +325,7 @@ public class AttachmentApplicationImpl extends BaseApplication implements Attach ...@@ -314,6 +325,7 @@ public class AttachmentApplicationImpl extends BaseApplication implements Attach
String sql = queryDescriptor.getSqlByName("loadById"); String sql = queryDescriptor.getSqlByName("loadById");
Map<String, Object> map = this.sqlExecutorDao.queryToMap(sql, fileId); Map<String, Object> map = this.sqlExecutorDao.queryToMap(sql, fileId);
Assert.notEmpty(map, "文件不存在,可能被其他用户删除或修改!"); Assert.notEmpty(map, "文件不存在,可能被其他用户删除或修改!");
checkAttachmentSecretLevel(attachmentRepository.findOne(fileId));
BatchSqlUpdateDetail batchInsertDetail = this.getBatchInsertDetail(); BatchSqlUpdateDetail batchInsertDetail = this.getBatchInsertDetail();
String path = null; String path = null;
Operator op = ThreadLocalUtil.getVariable("operator", Operator.class); Operator op = ThreadLocalUtil.getVariable("operator", Operator.class);
...@@ -355,6 +367,9 @@ public class AttachmentApplicationImpl extends BaseApplication implements Attach ...@@ -355,6 +367,9 @@ public class AttachmentApplicationImpl extends BaseApplication implements Attach
if (objs == null || objs.size() == 0) { if (objs == null || objs.size() == 0) {
return; return;
} }
objs.stream().map(f -> (String) f.get("id"))
.map(attachmentRepository::findOne)
.forEach(this::checkAttachmentSecretLevel);
BatchSqlUpdateDetail batchInsertDetail = this.getBatchInsertDetail(); BatchSqlUpdateDetail batchInsertDetail = this.getBatchInsertDetail();
String path = null; String path = null;
Operator op = ThreadLocalUtil.getVariable("operator", Operator.class); Operator op = ThreadLocalUtil.getVariable("operator", Operator.class);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment