Przeglądaj źródła

[微信开发平台][修改]:体验者添加删除

release_toaliyun_real
Stormeye Wu 7 lat temu
rodzic
commit
d84cef8efd
1 zmienionych plików z 22 dodań i 3 usunięć
  1. +22
    -3
      mallinkWechatOpen/src/main/java/com/iformall/controller/WechatWeappSetController.java

+ 22
- 3
mallinkWechatOpen/src/main/java/com/iformall/controller/WechatWeappSetController.java Wyświetl plik

@@ -1,5 +1,6 @@
package com.iformall.controller; package com.iformall.controller;


import com.iformall.common.ErrorCode;
import com.iformall.common.Result; import com.iformall.common.Result;
import com.iformall.common.ResultData; import com.iformall.common.ResultData;
import com.iformall.service.wechat.WxOpenService; 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.common.error.WxErrorException;
import me.chanjar.weixin.open.api.WxOpenMaService; import me.chanjar.weixin.open.api.WxOpenMaService;
import me.chanjar.weixin.open.bean.result.*; import me.chanjar.weixin.open.bean.result.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;


import java.util.List; import java.util.List;
import java.util.Map;


/** /**
* Stormeye Wu * Stormeye Wu
@@ -96,9 +99,17 @@ public class WechatWeappSetController {
return new ResultData(Result.ERROR); return new ResultData(Result.ERROR);
} }


@ApiOperation(value = "绑定微信用户为小程序体验者", notes = "")
@ApiOperation(value = "绑定微信用户为小程序体验者", notes = "{\"appId\":\"string\", \"wechatId\":\"string\"}")
@PostMapping("/bindTester") @PostMapping("/bindTester")
public ResultData bindTester(String appId, String wechatId) {
public ResultData bindTester(@RequestBody Map<String, String> 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 { try {
WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId);
WxOpenResult openRet = openMaService.bindTester(wechatId); WxOpenResult openRet = openMaService.bindTester(wechatId);
@@ -112,7 +123,15 @@ public class WechatWeappSetController {


@ApiOperation(value = "解除绑定小程序的体验者", notes = "") @ApiOperation(value = "解除绑定小程序的体验者", notes = "")
@PostMapping("/unbindTester") @PostMapping("/unbindTester")
public ResultData unbindTester(String appId, String wechatId) {
public ResultData unbindTester(@RequestBody Map<String, String> 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 { try {
WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId);
WxOpenResult openRet = openMaService.unbindTester(wechatId); WxOpenResult openRet = openMaService.unbindTester(wechatId);


Ładowanie…
Anuluj
Zapisz