From b59e2a1a9fd3cac489697db187de744049c5ea68 Mon Sep 17 00:00:00 2001 From: wangchao Date: Tue, 25 Aug 2020 16:03:22 +0800 Subject: [PATCH] =?UTF-8?q?third=E6=8E=A5=E5=8F=A3=20=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E5=AE=A2=E6=88=B7=E6=9F=A5=E8=AF=A2Token?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/CommonCustomerIdAndSrcFormDTO.java | 33 +++++++++++++ .../dto/form/CommonCustomerIdFormDTO.java | 27 ++++++++++ .../AuthAccessTokenClientResultDTO.java | 26 ++++++++++ .../dto/result/CustomerTokensResultDTO.java | 41 ++++++++++++++++ .../com/epmet/constant/ModuleConstant.java | 4 ++ .../controller/PaCustomerController.java | 14 ++++++ .../com/epmet/dao/AuthorizationInfoDao.java | 9 ++++ .../epmet/dao/ComponentAccessTokenDao.java | 9 ++++ .../com/epmet/service/PaCustomerService.java | 21 ++++++++ .../service/impl/PaCustomerServiceImpl.java | 49 +++++++++++++++++++ .../resources/mapper/AuthorizationInfoDao.xml | 12 +++++ .../mapper/ComponentAccessTokenDao.xml | 11 +++++ 12 files changed, 256 insertions(+) create mode 100644 epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CommonCustomerIdAndSrcFormDTO.java create mode 100644 epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CommonCustomerIdFormDTO.java create mode 100644 epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/AuthAccessTokenClientResultDTO.java create mode 100644 epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CustomerTokensResultDTO.java diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CommonCustomerIdAndSrcFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CommonCustomerIdAndSrcFormDTO.java new file mode 100644 index 0000000000..080e7fcd8f --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CommonCustomerIdAndSrcFormDTO.java @@ -0,0 +1,33 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description 公众号客户删除入参DTO + * @NEI https://nei.netease.com/interface/detail/?pid=52285&id=323482 + * @ClassName CommonCustomerIdAndSrcFormDTO + * @Auth wangc + * @Date 2020-08-25 11:02 + */ +@Data +public class CommonCustomerIdAndSrcFormDTO implements Serializable { + private static final long serialVersionUID = -2945388338786885295L; + + public interface CustomerAndSrcGroup extends CustomerClientShowGroup{} + + /** + * 客户Id + * */ + @NotBlank(message = "客户Id不能为空",groups = CustomerAndSrcGroup.class) + private String customerId; + + /** + * 数据来源(dev:开发 test:体验 prod:生产) + * */ + @NotBlank(message = "数据来源不能为空",groups = CustomerAndSrcGroup.class) + private String source; +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CommonCustomerIdFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CommonCustomerIdFormDTO.java new file mode 100644 index 0000000000..43860b8d8c --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CommonCustomerIdFormDTO.java @@ -0,0 +1,27 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description 获取客户第三方token 入参DTO + * @NEI https://nei.netease.com/interface/detail/?pid=52285&id=323480 + * @ClassName CommonCustomerIdFormDTO + * @Auth wangc + * @Date 2020-08-25 10:57 + */ +@Data +public class CommonCustomerIdFormDTO implements Serializable { + private static final long serialVersionUID = 3160741101286756024L; + + public interface PaCustomerIdGroup extends CustomerClientShowGroup{} + + /** + * 客户Id + * */ + @NotBlank(message = "客户Id不能为空" , groups = PaCustomerIdGroup.class) + private String customerId; +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/AuthAccessTokenClientResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/AuthAccessTokenClientResultDTO.java new file mode 100644 index 0000000000..69b1c4abb1 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/AuthAccessTokenClientResultDTO.java @@ -0,0 +1,26 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description 授权accessToken和app端的查询返参 + * @ClassName AuthAccessTokenClientResultDTO + * @Auth wangc + * @Date 2020-08-25 13:41 + */ +@Data +public class AuthAccessTokenClientResultDTO implements Serializable { + private static final long serialVersionUID = -642465145534993509L; + + /** + * 客户端类型 + * */ + private String clientType; + + /** + * 调用令牌 + * */ + private String accessToken; +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CustomerTokensResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CustomerTokensResultDTO.java new file mode 100644 index 0000000000..212114a4cc --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CustomerTokensResultDTO.java @@ -0,0 +1,41 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description + * @ClassName CustomerTokensResultDTO + * @Auth wangc + * @Date 2020-08-25 11:16 + */ +@Data +public class CustomerTokensResultDTO implements Serializable { + private static final long serialVersionUID = -6811282503588315365L; + + /** + * 客户Id + * */ + private String customerId = ""; + + /** + * 客户名称 + * */ + private String customerName = ""; + + /** + * 第三方token + * */ + private String componentAccessToken = ""; + + /** + * 授权方居民端token + * */ + private String resiAuthorizerToken = ""; + + /** + * 授权方工作端token + * */ + private String workAuthorizerToken = ""; +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ModuleConstant.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ModuleConstant.java index 544e4da23e..4c1cec0015 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ModuleConstant.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ModuleConstant.java @@ -116,5 +116,9 @@ public interface ModuleConstant { int EIGHTY_NINE_THOUSAND_AND_THREE = 89003; int EIGHTY_NINE_THOUSAND_AND_FOUR = 89004; + /** + * 数据来源 : 生产环境 + * */ + String SRC_PROD = "prod"; } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java index 13ad00fc9d..686985c317 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java @@ -192,5 +192,19 @@ public class PaCustomerController { return new Result().ok(pageData); } + /** + * @Description 获取客户第三方token + * @NEI https://nei.netease.com/interface/detail/req/?pid=52285&id=323480 + * @param param CommonCustomerIdFormDTO.class + * @return Result + * @author wangc + * @date 2020.08.25 15:39 + **/ + @PostMapping("tokenlist") + public Result tokenList(@RequestBody CommonCustomerIdFormDTO param){ + ValidatorUtils.validateEntity(param, CustomerUserFormDTO.CustomerIdGroup.class); + return new Result().ok(paCustomerService.tokenList(param)); + } + } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthorizationInfoDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthorizationInfoDao.java index b5c24edf2f..882a091b1b 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthorizationInfoDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthorizationInfoDao.java @@ -22,6 +22,7 @@ import com.epmet.dto.AuthorizationInfoDTO; import com.epmet.dto.form.AuthorizationInfoFormDTO; import com.epmet.dto.form.AuthorizerAccessTokenFormDTO; import com.epmet.dto.form.CustomerAccessTokenInfoFormDTO; +import com.epmet.dto.result.AuthAccessTokenClientResultDTO; import com.epmet.dto.result.AuthCodeResultDTO; import com.epmet.dto.result.CustomerAccessTokenInfoResultDTO; import com.epmet.dto.result.WillOverDueResultDTO; @@ -109,4 +110,12 @@ public interface AuthorizationInfoDao extends BaseDao { */ List getCustomerAccessTokenInfo(CustomerAccessTokenInfoFormDTO customerAccessTokenInfoFormDTO); + /** + * @Description 查询来源端对应的accessToken + * @param customerId + * @return List + * @author wangc + * @date 2020.08.25 15:24 + **/ + List selectClientToken(@Param("customerId") String customerId); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ComponentAccessTokenDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ComponentAccessTokenDao.java index 10a5710c6e..85a5bac687 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ComponentAccessTokenDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ComponentAccessTokenDao.java @@ -69,4 +69,13 @@ public interface ComponentAccessTokenDao extends BaseDao { * @return com.epmet.commons.tools.page.PageData */ PageData getCustomerList(UploadListFormDTO formDTO); + + /** + * @Description 获取客户第三方token + * @NEI https://nei.netease.com/interface/detail/res/?pid=52285&id=323480 + * @param param + * @return + * @author wangc + * @date 2020.08.25 14:51 + **/ + CustomerTokensResultDTO tokenList(CommonCustomerIdFormDTO param); + + /** + * @Description 公众号客户删除 + * @NEI https://nei.netease.com/interface/detail/?pid=52285&id=323482 + * @param token + * @param param + * @return + * @author wangc + * @date 2020.08.25 15:46 + **/ + void deletePublicCustomer(TokenDto token,CommonCustomerIdAndSrcFormDTO param); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java index c77f86e336..cf9f0666e7 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java @@ -31,6 +31,8 @@ import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.CpUserDetailRedis; +import com.epmet.constant.CodeConstant; +import com.epmet.constant.ModuleConstant; import com.epmet.constant.PaConstant; import com.epmet.dao.*; import com.epmet.dto.*; @@ -102,6 +104,8 @@ public class PaCustomerServiceImpl extends BaseServiceImpl page(Map params) { @@ -641,4 +645,49 @@ public class PaCustomerServiceImpl extends BaseServiceImpl(list, pageInfo.getTotal()); } + /** + * @Description 获取客户第三方token + * @NEI https://nei.netease.com/interface/detail/res/?pid=52285&id=323480 + * @param param + * @return + * @author wangc + * @date 2020.08.25 14:51 + **/ + @Override + public CustomerTokensResultDTO tokenList(CommonCustomerIdFormDTO param) { + CustomerTokensResultDTO result = new CustomerTokensResultDTO(); + String customerName = baseDao.selectCustomerName(param.getCustomerId()); + String componentAccessToken = componentAccessTokenDao.selectComponentAccessToken(); + List clientList = authorizationInfoDao.selectClientToken(param.getCustomerId()); + result.setCustomerId(param.getCustomerId()); + result.setComponentAccessToken(StringUtils.isBlank(componentAccessToken) ? "" : componentAccessToken); + result.setCustomerName(StringUtils.isBlank(customerName) ? "" : customerName); + if(null != clientList || !clientList.isEmpty()){ + clientList.forEach(client -> { + if(StringUtils.equals(CodeConstant.WORK,client.getClientType())){ + result.setWorkAuthorizerToken(client.getAccessToken()); + }else if(StringUtils.equals(CodeConstant.RESI,client.getClientType())){ + result.setResiAuthorizerToken(client.getAccessToken()); + } + }); + } + return result; + } + + /** + * @Description 公众号客户删除 + * @NEI https://nei.netease.com/interface/detail/?pid=52285&id=323482 + * @param token + * @param param + * @return + * @author wangc + * @date 2020.08.25 15:46 + **/ + @Override + public void deletePublicCustomer(TokenDto token , CommonCustomerIdAndSrcFormDTO param) { + if(StringUtils.equals(ModuleConstant.SRC_PROD,param.getSource())){ + logger.warn("有人试图删除用户生产数据,试图删除的客户Id:{},操作者Id:{}",param.getCustomerId(),token.getUserId()); + } + } + } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml index 61f441b6b8..c976e85ab8 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml @@ -121,4 +121,16 @@ + + + \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentAccessTokenDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentAccessTokenDao.xml index 3642c1d768..98d52d60b8 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentAccessTokenDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentAccessTokenDao.xml @@ -48,4 +48,15 @@ AND (UNIX_TIMESTAMP(expires_in_time) - UNIX_TIMESTAMP(NOW())) 900 + + \ No newline at end of file