From d9c5844688ec85f9fe56be17adc6c4254495d0d2 Mon Sep 17 00:00:00 2001 From: yss <17921@qq.com> Date: Mon, 5 Jun 2023 11:24:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B2=83=E6=96=87=E6=A1=A3-=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E3=80=81=E5=9B=9E=E8=B0=83=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=EF=BC=9A=E6=9F=A5=E8=AF=A2=E6=96=87=E4=BB=B6=20=E5=8F=8A?= =?UTF-8?q?=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wps/service/impl/WpsServiceImpl.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/service/impl/WpsServiceImpl.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/service/impl/WpsServiceImpl.java index 6f0b727..db652ae 100644 --- a/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/service/impl/WpsServiceImpl.java +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/service/impl/WpsServiceImpl.java @@ -119,7 +119,7 @@ public class WpsServiceImpl implements WpsService { re.setAppToken(tokenValue); re.setUrl(String.valueOf(urlMap.get("url"))); re.setUserId(cacheUserService.getCacheUser().getUserId()); - redisTemplate.opsForValue().set("wpsAppToken:"+in.getFileId(),in.getUserToken(),2, TimeUnit.HOURS); + redisTemplate.opsForValue().set("wpsAppToken:"+in.getFileId()+in.getPermission(),in.getUserToken(),2, TimeUnit.HOURS); return re; } @@ -190,11 +190,17 @@ public class WpsServiceImpl implements WpsService { */ @Override public Object saveWpsFile(String token, String userId, String userName, String fileId, String fileName, File file) { - Optional op=attachmentClient.upload(fileId,file); - Map mess=validateWps(token,fileId,op,"save"); + Map mess=validateWps(token,fileId,null,"write"); if(mess!=null){ return mess; } + Optional op=attachmentClient.upload(fileId,file); + if(!op.isPresent() ){ + mess= new HashMap<>(); + mess.put("result","20501007"); + mess.put("msg","文件上传失败"); + return mess; + } WpsFile wpsFile=new WpsFile(); wpsFile.setId(fileId); wpsFile.setName(fileName); @@ -207,22 +213,18 @@ public class WpsServiceImpl implements WpsService { private Map validateWps(String token,String fileId,Optional op,String permission){ Map mess= new HashMap<>(); mess.put("result","20501007"); - if(redisTemplate.opsForValue().get("wpsAppToken:"+fileId)==null){ + if(redisTemplate.opsForValue().get("wpsAppToken:"+fileId+permission)==null){ mess.put("msg","当前链接已失效"); return mess; } - if(!String.valueOf(redisTemplate.opsForValue().get("wpsAppToken:"+fileId)).equals(token)){ + if(!String.valueOf(redisTemplate.opsForValue().get("wpsAppToken:"+fileId+permission)).equals(token)){ mess.put("msg","您无权限访问"); return mess; } - if(!op.isPresent() && !"read".equals(permission)){ + if(op!=null && !op.isPresent() && !"read".equals(permission)){ mess.put("msg","查看的文件不存在"); return mess; } - if(!op.isPresent() && !"save".equals(permission)){ - mess.put("msg","文件上传失败"); - return mess; - } return null; } /**