Browse Source

微信第三方平台-授权信息修改

master
zxc 5 years ago
parent
commit
bbf879c589
  1. 17
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthorizationInfoDao.java
  2. 5
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/RedisThird.java
  3. 8
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java
  4. 12
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml

17
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<AuthorizationInfoEntity> {
* @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<AuthorizationInfoEntity> {
* @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<AuthorizationInfoEntity> {
*/
void updateOldAuthorizerAccessToken(@Param("customerId")String customerId,@Param("clientType")String clientType);
/**
* @Description 根据 authAppId 查询客户ID和客户端类型
* @param authAppId
* @author zxc
*/
AuthCodeResultDTO selectCustomerIdByAuthAppId(@Param("authAppId")String authAppId);
}

5
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<String, Object> map = BeanUtil.beanToMap(authInfo, false, true);
String key = ThirdRedisKeyConstant.AUTHORIZER_REFRESH_TOKEN_REDIS_KEY + customerId+ThirdRedisKeyConstant.COLON + clientType;
redisUtils.hMSet(key, map,NOT_EXPIRE);
}
}

8
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<String, Object> 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)){

12
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml

@ -78,4 +78,16 @@
AND EXPIRES_IN_TIME > NOW()
</select>
<!-- 根据 authAppId 查询客户ID和客户端类型 -->
<select id="selectCustomerIdByAuthAppId" resultType="com.epmet.dto.result.AuthCodeResultDTO">
SELECT
customer_id AS customerId,
client_type AS clientType
FROM
authorization_info
WHERE
del_flag = 0
AND authorizer_appid = #{authAppId}
</select>
</mapper>
Loading…
Cancel
Save