Browse Source

加入小程序签名key修改

wangliang 1 year ago
parent
commit
20e87a295f

+ 9 - 3
sop-api/src/main/java/com/qmth/sop/server/api/SysController.java

@@ -222,9 +222,15 @@ public class SysController {
     @RequestMapping(value = "/file/preview/app", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = EditResult.class)})
     public Result filePreview(@ApiParam(value = "小程序签名key", required = true) @RequestParam String key) throws Exception {
-        BasicAttachment basicAttachment = basicAttachmentService.filePreviewApp(key);
-        Optional.ofNullable(basicAttachment).orElseThrow(() -> ExceptionResultEnum.ATTACHMENT_NO_DATA.exception());
-        return ResultUtil.ok(new EditResult(basicAttachment.getId(), basicAttachmentService.filePreview(basicAttachment.getPath())), key);
+        List<BasicAttachment> basicAttachmentList = basicAttachmentService.filePreviewApp(key);
+        if (CollectionUtils.isEmpty(basicAttachmentList)) {
+            throw ExceptionResultEnum.ATTACHMENT_NO_DATA.exception();
+        }
+        List<EditResult> editResultList = new ArrayList<>(basicAttachmentList.size());
+        for (BasicAttachment b : basicAttachmentList) {
+            editResultList.add(new EditResult(b.getId(), basicAttachmentService.filePreview(b.getPath()), key));
+        }
+        return ResultUtil.ok(editResultList);
     }
 
     @ApiOperation(value = "文件预览接口")

+ 2 - 1
sop-business/src/main/java/com/qmth/sop/business/service/BasicAttachmentService.java

@@ -8,6 +8,7 @@ import org.springframework.web.multipart.MultipartFile;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.List;
 
 /**
  * <p>
@@ -79,7 +80,7 @@ public interface BasicAttachmentService extends IService<BasicAttachment> {
      * @param key
      * @return
      */
-    public BasicAttachment filePreviewApp(String key) throws Exception;
+    public List<BasicAttachment> filePreviewApp(String key) throws Exception;
 
     /**
      * 文件预览

+ 2 - 2
sop-business/src/main/java/com/qmth/sop/business/service/impl/BasicAttachmentServiceImpl.java

@@ -241,8 +241,8 @@ public class BasicAttachmentServiceImpl extends ServiceImpl<BasicAttachmentMappe
      * @throws Exception
      */
     @Override
-    public BasicAttachment filePreviewApp(String key) throws Exception {
-        return this.getOne(new QueryWrapper<BasicAttachment>().lambda().eq(BasicAttachment::getRemark, key));
+    public List<BasicAttachment> filePreviewApp(String key) throws Exception {
+        return this.list(new QueryWrapper<BasicAttachment>().lambda().eq(BasicAttachment::getRemark, key).last(" limit 10"));
     }
 
     /**