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);