From 421b3a29abe2f549dcf379ea695bef86594f1ade Mon Sep 17 00:00:00 2001 From: Stormeye Wu Date: Mon, 24 Dec 2018 22:43:45 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=BE=AE=E4=BF=A1=E7=AC=AC=E4=B8=89=E6=96=B9?= =?UTF-8?q?=E5=BC=80=E6=94=BE=E5=B9=B3=E5=8F=B0][=E6=96=B0=E5=A2=9E]:?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=B0=8F=E7=A8=8B=E5=BA=8F=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=99=A8=E5=9F=9F=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/WechatWeappSetController.java | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 mallinkAdmin/src/main/java/com/iformall/controller/WechatWeappSetController.java diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/WechatWeappSetController.java b/mallinkAdmin/src/main/java/com/iformall/controller/WechatWeappSetController.java new file mode 100644 index 000000000..9cd821a2d --- /dev/null +++ b/mallinkAdmin/src/main/java/com/iformall/controller/WechatWeappSetController.java @@ -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 requestDomain, List wsrequestdomain, + List uploaddomain, List 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 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); + } +}