Browse Source

微信第三方平台-授权回调

dev_shibei_match
zxc 5 years ago
parent
commit
6617d1fa38
  1. 3
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/AuthRedirectController.java
  2. 3
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ComponentVerifyTicketService.java
  3. 5
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java
  4. 10
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java

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

@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* @Author zxc
@ -28,7 +29,7 @@ public class AuthRedirectController {
* @author zxc
*/
@GetMapping("redirect/{customerId}/{clientType}")
public Result redirectUri(HttpServletRequest request, HttpServletResponse response, @PathVariable("customerId")String customerId, @PathVariable("clientType")String clientType){
public Result redirectUri(HttpServletRequest request, HttpServletResponse response, @PathVariable("customerId")String customerId, @PathVariable("clientType")String clientType) throws IOException {
componentVerifyTicketService.redirectUri(request,response,customerId,clientType);
return new Result();
}

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

@ -2,6 +2,7 @@ package com.epmet.service;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* @Author zxc
@ -41,6 +42,6 @@ public interface ComponentVerifyTicketService {
* @param
* @author zxc
*/
void redirectUri(HttpServletRequest request, HttpServletResponse response,String customerId, String clientType);
void redirectUri(HttpServletRequest request, HttpServletResponse response,String customerId, String clientType) throws IOException;
}

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

@ -30,6 +30,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
@ -366,7 +367,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
*/
@Transactional(rollbackFor = Exception.class)
@Override
public void redirectUri(HttpServletRequest request, HttpServletResponse response,String customerId, String client) {
public void redirectUri(HttpServletRequest request, HttpServletResponse response,String customerId, String client) throws IOException{
log.info("开始执行回调URL");
try {
request.setCharacterEncoding(ModuleConstant.UTF8);
@ -391,11 +392,13 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
//授权方AppId
// formDTO.setAuthAppId(authorizationInfo.getAuthorizer_appid());
formDTO.setCustomerId(customerId);
log.info(formDTO.toString());
// this.updateCustomerMpAppIdAndCreateOpenPlatform(customerId,authorizationInfo.getAuthorizer_appid(),client);
authCodeDao.insertRedirectAuthCode(formDTO);
//authCode存缓存
redisThird.setAuthCode(formDTO);
log.info("回调结束");
response.sendRedirect(WxMaCodeConstant.WEB_URL);
}
/**

10
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java

@ -26,16 +26,14 @@ public interface WxMaCodeConstant {
String API_AUTHORIZER_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/component/api_authorizer_token?component_access_token=";
/**
* 授权回调url
* 反参授权回调url
*/
String API_REDIRECT_URL = "https://epmet-dev.elinkservice.cn/api/third/redirectauthcode";
String API_RETURN_REDIRECT_URL = "https://epmet-cloud.elinkservice.cn/api/third/redirectauthcode/%s/%s";
/**
* 反参授权回调url
* 前端地址 授权之后的跳转的地址
*/
// String API_RETURN_REDIRECT_URL = "https://epmet-dev.elinkservice.cn/api/third/redirectauthcode?client=%s&customerId=%s";
String API_RETURN_REDIRECT_URL = "https://epmet-cloud.elinkservice.cn/api/third/redirectauthcode/%s/%s";
// String API_RETURN_REDIRECT_URL = "https://10.10.10.194:8080/api/third/redirectauthcode?client=%s&customerId=%s";
String WEB_URL = "https://epmet-cloud.elinkservice.cn/third/mpweb/page/info";
/**
* 授权注册页面扫码授权

Loading…
Cancel
Save