|
|
|
@@ -1,7 +1,10 @@ |
|
|
|
package com.iformall.controller; |
|
|
|
|
|
|
|
import com.iformall.domain.po.WxAuthorizerInfo; |
|
|
|
import com.iformall.domain.po.WxComponentVerifyTicket; |
|
|
|
import com.iformall.enums.EnumWxAuthorizationInfoType; |
|
|
|
import com.iformall.enums.EnumWxAuthorizationStatus; |
|
|
|
import com.iformall.service.WxAuthorizerInfoService; |
|
|
|
import com.iformall.service.WxComponentVerifyTicketService; |
|
|
|
import com.iformall.service.wechat.WxOpenService; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
@@ -11,6 +14,8 @@ import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage; |
|
|
|
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; |
|
|
|
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; |
|
|
|
import me.chanjar.weixin.open.bean.message.WxOpenXmlMessage; |
|
|
|
import me.chanjar.weixin.open.bean.result.WxOpenAuthorizerInfoResult; |
|
|
|
import me.chanjar.weixin.open.bean.result.WxOpenQueryAuthResult; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
@@ -37,6 +42,9 @@ public class WechatCalllbackController extends BaseController { |
|
|
|
@Autowired |
|
|
|
private WxComponentVerifyTicketService componentVerifyTicketService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WxAuthorizerInfoService authorizerInfoService; |
|
|
|
|
|
|
|
@RequestMapping(value = "/notify", method = RequestMethod.POST) |
|
|
|
@ApiOperation("接收ticket回调") |
|
|
|
public Object receiveTicket(HttpServletRequest request) throws IOException { |
|
|
|
@@ -86,9 +94,32 @@ public class WechatCalllbackController extends BaseController { |
|
|
|
} else if (inMessage.getInfoType().equals(EnumWxAuthorizationInfoType.AUTHORIZED.getMessage()) || |
|
|
|
inMessage.getInfoType().equals(EnumWxAuthorizationInfoType.UPDATEAUTHORIZED.getMessage()) |
|
|
|
) { |
|
|
|
// TODO |
|
|
|
try { |
|
|
|
WxOpenQueryAuthResult queryAuthResult = wxOpenService.getWxOpenComponentService().getQueryAuth(inMessage.getAuthorizationCode()); |
|
|
|
logger.info("getQueryAuth", queryAuthResult); |
|
|
|
|
|
|
|
WxOpenAuthorizerInfoResult openAuthorizerInfoResult = wxOpenService.getWxOpenComponentService().getAuthorizerInfo( |
|
|
|
queryAuthResult.getAuthorizationInfo().getAuthorizerAppid()); |
|
|
|
// save auth info |
|
|
|
authorizerInfoService.saveOrUpdate(new WxAuthorizerInfo(){ |
|
|
|
{ |
|
|
|
setAuthorizerAppid(openAuthorizerInfoResult.getAuthorizationInfo().getAuthorizerAppid()); |
|
|
|
setAlias(openAuthorizerInfoResult.getAuthorizerInfo().getAlias()); |
|
|
|
setHeadImg(openAuthorizerInfoResult.getAuthorizerInfo().getHeadImg()); |
|
|
|
setQrcodeUrl(openAuthorizerInfoResult.getAuthorizerInfo().getQrcodeUrl()); |
|
|
|
setAuthorizationStatus(EnumWxAuthorizationStatus.AUTHORIZED.getCode()); |
|
|
|
} |
|
|
|
}); |
|
|
|
} catch (WxErrorException e) { |
|
|
|
logger.error(e.getMessage()); |
|
|
|
} |
|
|
|
} else if (inMessage.getInfoType().equals(EnumWxAuthorizationInfoType.AUTHORIZED.getMessage())) { |
|
|
|
// TODO |
|
|
|
authorizerInfoService.saveOrUpdate(new WxAuthorizerInfo(){ |
|
|
|
{ |
|
|
|
setAuthorizerAppid(inMessage.getAuthorizerAppid()); |
|
|
|
setAuthorizationStatus(EnumWxAuthorizationStatus.UNAUTHORIZED.getCode()); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
try { |
|
|
|
String out = wxOpenService.getWxOpenComponentService().route(inMessage); |
|
|
|
|