leo.xie лет назад: 3
Родитель
Сommit
0e2c2fe5fe
2 измененных файлов с 36 добавлено и 25 удалено
  1. 1 1
      docker-prod.yaml
  2. 35 24
      src/main/java/com/ads/business/service/impl/DocServiceImpl.java

+ 1 - 1
docker-prod.yaml

@@ -14,7 +14,7 @@ services:
       - "8015:8073"
     networks:
       root_prenet:
-        ipv4_address: 172.29.0.5
+        ipv4_address: 172.29.0.3
 
 networks:
   root_prenet:

+ 35 - 24
src/main/java/com/ads/business/service/impl/DocServiceImpl.java

@@ -245,35 +245,29 @@ public class DocServiceImpl extends ServiceImpl<DocDao, Doc> implements DocServi
         return outData;
     }
 
-    @Override
-    public JsonResult pdfDetail(HttpServletRequest request, Long docId, String userNo) {
-        GetLoginOutData userInfo = OnlineUserUtils.get();
-        if (null == userInfo) {
-            return JsonResult.fail("您没有登录");
-        }
+    private Doc auth(Long docId,GetLoginOutData userInfo){
+
         if (StringUtils.isEmpty(userInfo.getMobile())) {
-            return JsonResult.fail(1000, "请重新登录");
+            throw new BusinessException("请重新登录");
         }
-        //水印 姓名+手机号后四位
-        String watermark = userInfo.getName() + userInfo.getMobile().substring(userInfo.getMobile().length() - 5);
         Doc doc = this.baseMapper.selectById(docId);
         if (null == doc) {
             throw new BusinessException("当前文件信息不存在!");
         }
         if (doc.getStatus() == 0) {
-            return JsonResult.fail(1000, "当前文件已禁用,请启用后查看!");
+            throw new BusinessException("当前文件已禁用,请启用后查看!");
         }
         DocType docType = docTypeService.getById(doc.getTypeId());
         if (ObjectUtil.isEmpty(docType)) {
-            return JsonResult.fail("当前文件说在分类信息不存在");
+            throw new BusinessException("当前文件说在分类信息不存在");
         }
         if (docType.getStatus() == 0) {
-            return JsonResult.fail(1000, "当前文件所在分类已禁用,请启用后查看!");
+            throw new BusinessException("当前文件所在分类已禁用,请启用后查看!");
         }
         //userInfo.setMobile("18896995753");
         //userInfo.setMobile("15261532462");
         if (StringUtils.isEmpty(userInfo.getMobile())) {
-            return JsonResult.fail(1000, "请退出重新登录钉钉");
+            throw new BusinessException("请退出重新登录钉钉");
         }
         log.info("获取文件详情信息--校验会话权限");
         List<DocTypeConversationRel> typeList = docTypeConversationRelDao.getListByMobile(docType.getTypeId(),userInfo.getMobile());
@@ -282,11 +276,11 @@ public class DocServiceImpl extends ServiceImpl<DocDao, Doc> implements DocServi
         //手机号不为空,群组为空
         if (CollectionUtil.isNotEmpty(typeRoleMobiles) && CollectionUtil.isEmpty(typeList)) {
             if (!typeRoleMobiles.contains(userInfo.getMobile())) {
-                return JsonResult.fail(1000, "您没有当前文件的查看权限");
+                throw new BusinessException("您没有当前文件的查看权限");
             }
             Boolean res = checkAuthDetail(userInfo, doc);
             if (res) {
-                return JsonResult.fail(1000, "您没有当前文件的查看权限");
+                throw new BusinessException("您没有当前文件的查看权限");
             }
         }
         //手机号不为空,群组不为空
@@ -294,47 +288,63 @@ public class DocServiceImpl extends ServiceImpl<DocDao, Doc> implements DocServi
             List<String> conversationMobiles = docTypeConversationRelService.getListByTypeId(docType.getTypeId());
             conversationMobiles.addAll(typeRoleMobiles);
             if (!conversationMobiles.contains(OnlineUserUtils.get().getMobile())) {
-                return JsonResult.fail(1000, "您没有当前文件的查看权限");
+                throw new BusinessException("您没有当前文件的查看权限");
             }
             Boolean res = checkAuthDetail(userInfo, doc);
             if (res) {
-                return JsonResult.fail(1000, "您没有当前文件的查看权限");
+                throw new BusinessException("您没有当前文件的查看权限");
             }
         }
         //手机号为空,群组不为空
         if (CollectionUtil.isEmpty(typeRoleMobiles) && CollectionUtil.isNotEmpty(typeList)) {
             List<String> conversationMobiles = docTypeConversationRelService.getListByTypeId(docType.getTypeId());
             if (!conversationMobiles.contains(OnlineUserUtils.get().getMobile())) {
-                return JsonResult.fail(1000, "您没有当前文件的查看权限");
+                throw new BusinessException("您没有当前文件的查看权限");
             }
             Boolean res = checkAuthDetail(userInfo, doc);
             if (res) {
-                return JsonResult.fail(1000, "您没有当前文件的查看权限");
+                throw new BusinessException("您没有当前文件的查看权限");
             }
         }
         //手机号为空,群组为空
         if (CollectionUtil.isEmpty(typeRoleMobiles) && CollectionUtil.isEmpty(typeList)) {
             Boolean res = checkAuthDetail(userInfo, doc);
             if (res) {
-                return JsonResult.fail(1000, "您没有当前文件的查看权限");
+                throw new BusinessException("您没有当前文件的查看权限");
             }
         }
         log.info("校验权限结束!");
 
+        return doc;
+    }
+
+    @Override
+    public JsonResult pdfDetail(HttpServletRequest request, Long docId, String userNo) {
+
+        GetLoginOutData userInfo = OnlineUserUtils.get();
+        if (null == userInfo) {
+            return JsonResult.fail("您没有登录");
+        }
+
+        Doc doc = auth(docId,userInfo);
+
+        //水印 姓名+手机号后四位
+        String watermark = "沪上阿姨SOP";
+
         String fileName = doc.getName();
         String docUrl = doc.getDocUrl();
         String domain = pictureConfig.getServerPath();
         String path = domain + request.getContextPath() + "/";
-        String filePath = pictureConfig.getServerBasePath() +"/"+ pictureConfig.getUploadPath() + "/" + userNo + "/" + docId + fileName + ".pdf";
-        String imageFilePath = pictureConfig.getServerBasePath() +"/"+ pictureConfig.getUploadPath() + "/" + userNo + "/" + docId + fileName + File.separator;
-        String createPath = pictureConfig.getBasePath() + "/" + pictureConfig.getUploadPath() + "/" + userNo + "/" + docId + fileName + ".pdf";
+        String filePath = pictureConfig.getServerBasePath() +"/"+ pictureConfig.getUploadPath() + "/"  + docId +"/"+ fileName + ".pdf";
+        String imageFilePath = pictureConfig.getServerBasePath() +"/"+ pictureConfig.getUploadPath() + "/" +  docId +"/"+ fileName + File.separator;
+        String createPath = pictureConfig.getBasePath() + "/" + pictureConfig.getUploadPath() + "/" + docId + fileName +"/"+ ".pdf";
         File fromFile = new File(createPath);
         //判断目标文件所在的目录是否存在
         if (!fromFile.getParentFile().exists()) {
             //如果目标文件所在的目录不存在,则创建父目录
             fromFile.getParentFile().mkdirs();
         }
-        String pictureFilePath = docUrl.replace(domain+"file",pictureConfig.getBasePath());
+        String pictureFilePath = docUrl.replace(domain+pictureConfig.getServerBasePath(),pictureConfig.getBasePath());
         if(!new File(pictureFilePath).exists()){
             throw new BusinessException("当前图片不存在"+pictureFilePath+"&"+domain+"&"+pictureConfig.getBasePath());
         }
@@ -362,6 +372,7 @@ public class DocServiceImpl extends ServiceImpl<DocDao, Doc> implements DocServi
                 }
             }
         }
+
         PdfDetailResponse rs = new PdfDetailResponse();
         rs.setPath(path + filePath);
         rs.setFileName(fileName);