| @@ -0,0 +1,83 @@ | |||
| package com.iformall.controller; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.service.wechat.WxOpenService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import me.chanjar.weixin.common.error.WxErrorException; | |||
| import me.chanjar.weixin.open.api.WxOpenMaService; | |||
| import me.chanjar.weixin.open.bean.result.*; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.GetMapping; | |||
| import org.springframework.web.bind.annotation.PostMapping; | |||
| import org.springframework.web.bind.annotation.RequestMapping; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| import java.util.List; | |||
| /** | |||
| * Stormeye Wu | |||
| */ | |||
| @RestController | |||
| @RequestMapping("/weappSet") | |||
| @Api(description = "微信第三方开发平台-小程序设置") | |||
| public class WechatWeappSetController { | |||
| private final Logger logger = LoggerFactory.getLogger(getClass()); | |||
| @Autowired | |||
| private WxOpenService openService; | |||
| @ApiOperation("获取小程序服务器域名") | |||
| @GetMapping("/getDomain") | |||
| public ResultData modifyDomain(String appId) { | |||
| try { | |||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||
| WxOpenResult openRet = openMaService.getDomain(); | |||
| logger.info(openRet.toString()); | |||
| return new ResultData(openRet); | |||
| } catch (WxErrorException e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| return new ResultData(Result.ERROR); | |||
| } | |||
| @ApiOperation(value = "设置小程序服务器域名", notes = "{\n" + | |||
| " \"action\":\"add\",\n" + | |||
| " \"requestdomain\":[\"https://www.qq.com\",\"https://www.qq.com\"],\n" + | |||
| " \"wsrequestdomain\":[\"wss://www.qq.com\",\"wss://www.qq.com\"],\n" + | |||
| " \"uploaddomain\":[\"https://www.qq.com\",\"https://www.qq.com\"],\n" + | |||
| " \"downloaddomain\":[\"https://www.qq.com\",\"https://www.qq.com\"],\n" + | |||
| " }") | |||
| @PostMapping("/modifyDomain") | |||
| public ResultData modifyDomain(String appId, String action, | |||
| List<String> requestDomain, List<String> wsrequestdomain, | |||
| List<String> uploaddomain, List<String> downloaddomain) { | |||
| try { | |||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||
| WxOpenMaDomainResult openRet = openMaService.modifyDomain(action, | |||
| requestDomain, wsrequestdomain, | |||
| uploaddomain, downloaddomain); | |||
| logger.info(openRet.toString()); | |||
| return new ResultData(openRet); | |||
| } catch (WxErrorException e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| return new ResultData(Result.ERROR); | |||
| } | |||
| @ApiOperation(value = "设置小程序业务域名", notes = "extInfo参考https://mp.weixin.qq.com/debug/wxadoc/dev/framework/config.html") | |||
| @PostMapping("/setWebViewDomain") | |||
| public ResultData setWebViewDomain(String appId, String action, List<String> urlList) { | |||
| try { | |||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||
| String openRet = openMaService.setWebViewDomain(action, urlList); | |||
| logger.info(openRet.toString()); | |||
| return new ResultData(openRet); | |||
| } catch (WxErrorException e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| return new ResultData(Result.ERROR); | |||
| } | |||
| } | |||