浏览代码

1.0.5 update

xiaofei 10 月之前
父节点
当前提交
3c51d1b81e

+ 1 - 1
paper-library-business/src/main/java/com/qmth/paper/library/business/service/PaperLibraryService.java

@@ -44,7 +44,7 @@ public interface PaperLibraryService extends IService<PaperLibrary> {
 
     List<String> listBatchNo(Long studentId);
 
-    boolean deletePicture(Long paperLibraryId);
+    boolean deletePicture(List<Long> paperLibraryIds);
 
     boolean rotatePictureUpload(Long paperLibraryId, boolean isFront, Integer rotate);
 

+ 12 - 7
paper-library-business/src/main/java/com/qmth/paper/library/business/service/impl/PaperLibraryServiceImpl.java

@@ -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;
     }

+ 3 - 2
paper-library/src/main/java/com/qmth/paper/library/api/DocManageController.java

@@ -26,6 +26,7 @@ import org.springframework.web.bind.annotation.RestController;
 import javax.annotation.Resource;
 import javax.validation.constraints.Max;
 import javax.validation.constraints.Min;
+import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 
@@ -150,8 +151,8 @@ public class DocManageController {
     @ApiOperation(value = "删除图片")
     @PostMapping("/picture/delete")
     @ApiResponses({@ApiResponse(code = 200, message = "查询成功", response = Result.class)})
-    public Result deletePicture(@ApiParam(value = "图片ID", required = true) @RequestParam Long paperLibraryId) {
-        return ResultUtil.ok(paperLibraryService.deletePicture(paperLibraryId));
+    public Result deletePicture(@ApiParam(value = "图片ID", required = true) @RequestParam List<Long> paperLibraryIds) {
+        return ResultUtil.ok(paperLibraryService.deletePicture(paperLibraryIds));
     }
 
     @ApiOperation(value = "旋转保存图片")