From d84cef8efd4b007490d229002b0e95150a7a1f64 Mon Sep 17 00:00:00 2001 From: Stormeye Wu Date: Tue, 19 Feb 2019 18:33:56 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=BE=AE=E4=BF=A1=E5=BC=80=E5=8F=91=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0][=E4=BF=AE=E6=94=B9]:=E4=BD=93=E9=AA=8C=E8=80=85?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/WechatWeappSetController.java | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/mallinkWechatOpen/src/main/java/com/iformall/controller/WechatWeappSetController.java b/mallinkWechatOpen/src/main/java/com/iformall/controller/WechatWeappSetController.java index caa9fe909..e0f11ac6d 100644 --- a/mallinkWechatOpen/src/main/java/com/iformall/controller/WechatWeappSetController.java +++ b/mallinkWechatOpen/src/main/java/com/iformall/controller/WechatWeappSetController.java @@ -1,5 +1,6 @@ package com.iformall.controller; +import com.iformall.common.ErrorCode; import com.iformall.common.Result; import com.iformall.common.ResultData; import com.iformall.service.wechat.WxOpenService; @@ -8,12 +9,14 @@ 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.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.List; +import java.util.Map; /** * Stormeye Wu @@ -96,9 +99,17 @@ public class WechatWeappSetController { return new ResultData(Result.ERROR); } - @ApiOperation(value = "绑定微信用户为小程序体验者", notes = "") + @ApiOperation(value = "绑定微信用户为小程序体验者", notes = "{\"appId\":\"string\", \"wechatId\":\"string\"}") @PostMapping("/bindTester") - public ResultData bindTester(String appId, String wechatId) { + public ResultData bindTester(@RequestBody Map params) { + String appId = params.get("appId"); + String wechatId = params.get("wechatId"); + if(StringUtils.isBlank(appId)) { + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "appId不能为空"); + } + if(StringUtils.isBlank(wechatId)) { + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "wechatId不能为空"); + } try { WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); WxOpenResult openRet = openMaService.bindTester(wechatId); @@ -112,7 +123,15 @@ public class WechatWeappSetController { @ApiOperation(value = "解除绑定小程序的体验者", notes = "") @PostMapping("/unbindTester") - public ResultData unbindTester(String appId, String wechatId) { + public ResultData unbindTester(@RequestBody Map params) { + String appId = params.get("appId"); + String wechatId = params.get("wechatId"); + if(StringUtils.isBlank(appId)) { + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "appId不能为空"); + } + if(StringUtils.isBlank(wechatId)) { + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "wechatId不能为空"); + } try { WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); WxOpenResult openRet = openMaService.unbindTester(wechatId);