From 9a0d0d2980953533aa02dc065525bc448e7bd38f Mon Sep 17 00:00:00 2001 From: xzb <223@qq.com> Date: Wed, 19 Oct 2022 15:02:33 +0800 Subject: [PATCH] permission --- .../AcPermissionDistributeController.java | 10 +- .../PermissionDistributeService.java | 15 ++- .../ScanPermissionDistributeInfoRspVo.java | 108 +++++++++++++++--- 3 files changed, 113 insertions(+), 20 deletions(-) diff --git a/src/main/java/club/joylink/rtss/controller/permission2/AcPermissionDistributeController.java b/src/main/java/club/joylink/rtss/controller/permission2/AcPermissionDistributeController.java index d01be99b3..ab7e46729 100644 --- a/src/main/java/club/joylink/rtss/controller/permission2/AcPermissionDistributeController.java +++ b/src/main/java/club/joylink/rtss/controller/permission2/AcPermissionDistributeController.java @@ -76,16 +76,18 @@ public class AcPermissionDistributeController { */ @GetMapping(path = "/{pdId}/qrCode") public String generateQrCode(@PathVariable("pdId") Long pdId, @RequestAttribute(value = AuthenticateInterceptor.LOGIN_INFO_KEY) LoginUserInfoVO loginInfo) { - return this.permissionDistributeService.generateQrCode(pdId,loginInfo); + return this.permissionDistributeService.generateQrCode(pdId, loginInfo); } + /** * 微信扫码获取权限分发相关信息 + * * @param code 用户编码 * @param id 权限分发id */ - @GetMapping - public void findPermissionDistributeInfo(String code, Long id){ - + @GetMapping("/scan") + public ScanPermissionDistributeInfoRspVo scanPermissionDistributeInfo(String code, Long id) { + return this.permissionDistributeService.scanPermissionDistributeInfo(code, id); } } diff --git a/src/main/java/club/joylink/rtss/services/permission/PermissionDistributeService.java b/src/main/java/club/joylink/rtss/services/permission/PermissionDistributeService.java index 9f02fc241..4b77884bc 100644 --- a/src/main/java/club/joylink/rtss/services/permission/PermissionDistributeService.java +++ b/src/main/java/club/joylink/rtss/services/permission/PermissionDistributeService.java @@ -225,11 +225,24 @@ public class PermissionDistributeService { * @param code 用户编码 * @param id 权限分发id */ - public void scanPermissionDistributeInfo(String code, Long id) { + @Transactional(readOnly = true) + public ScanPermissionDistributeInfoRspVo scanPermissionDistributeInfo(String code, Long id) { AccountVO accountVO = this.authenticateService.getOrCreateUserByWmcode(WxApiService.MiniApp.JoyLink, code); PermissionDistribute permissionDistribute = this.permissionDistributeDAO.selectByPrimaryKey(id); BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(null != permissionDistribute, String.format("权限分发[id=%s]不存在", id)); Permission permission = this.permissionDAO.selectByPrimaryKey(permissionDistribute.getPermissionId()); BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(null != permission, String.format("权限分发[id=%s]的权限[id=%s]不存在", id, permissionDistribute.getPermissionId())); + // + SysAccount creator = this.sysAccountDAO.selectByPrimaryKey(permissionDistribute.getCreatorId()); + BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(null != creator); + SysAccount scanner = this.sysAccountDAO.selectByPrimaryKey(accountVO.getId()); + BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(null != scanner); + // + ScanPermissionDistributeInfoRspVo rsp = new ScanPermissionDistributeInfoRspVo(); + rsp.fill(permissionDistribute); + rsp.fillPermission(permission); + rsp.fillCreator(creator); + rsp.fillScanner(scanner); + return rsp; } } diff --git a/src/main/java/club/joylink/rtss/vo/permission/ScanPermissionDistributeInfoRspVo.java b/src/main/java/club/joylink/rtss/vo/permission/ScanPermissionDistributeInfoRspVo.java index a0a72b99d..9ab08c2a3 100644 --- a/src/main/java/club/joylink/rtss/vo/permission/ScanPermissionDistributeInfoRspVo.java +++ b/src/main/java/club/joylink/rtss/vo/permission/ScanPermissionDistributeInfoRspVo.java @@ -1,27 +1,29 @@ package club.joylink.rtss.vo.permission; +import club.joylink.rtss.entity.SysAccount; +import club.joylink.rtss.entity.permission.Permission; +import club.joylink.rtss.entity.permission.PermissionDistribute; import lombok.Data; import java.time.LocalDateTime; /** - * 扫码获取权限分发的响应 + * 扫码获取权限分发的相关信息 */ @Data public class ScanPermissionDistributeInfoRspVo { /** - * 扫码用户的账号id + * 进行扫码操作的用户 */ - private Long accountId; + private AccountVo scanner; /** * 权限分发id */ private Long pdId; - /** - * 关联权限id + * 关联权限 */ - private Long permissionId; + private PermissionVo permissionInfo; /** * 分发来自subject id(rts_permission_subject) @@ -44,7 +46,7 @@ public class ScanPermissionDistributeInfoRspVo { private Boolean forever; /** - * 权限分发状态 + * 权限分发状态,1-有效,2-无效 */ private Integer status; @@ -52,12 +54,6 @@ public class ScanPermissionDistributeInfoRspVo { * 创建时间 */ private LocalDateTime createTime; - - /** - * 修改时间 - */ - private LocalDateTime updateTime; - /** * 开始时间 */ @@ -69,12 +65,94 @@ public class ScanPermissionDistributeInfoRspVo { private LocalDateTime endTime; /** - * 创建者id + * 创建者 */ - private Long creatorId; + private AccountVo creator; /** * 备注描述 */ private String dsc; + + public void fillCreator(SysAccount account){ + this.setCreator(this.convertFrom(account)); + } + public void fillScanner(SysAccount account){ + this.setScanner(this.convertFrom(account)); + } + public void fillPermission(Permission p){ + PermissionVo to = new PermissionVo(); + this.setPermissionInfo(to); + // + to.setId(p.getId()); + to.setName(p.getName()); + to.setDes(p.getDes()); + } + public void fill(PermissionDistribute p){ + this.pdId=p.getId(); + this.sourceSubjectId=p.getSourceSubjectId(); + this.amount=p.getAmount(); + this.remains=p.getRemains(); + this.forever=p.getForever(); + this.status=p.getStatus(); + this.createTime=p.getCreateTime(); + this.startTime=p.getStartTime(); + this.endTime=p.getEndTime(); + this.dsc=p.getDsc(); + } + ////////////////////////////////////////////////////// + + private AccountVo convertFrom(SysAccount from){ + AccountVo to = new AccountVo(); + to.setId(from.getId()); + to.setName(from.getName()); + to.setAccount(from.getAccount()); + to.setNickName(from.getNickname()); + to.setMobile(from.getMobile()); + to.setEmail(from.getEmail()); + return to; + } + @Data + public static class AccountVo{ + /** + * 用户id + */ + private Long id; + /** + * 账号 + */ + private String account; + /** + * 真实姓名 + */ + private String name; + /** + * 昵称 + */ + private String nickName; + /** + * 电话 + */ + private String mobile; + /** + * 邮件地址 + */ + private String email; + + } + @Data + public static class PermissionVo{ + /** + * 权限id + */ + private Long id; + /** + * 权限名称 + */ + private String name; + /** + * 权限描述 + */ + private String des; + } }