From bbf879c5893df6424fb886a22ef6396527812ff9 Mon Sep 17 00:00:00 2001 From: zxc <954985706@qq.com> Date: Wed, 22 Jul 2020 17:46:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E7=AC=AC=E4=B8=89=E6=96=B9?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0-=E6=8E=88=E6=9D=83=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/dao/AuthorizationInfoDao.java | 17 ++++++++++++++++- .../main/java/com/epmet/redis/RedisThird.java | 5 +++-- .../impl/ComponentVerifyTicketServiceImpl.java | 8 ++++---- .../resources/mapper/AuthorizationInfoDao.xml | 12 ++++++++++++ 4 files changed, 35 insertions(+), 7 deletions(-) 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 3e98b5a623..ad1bca18b5 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 @@ -21,6 +21,7 @@ import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.AuthorizationInfoDTO; import com.epmet.dto.form.AuthorizationInfoFormDTO; import com.epmet.dto.form.AuthorizerAccessTokenFormDTO; +import com.epmet.dto.result.AuthCodeResultDTO; import com.epmet.dto.result.WillOverDueResultDTO; import com.epmet.entity.AuthorizationInfoEntity; import org.apache.ibatis.annotations.Mapper; @@ -49,7 +50,7 @@ public interface AuthorizationInfoDao extends BaseDao { * @param customerId * @author zxc */ - void updateOldAuthorizationInfo(@Param("customerId")String customerId); +// void updateOldAuthorizationInfo(@Param("customerId")String customerId); /** * 根据客户ID,客户端类型获取授权信息 @@ -60,6 +61,13 @@ public interface AuthorizationInfoDao extends BaseDao { * @return com.epmet.dto.AuthorizationInfoDTO */ AuthorizationInfoDTO getAuthInfoByCustomer(@Param("customerId") String customerId, @Param("clientType") String clientType); + + /** + * @Description 逻辑删除授权信息 + * @param customerId + * @param clientType + * @author zxc + */ void updateOldAuthorizationInfo(@Param("customerId")String customerId,@Param("clientType")String clientType); /** @@ -83,4 +91,11 @@ public interface AuthorizationInfoDao extends BaseDao { */ void updateOldAuthorizerAccessToken(@Param("customerId")String customerId,@Param("clientType")String clientType); + /** + * @Description 根据 authAppId 查询客户ID和客户端类型 + * @param authAppId + * @author zxc + */ + AuthCodeResultDTO selectCustomerIdByAuthAppId(@Param("authAppId")String authAppId); + } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/RedisThird.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/RedisThird.java index 9317ce418e..4d1e3f9386 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/RedisThird.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/RedisThird.java @@ -121,8 +121,9 @@ public class RedisThird { * @author zxc */ public void setAuthInfo(AuthorizationInfoResultDTO authInfo,String customerId,String clientType){ - String key = ThirdRedisKeyConstant.AUTH_INFO_REDIS_KEY+ThirdRedisKeyConstant.COLON+customerId+ThirdRedisKeyConstant.COLON+clientType; - redisUtils.set(key,authInfo,-1); + Map map = BeanUtil.beanToMap(authInfo, false, true); + String key = ThirdRedisKeyConstant.AUTHORIZER_REFRESH_TOKEN_REDIS_KEY + customerId+ThirdRedisKeyConstant.COLON + clientType; + redisUtils.hMSet(key, map,NOT_EXPIRE); } } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java index feafd23b93..c73a85b980 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java @@ -138,19 +138,20 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe case ModuleConstant.AUTHORIZED: //授权成功 // 更改customer_mp 授权信息,appId,并绑定 String authCode = result.get(ModuleConstant.AUTHORIZATION_CODE_HUMP); + String authAppId = result.get(ModuleConstant.AUTHORIZER_APP_ID_HUMP); log.info("=============================="+authCode); - AuthCodeResultDTO authCodeResultDTO = authCodeDao.selectCustomerIdByAuthCode(authCode); + AuthCodeResultDTO authCodeResultDTO = authorizationInfoDao.selectCustomerIdByAuthAppId(authAppId); String clientType = authCodeResultDTO.getClientType(); String customerId = authCodeResultDTO.getCustomerId(); - Map authorizerRefreshToken = redisThird.getAuthorizerRefreshToken(customerId + ThirdRedisKeyConstant.COLON + clientType); - String authAppId = authorizerRefreshToken.get("authorizerAppid").toString(); this.updateCustomerMpAppIdAndCreateOpenPlatform(customerId,authAppId,clientType); authCodeDao.updateAppId(customerId,clientType,authAppId); this.saveAuthAccountInfo(customerId,authAppId,clientType); + break; case ModuleConstant.UNAUTHORIZED://用户取消授权 //todo 取消授权 String authorizerAppId = result.get(ModuleConstant.AUTHORIZER_APP_ID_HUMP); customerMpDao.updateAuthorizationFlag(authorizerAppId); + break; } } catch (Exception e) { log.error(e.getMessage()); @@ -372,7 +373,6 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe String authCode = authCodeAndTime.getAuthCode(); String client = authCodeAndTime.getClientType(); String expiresIn = authCodeAndTime.getExpiresIn(); -// String customerId = tokenDto.getCustomerId(); String customerId = this.getLoginUserCustomerId(tokenDto); Date expiresInTime = this.countExpirationTime(expiresIn); if (StringUtils.isBlank(customerId)||StringUtils.isBlank(client)||StringUtils.isBlank(authCode)||StringUtils.isBlank(expiresIn)){ 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 406a9fd06c..a45ff3501e 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 @@ -78,4 +78,16 @@ AND EXPIRES_IN_TIME > NOW() + + + \ No newline at end of file