Browse Source

微信第三方平台

dev_shibei_match
zxc 5 years ago
parent
commit
e2a8e34324
  1. 37
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/AuthRedirectController.java
  2. 31
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/WeChatNotifyController.java
  3. 8
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthorizationInfoDao.java
  4. 2
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ComponentAccessTokenDao.java
  5. 12
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/FuncInfoDao.java
  6. 7
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PreAuthTokenDao.java
  7. 12
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/RefreshAuthorizerAccessTokenDao.java
  8. 6
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ComponentVerifyTicketService.java
  9. 12
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java
  10. 5
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml
  11. 4
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentAccessTokenDao.xml
  12. 6
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/FuncInfoDao.xml
  13. 6
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PreAuthTokenDao.xml
  14. 5
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/RefreshAuthorizerAccessTokenDao.xml

37
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/AuthRedirectController.java

@ -0,0 +1,37 @@
package com.epmet.controller;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.service.ComponentVerifyTicketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* @Author zxc
* @CreateTime 2020/7/10 9:04
*/
@RestController
@RequestMapping("mpweb")
public class AuthRedirectController {
@Autowired
private ComponentVerifyTicketService componentVerifyTicketService;
/**
* @Description 授权回调URL
* @param
* @author zxc
*/
public Result redirectUri(HttpServletRequest request, HttpServletResponse response, @LoginUser TokenDto tokenDto, @RequestParam("authAppId")String authAppId){
componentVerifyTicketService.redirectUri(request,response,tokenDto,authAppId);
return new Result();
}
}

31
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/WeChatNotifyController.java

@ -1,15 +1,10 @@
package com.epmet.controller;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.service.ComponentVerifyTicketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* @Author zxc
* @CreateTime 2020/7/8 15:06
@ -44,16 +39,6 @@ public class WeChatNotifyController {
return new Result();
}
/**
* @Description 使用授权码获取授权信息
* @author zxc
*/
/*@PostMapping(value = "/authinfobyauthcode")
public Result authInfoByAuthCode() {
componentVerifyTicketService.authInfoByAuthCode();
return new Result();
}*/
/**
* @Description 获取/刷新接口调用令牌
* @author zxc
@ -64,20 +49,4 @@ public class WeChatNotifyController {
return new Result();
}
/**
* @Description 授权回调URL
* @param
* @author zxc
*/
@PostMapping("redirecturi")
public Result redirectUri(HttpServletRequest request, HttpServletResponse response, @LoginUser TokenDto tokenDto, @PathVariable String authAppId){
componentVerifyTicketService.redirectUri(request,response,tokenDto,authAppId);
return new Result();
}
@PostMapping("merge")
public Result merge(){
return new Result();
}
}

8
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.form.AuthorizationInfoFormDTO;
import com.epmet.entity.AuthorizationInfoEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 授权信息表
@ -37,5 +38,12 @@ public interface AuthorizationInfoDao extends BaseDao<AuthorizationInfoEntity> {
* @author zxc
*/
void insertAuthorizationInfo(AuthorizationInfoFormDTO formDTO);
/**
* @Description 逻辑删除授权信息
* @param customerId
* @author zxc
*/
void updateOldAuthorizationInfo(@Param("customerId")String customerId);
}

2
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ComponentAccessTokenDao.java

@ -37,5 +37,7 @@ public interface ComponentAccessTokenDao extends BaseDao<ComponentAccessTokenEnt
* @author zxc
*/
void insertComponentAccessToken(ComponentAccessTokenFormDTO formDTO);
void updateOldComponentAccessToken();
}

12
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/FuncInfoDao.java

@ -34,6 +34,18 @@ import java.util.List;
@Mapper
public interface FuncInfoDao extends BaseDao<FuncInfoEntity> {
/**
* @Description 插入授权列表信息
* @param funcInfoList
* @author zxc
*/
void insertFuncInfo(@Param("funcInfoList") List<FuncInfoFormDTO> funcInfoList);
/**
* @Description 逻辑删除 权限列表
* @param customerId
* @author zxc
*/
void updateOldFuncInfo(@Param("customerId")String customerId);
}

7
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PreAuthTokenDao.java

@ -37,5 +37,12 @@ public interface PreAuthTokenDao extends BaseDao<PreAuthTokenEntity> {
* @author zxc
*/
void insertPreAuthToken(PreAuthTokenFormDTO formDTO);
/**
* @Description 逻辑删 pre_auth_code
* @param
* @author zxc
*/
void updateOldPreAuthCode();
}

12
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/RefreshAuthorizerAccessTokenDao.java

@ -22,6 +22,7 @@ import com.epmet.dto.form.AuthorizerAccessTokenFormDTO;
import com.epmet.dto.result.WillOverDueResultDTO;
import com.epmet.entity.RefreshAuthorizerAccessTokenEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -41,7 +42,18 @@ public interface RefreshAuthorizerAccessTokenDao extends BaseDao<RefreshAuthoriz
*/
List<WillOverDueResultDTO> checkWillOverDue();
/**
* @Description 插入 authorizer_access_token
* @param refreshAccessToken
* @author zxc
*/
void insertAuthorizerAccessToken(AuthorizerAccessTokenFormDTO refreshAccessToken);
/**
* @Description 逻辑删除 授权方的authorizer_access_token
* @param customerId
* @author zxc
*/
void updateOldAuthorizerAccessToken(@Param("customerId")String customerId);
}

6
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ComponentVerifyTicketService.java

@ -31,12 +31,6 @@ public interface ComponentVerifyTicketService {
*/
void preAuthCode();
/**
* @Description 使用授权码获取授权信息
* @author zxc
*/
// void authInfoByAuthCode();
/**
* @Description 获取/刷新接口调用令牌
* @param

12
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java

@ -156,6 +156,8 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
ComponentAccessTokenFormDTO formDTO = new ComponentAccessTokenFormDTO();
formDTO.setComponentAccessToken(componentAccessToken);
formDTO.setExpiresIn(Integer.valueOf(expiresIn));
//先逻辑删,在插入
componentAccessTokenDao.updateOldComponentAccessToken();
componentAccessTokenDao.insertComponentAccessToken(formDTO);
//存缓存
redisThird.setComponentAccessToken(componentAccessToken);
@ -192,6 +194,8 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
PreAuthTokenFormDTO formDTO = new PreAuthTokenFormDTO();
formDTO.setPreAuthToken(preAuthCode);
formDTO.setExpiresIn(ex);
//先逻辑删除,在插入DB
preAuthTokenDao.updateOldPreAuthCode();
preAuthTokenDao.insertPreAuthToken(formDTO);
//预授权码 放入缓存
redisThird.setPreAuthCode(preAuthCode,ex);
@ -229,6 +233,8 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
authInfoDTO.setAuthorizerRefreshToken(authorizationInfoResultDTO.getAuthorizer_refresh_token());
authInfoDTO.setExpiresIn(Integer.valueOf(authorizationInfoResultDTO.getExpires_in()));
authInfoDTO.setCustomerId(customerId);
//先逻辑删除,在插入
authorizationInfoDao.updateOldAuthorizationInfo(customerId);
authorizationInfoDao.insertAuthorizationInfo(authInfoDTO);
// 获取/刷新接口调用令牌记录表 插入
AuthorizerAccessTokenFormDTO refreshAccessToken = new AuthorizerAccessTokenFormDTO();
@ -237,6 +243,8 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
refreshAccessToken.setAuthorizerAccessToken(authorizationInfoResultDTO.getAuthorizer_access_token());
refreshAccessToken.setAuthorizerRefreshToken(authorizationInfoResultDTO.getAuthorizer_refresh_token());
refreshAccessToken.setExpiresIn(Integer.valueOf(authorizationInfoResultDTO.getExpires_in()));
//先逻辑删除,再插入
refreshAuthorizerAccessTokenDao.updateOldAuthorizerAccessToken(customerId);
refreshAuthorizerAccessTokenDao.insertAuthorizerAccessToken(refreshAccessToken);
// 2. 权限列表
List<FuncInfoFormDTO> funcInfos = new ArrayList<>();
@ -253,6 +261,8 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
fu.setCustomerId(customerId);
funcInfos.add(fu);
}
//先逻辑删除,在插入
funcInfoDao.updateOldFuncInfo(customerId);
funcInfoDao.insertFuncInfo(funcInfos);
// 授权信息放入缓存
redisThird.setAuthInfo(authorizationInfoResultDTO);
@ -291,6 +301,8 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
formDTO.setExpiresIn(Integer.valueOf(expiresIn));
formDTO.setCustomerId(willOverDueDTO.getCustomerId());
formDTO.setAuthAppid(willOverDueDTO.getAuthAppId());
//先逻辑删除,在插入
refreshAuthorizerAccessTokenDao.updateOldAuthorizerAccessToken(willOverDueDTO.getCustomerId());
refreshAuthorizerAccessTokenDao.insertAuthorizerAccessToken(formDTO);
//缓存 refreshAuthorizerAccessToken

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

@ -36,4 +36,9 @@
)
</insert>
<!-- 逻辑删除授权信息 -->
<update id="updateOldAuthorizationInfo">
update authorization_info set del_flag = 0 where customer_id = #{customerId}
</update>
</mapper>

4
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentAccessTokenDao.xml

@ -30,4 +30,8 @@
)
</insert>
<update id="updateOldComponentAccessToken">
update component_access_token set del_flag = 1
</update>
</mapper>

6
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/FuncInfoDao.xml

@ -16,6 +16,7 @@
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<!-- 插入授权列表信息 -->
<insert id="insertFuncInfo" parameterType="com.epmet.dto.form.FuncInfoFormDTO">
<foreach collection="funcInfoList" item="func" separator=",">
INSERT INTO func_info ( ID, FUNCSCOPE_CATEGORY, FUNCSCOPE_ID, CUSTOMER_ID, AUTHORIZATION_INFO_APPID, DEL_FLAG, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME )
@ -35,4 +36,9 @@
</foreach>
</insert>
<!-- 逻辑删除 权限列表 -->
<update id="updateOldFuncInfo">
update func_info set del_flag = 0 where customer_id = #{customerId}
</update>
</mapper>

6
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PreAuthTokenDao.xml

@ -14,6 +14,7 @@
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<!-- 插入 pre_auth_code -->
<insert id="insertPreAuthToken" parameterType="com.epmet.dto.form.PreAuthTokenFormDTO">
INSERT INTO pre_auth_token ( ID, PRE_AUTH_TOKEN, EXPIRES_IN, DEL_FLAG, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME )
VALUES
@ -29,4 +30,9 @@
)
</insert>
<!-- 逻辑删pre_auth_code -->
<update id="updateOldPreAuthCode">
update pre_auth_token set del_flag = 0
</update>
</mapper>

5
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/RefreshAuthorizerAccessTokenDao.xml

@ -49,4 +49,9 @@
)
</insert>
<!-- 逻辑删 authorizer_access_token -->
<update id="updateOldAuthorizerAccessToken">
update refresh_authorizer_access_token set del_flag = 0 where customer_id = #{customerId}
</update>
</mapper>
Loading…
Cancel
Save