Commit 65172649 authored by 雍欢's avatar 雍欢

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

parent eaff27b8
......@@ -57,7 +57,6 @@ public class AttachmentApplicationImpl extends BaseApplication implements Attach
attachmentConfiguration.buildDetails();
attachmentConfiguration = (AttachmentConfiguration) this.commonDomainService.saveBaseInfoWithFolderEntity(attachmentConfiguration,
configurationRepository);
return attachmentConfiguration.getId();
}
......@@ -153,10 +152,8 @@ public class AttachmentApplicationImpl extends BaseApplication implements Attach
@Transactional
public void deleteAttachment(String id, Boolean verifyCreator) {
this.checkIdNotBlank(id);
List<String> ids = new ArrayList<String>(1);
List<String> ids = new ArrayList<>(1);
ids.add(id);
deleteAttachmentsByIds(ids, verifyCreator);
}
......@@ -168,6 +165,7 @@ public class AttachmentApplicationImpl extends BaseApplication implements Attach
throw new ApplicationException("不能删除其他人上传的文件。");
}
}
checkAttachmentSecretLevel(attachment);
attachment.setStatus(Attachment.Status.DELETED.getId());
}
......@@ -181,7 +179,6 @@ public class AttachmentApplicationImpl extends BaseApplication implements Attach
List<Attachment> attachments = this.attachmentRepository.findAll(ids);
Assert.notNull(ids.size() == attachments.size(), MessageSourceContext.getMessage(MessageConstants.IDS_EXIST_INVALID_ID, "附件"));
internalDeleteAttachments(attachments, verifyCreator);
}
......@@ -202,12 +199,17 @@ public class AttachmentApplicationImpl extends BaseApplication implements Attach
@Override
public Attachment loadAttachment(String id) {
this.checkIdNotBlank(id);
return this.attachmentRepository.findOne(id);
Attachment attachment = this.attachmentRepository.findOne(id);
checkAttachmentSecretLevel(attachment);
return attachment;
}
@Override
public void updateAttachmentsSequence(Map<String, Integer> params) {
Assert.notEmpty(params, "参数params不能为空。");
params.keySet().stream().map(attachmentRepository::findOne)
.forEach(this::checkAttachmentSecretLevel);
this.commonDomainService.updateSequence(Attachment.class, params);
}
......@@ -220,17 +222,26 @@ public class AttachmentApplicationImpl extends BaseApplication implements Attach
return attachments;
}
AttachmentConfiguration attachmentConfiguration = attachmentConfigurationRepository.findByCode(bizKindId);
if (attachmentConfiguration != null) {
if (Objects.equals(attachmentConfiguration.getEnableSecret(), 1)) {
Person person = orgApplication.loadPerson(ThreadLocalUtil.getOperator().getUserId());
return attachments.stream()
.filter(attachment -> matchingSecretLevel(person, attachment))
.collect(Collectors.toList());
}
if (attachmentConfiguration != null && Objects.equals(attachmentConfiguration.getEnableSecret(), 1)) {
Person person = orgApplication.loadPerson(ThreadLocalUtil.getOperator().getUserId());
return attachments.stream()
.filter(attachment -> matchingSecretLevel(person, attachment))
.collect(Collectors.toList());
}
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
String sql = queryDescriptor.getSqlByName("loadById");
Map<String, Object> map = this.sqlExecutorDao.queryToMap(sql, fileId);
Assert.notEmpty(map, "文件不存在,可能被其他用户删除或修改!");
checkAttachmentSecretLevel(attachmentRepository.findOne(fileId));
BatchSqlUpdateDetail batchInsertDetail = this.getBatchInsertDetail();
String path = null;
Operator op = ThreadLocalUtil.getVariable("operator", Operator.class);
......@@ -355,6 +367,9 @@ public class AttachmentApplicationImpl extends BaseApplication implements Attach
if (objs == null || objs.size() == 0) {
return;
}
objs.stream().map(f -> (String) f.get("id"))
.map(attachmentRepository::findOne)
.forEach(this::checkAttachmentSecretLevel);
BatchSqlUpdateDetail batchInsertDetail = this.getBatchInsertDetail();
String path = null;
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