|
|
|
@@ -1,5 +1,9 @@ |
|
|
|
package com.iformall.controller; |
|
|
|
|
|
|
|
import com.google.gson.Gson; |
|
|
|
import com.google.gson.GsonBuilder; |
|
|
|
import com.iformall.common.Result; |
|
|
|
import com.iformall.common.ResultData; |
|
|
|
import com.iformall.domain.po.*; |
|
|
|
import com.iformall.enums.EnumWeappAuditStatus; |
|
|
|
import com.iformall.enums.EnumWxAuthorizationInfoType; |
|
|
|
@@ -14,7 +18,9 @@ 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.WxOpenPlatformResult; |
|
|
|
import me.chanjar.weixin.open.bean.result.WxOpenQueryAuthResult; |
|
|
|
import me.chanjar.weixin.open.bean.result.WxOpenResult; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
@@ -312,53 +318,78 @@ public class WechatCalllbackController extends BaseController { |
|
|
|
|
|
|
|
@GetMapping(value = "/createOpenPlatform") |
|
|
|
@ApiOperation("创建微信开放平台") |
|
|
|
public String createOpenPlatform(@RequestParam(value="appId") String appId) { |
|
|
|
public ResultData createOpenPlatform(@RequestParam(value="appId") String appId) { |
|
|
|
Gson gson = new GsonBuilder().create(); |
|
|
|
try { |
|
|
|
String llstr = openService.getWxOpenComponentService().getWxMpServiceByAppid(appId).createOpenPlatform(appId); |
|
|
|
logger.info(llstr); |
|
|
|
return llstr; |
|
|
|
String responseStr = openService.getWxOpenComponentService().getWxMpServiceByAppid(appId).createOpenPlatform(appId); |
|
|
|
logger.info(responseStr); |
|
|
|
WxOpenPlatformResult openPlatformResult = gson.fromJson(responseStr, WxOpenPlatformResult.class); |
|
|
|
if(openPlatformResult.isSuccess()) { |
|
|
|
WxAuthorizerInfo authorizerInfo = authorizerInfoService.getByAppId(appId); |
|
|
|
if(authorizerInfo != null) { |
|
|
|
authorizerInfo.setId(authorizerInfo.getId()); |
|
|
|
authorizerInfo.setOpenAppid(openPlatformResult.getOpenAppid()); |
|
|
|
authorizerInfoService.updateOpenAppid(authorizerInfo); |
|
|
|
} |
|
|
|
} |
|
|
|
return new ResultData(responseStr); |
|
|
|
} catch (WxErrorException e) { |
|
|
|
logger.error(e.getMessage()); |
|
|
|
return new ResultData(Result.ERROR, e.getMessage()); |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping(value = "/bindOpenPlatform") |
|
|
|
@ApiOperation("绑定微信开放平台") |
|
|
|
public String bindOpenPlatform(@RequestParam(value = "appId") String appId, @RequestParam(value = "openAppId") String openAppId) { |
|
|
|
public ResultData bindOpenPlatform(@RequestParam(value = "appId") String appId, @RequestParam(value = "openAppId") String openAppId) { |
|
|
|
Gson gson = new GsonBuilder().create(); |
|
|
|
try { |
|
|
|
String llstr = openService.getWxOpenComponentService().getWxMpServiceByAppid(appId).bindOpenPlatform(appId, openAppId); |
|
|
|
logger.info(llstr); |
|
|
|
return llstr; |
|
|
|
String responseStr = openService.getWxOpenComponentService().getWxMpServiceByAppid(appId).bindOpenPlatform(appId, openAppId); |
|
|
|
logger.info(responseStr); |
|
|
|
WxOpenResult openResult = gson.fromJson(responseStr, WxOpenResult.class); |
|
|
|
if(openResult.isSuccess()) { |
|
|
|
return new ResultData(); |
|
|
|
} |
|
|
|
return new ResultData(Result.ERROR, responseStr); |
|
|
|
} catch (WxErrorException e) { |
|
|
|
logger.error(e.getMessage()); |
|
|
|
return new ResultData(Result.ERROR, e.getMessage()); |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping(value = "/unbindOpenPlatform") |
|
|
|
@ApiOperation("解绑微信开放平台") |
|
|
|
public String unbindOpenPlatform(@RequestParam(value = "appId") String appId, @RequestParam(value = "openAppId") String openAppId) { |
|
|
|
public ResultData unbindOpenPlatform(@RequestParam(value = "appId") String appId, @RequestParam(value = "openAppId") String openAppId) { |
|
|
|
Gson gson = new GsonBuilder().create(); |
|
|
|
try { |
|
|
|
String llstr = openService.getWxOpenComponentService().getWxMpServiceByAppid(appId).unbindOpenPlatform(appId, openAppId); |
|
|
|
logger.info(llstr); |
|
|
|
return llstr; |
|
|
|
String responseStr = openService.getWxOpenComponentService().getWxMpServiceByAppid(appId).unbindOpenPlatform(appId, openAppId); |
|
|
|
logger.info(responseStr); |
|
|
|
WxOpenResult openResult = gson.fromJson(responseStr, WxOpenResult.class); |
|
|
|
if(openResult.isSuccess()) { |
|
|
|
return new ResultData(); |
|
|
|
} |
|
|
|
return new ResultData(Result.ERROR, responseStr); |
|
|
|
} catch (WxErrorException e) { |
|
|
|
logger.error(e.getMessage()); |
|
|
|
return new ResultData(Result.ERROR, e.getMessage()); |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping(value = "/getOpenPlatform") |
|
|
|
@ApiOperation("获取微信开放平台") |
|
|
|
public String getOpenPlatform(@RequestParam(value = "appId") String appId) { |
|
|
|
@ApiOperation("获取微信开放平台appId") |
|
|
|
public ResultData getOpenPlatform(@RequestParam(value = "appId") String appId) { |
|
|
|
Gson gson = new GsonBuilder().create(); |
|
|
|
try { |
|
|
|
String llstr = openService.getWxOpenComponentService().getWxMpServiceByAppid(appId).getBindOpenPlatform(appId); |
|
|
|
logger.info(llstr); |
|
|
|
return llstr; |
|
|
|
String responseStr = openService.getWxOpenComponentService().getWxMpServiceByAppid(appId).getBindOpenPlatform(appId); |
|
|
|
logger.info(responseStr); |
|
|
|
WxOpenPlatformResult openPlatformResult = gson.fromJson(responseStr, WxOpenPlatformResult.class); |
|
|
|
if(openPlatformResult.isSuccess()) { |
|
|
|
return new ResultData(openPlatformResult.getOpenAppid()); |
|
|
|
} |
|
|
|
return new ResultData(Result.ERROR, responseStr); |
|
|
|
} catch (WxErrorException e) { |
|
|
|
logger.error(e.getMessage()); |
|
|
|
return new ResultData(Result.ERROR, e.getMessage()); |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |