diff --git a/interface/share.json b/interface/share.json index cd58d4c1..6329f33b 100644 --- a/interface/share.json +++ b/interface/share.json @@ -21,7 +21,7 @@ } }, { - "url": "http://81.69.8.95:8080/share/usershare/update", + "url": "http:/43.135.22.107:8080/share/usershare/update", "method": "POST", "body": { "id":"分享id,如111", @@ -89,7 +89,7 @@ } }, { - "url": "http://81.69.8.95:8080/share/usershare/{memberId}?pageNo=1&pageSize=10", + "url": "http://81.69.8.95:8080/share/usershare/byUser?memberId=1?pageNo=1&pageSize=10", "method": "GET", "response": { diff --git a/src/main/java/com/dl/officialsite/login/filter/LoginFilter.java b/src/main/java/com/dl/officialsite/login/filter/LoginFilter.java index fd7f57c7..3f19d94c 100644 --- a/src/main/java/com/dl/officialsite/login/filter/LoginFilter.java +++ b/src/main/java/com/dl/officialsite/login/filter/LoginFilter.java @@ -45,6 +45,10 @@ public class LoginFilter extends OncePerRequestFilter { add("/login/logout"); add("/share/usershare/all"); add("/share/usershare/queryByShareId"); + add("/share/usershare/byUser"); + add("/share/usershare/create"); + add("/share/usershare/update"); + add("/share/usershare/delete"); }} ; @Override diff --git a/src/main/java/com/dl/officialsite/sharing/controller/UserSharingController.java b/src/main/java/com/dl/officialsite/sharing/controller/UserSharingController.java index a3614973..d4dc2d57 100644 --- a/src/main/java/com/dl/officialsite/sharing/controller/UserSharingController.java +++ b/src/main/java/com/dl/officialsite/sharing/controller/UserSharingController.java @@ -47,8 +47,8 @@ public BaseResponse updateSharing(UpdateSharingReq req){ * 删除分享 */ @PostMapping("delete") - public BaseResponse deleteSharing(@RequestParam("shareId") long shareId){ - this.userSharingService.deleteSharing(shareId); + public BaseResponse deleteSharing(@RequestParam("shareId") long shareId, @RequestParam("memberId") long memberId){ + this.userSharingService.deleteSharing(shareId, memberId); return BaseResponse.success(); } @@ -76,8 +76,8 @@ public BaseResponse querySharing(@RequestParam("shareId") long shareI /** * 查看用户的分享 */ - @GetMapping("{memberId}") - public BaseResponse loadSharingByUser(@PathVariable("memberId") long memberId, + @GetMapping("byUser") + public BaseResponse loadSharingByUser(@RequestParam("memberId") long memberId, @RequestParam(value = "pageNo",defaultValue = "1") int pageNo, @RequestParam(value = "pageSize",defaultValue = "20") int pageSize) { return BaseResponse.successWithData(this.userSharingService.loadSharingByUser(memberId, pageNo, pageSize)); diff --git a/src/main/java/com/dl/officialsite/sharing/model/req/CreateSharingReq.java b/src/main/java/com/dl/officialsite/sharing/model/req/CreateSharingReq.java index 45b28f97..04d19406 100644 --- a/src/main/java/com/dl/officialsite/sharing/model/req/CreateSharingReq.java +++ b/src/main/java/com/dl/officialsite/sharing/model/req/CreateSharingReq.java @@ -63,4 +63,9 @@ public class CreateSharingReq { @ApiModelProperty("标签类别") //defi zk underlying private String label; + + /** + * 分享人memberId + */ + private long memberId; } diff --git a/src/main/java/com/dl/officialsite/sharing/model/req/UpdateSharingReq.java b/src/main/java/com/dl/officialsite/sharing/model/req/UpdateSharingReq.java index 0f6a96a3..a191adc7 100644 --- a/src/main/java/com/dl/officialsite/sharing/model/req/UpdateSharingReq.java +++ b/src/main/java/com/dl/officialsite/sharing/model/req/UpdateSharingReq.java @@ -65,4 +65,9 @@ public class UpdateSharingReq { */ @ApiModelProperty("分享标签") private String label; + + /** + * 修改人id + */ + private String memberId; } diff --git a/src/main/java/com/dl/officialsite/sharing/service/IUserSharingService.java b/src/main/java/com/dl/officialsite/sharing/service/IUserSharingService.java index de38d9ca..26e5beea 100644 --- a/src/main/java/com/dl/officialsite/sharing/service/IUserSharingService.java +++ b/src/main/java/com/dl/officialsite/sharing/service/IUserSharingService.java @@ -26,7 +26,7 @@ public interface IUserSharingService { /** * 删除分享 */ - void deleteSharing(long shareId); + void deleteSharing(long shareId, long memberId); /** diff --git a/src/main/java/com/dl/officialsite/sharing/service/impl/DefaultSharingServiceImpl.java b/src/main/java/com/dl/officialsite/sharing/service/impl/DefaultSharingServiceImpl.java index 5d052308..af43f383 100644 --- a/src/main/java/com/dl/officialsite/sharing/service/impl/DefaultSharingServiceImpl.java +++ b/src/main/java/com/dl/officialsite/sharing/service/impl/DefaultSharingServiceImpl.java @@ -45,11 +45,11 @@ public long createSharing(CreateSharingReq req) { /** * 登陆用户转member */ - SessionUserInfo userInfo = HttpSessionUtils.getMember(request.getSession()); - Preconditions.checkState(userInfo != null, "User info not null"); - Optional memberOpt = this.memberRepository.findByAddress(userInfo.getAddress()); - Member member = memberOpt.get(); - +// SessionUserInfo userInfo = HttpSessionUtils.getMember(request.getSession()); +// Preconditions.checkState(userInfo != null, "User info not null"); +// Optional memberOpt = this.memberRepository.findByAddress(userInfo.getAddress()); +// Member member = memberOpt.get(); +// if(member.getId() != req.) /** * 创建资料 */ @@ -61,7 +61,7 @@ public long createSharing(CreateSharingReq req) { entity.setPresenter(req.getPresenter()); entity.setOrg(req.getOrg()); entity.setTwitter(req.getTwitter()); - entity.setMemberId(member.getId().longValue()); + entity.setMemberId(req.getMemberId()); entity.setSharingDoc(req.getSharingDoc()); entity.setLabel(req.getLabel()); entity.setLockStatus(SharingLockStatus.UNLOCKED.getCode()); @@ -80,10 +80,14 @@ public void updateSharing(UpdateSharingReq req) { TbShare sharing = existed.get(); SessionUserInfo userInfo = HttpSessionUtils.getMember(request.getSession()); Member member = this.memberRepository.findByAddress(userInfo.getAddress()).get(); - if(!Objects.equals(sharing.getMemberId(), member.getId())){ - throw new BizException(CodeEnums.SHARING_NOT_FOUND); - } +// if(!Objects.equals(sharing.getMemberId(), member.getId())){ +// throw new BizException(CodeEnums.SHARING_NOT_FOUND); +// } + + if(!Objects.equals(sharing.getMemberId(), req.getMemberId())){ + throw new BizException(CodeEnums.SHARING_NOT_OWNER); + } if(sharing.getLockStatus() == SharingLockStatus.LOCKED.getCode()){ throw new BizException(CodeEnums.SHARING_LOCKED); } @@ -101,19 +105,18 @@ public void updateSharing(UpdateSharingReq req) { } @Override - public void deleteSharing(long shareId) { + public void deleteSharing(long shareId, long memberId) { //Verify Optional existed = this.sharingRepository.findById(shareId); if(!existed.isPresent()){ throw new BizException(CodeEnums.SHARING_NOT_FOUND); } TbShare sharing = existed.get(); - SessionUserInfo userInfo = HttpSessionUtils.getMember(request.getSession()); - Member member = this.memberRepository.findByAddress(userInfo.getAddress()).get(); - if(!Objects.equals(sharing.getMemberId(), member.getId())){ - throw new BizException(CodeEnums.SHARING_NOT_FOUND); +// SessionUserInfo userInfo = HttpSessionUtils.getMember(request.getSession()); +// Member member = this.memberRepository.findByAddress(userInfo.getAddress()).get(); + if(!Objects.equals(sharing.getMemberId(), memberId)){ + throw new BizException(CodeEnums.SHARING_NOT_OWNER); } - //Delete this.sharingRepository.deleteById(shareId); }