|
@@ -46,6 +46,7 @@ import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -383,16 +384,20 @@ public class PaperLibraryServiceImpl extends ServiceImpl<PaperLibraryMapper, Pap
|
|
|
|
|
|
@Transactional
|
|
|
@Override
|
|
|
- public boolean deletePicture(Long paperLibraryId) {
|
|
|
- PaperLibrary paperLibrary = this.getById(paperLibraryId);
|
|
|
- if (paperLibrary == null) {
|
|
|
+ public boolean deletePicture(List<Long> paperLibraryIds) {
|
|
|
+ List<PaperLibrary> paperLibraryList = this.listByIds(paperLibraryIds);
|
|
|
+ if (CollectionUtils.isEmpty(paperLibraryList)) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("图片数据不存在");
|
|
|
}
|
|
|
+
|
|
|
// 删除后,重新统计绑定数量
|
|
|
- if (this.removeById(paperLibraryId) && paperLibrary.getStudentId() != null) {
|
|
|
- examStudentService.updateBindCount(paperLibrary.getStudentId());
|
|
|
- // 清除pdf文件记录
|
|
|
- examStudentService.clearPdfFilePath(paperLibrary.getStudentId());
|
|
|
+ if (this.removeByIds(paperLibraryIds)) {
|
|
|
+ Set<Long> studentIds = paperLibraryList.stream().filter(m->m.getStudentId() != null).map(PaperLibrary::getStudentId).collect(Collectors.toSet());
|
|
|
+ for (Long studentId : studentIds) {
|
|
|
+ examStudentService.updateBindCount(studentId);
|
|
|
+ // 清除pdf文件记录
|
|
|
+ examStudentService.clearPdfFilePath(studentId);
|
|
|
+ }
|
|
|
}
|
|
|
return true;
|
|
|
}
|