🆕 #2113 【公众号】增加对话能力(原导购)相关接口

This commit is contained in:
hywr
2021-05-14 21:32:25 +08:00
committed by GitHub
parent a596228a8d
commit 7359abf7c5
45 changed files with 3462 additions and 27 deletions

View File

@ -0,0 +1,94 @@
package me.chanjar.weixin.mp.api.impl;
import com.google.inject.Inject;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.bean.guide.*;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import java.util.ArrayList;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author <a href="https://www.sacoc.cn">广州跨界-宋心成</a>
* @date 2021/5/13/013
*/
@Guice(modules = ApiTestModule.class)
public class WxMpGuideBuyerServiceImplTest {
@Inject
protected WxMpService wxService;
/**
* 顾问微信号 guide_account
*/
private static final String ACCOUNT = "sxc_Warm";
@Test
public void testAddGuideBuyerRelation() throws WxErrorException {
List<WxMpAddGuideBuyerInfo> list = new ArrayList<>();
list.add(WxMpAddGuideBuyerInfo.builder().nickname("小执花").openid("oqlk8v0uTJgRnn5eEskNruD4-bc8").build());
List<WxMpGuideBuyerResp> wxMpGuideBuyerResps = this.wxService.getGuideBuyerService().addGuideBuyerRelation(ACCOUNT, null, list);
assertThat(wxMpGuideBuyerResps).isNotNull();
}
@Test
public void testAddGuideBuyerRelationOnce() throws WxErrorException {
this.wxService.getGuideBuyerService().addGuideBuyerRelation(ACCOUNT, null, "oqlk8v0uTJgRnn5eEskNruD4-bc8", "小执花");
}
@Test
public void testDelGuideBuyerRelation() throws WxErrorException {
List<String> list = new ArrayList<>();
list.add("oqlk8v0uTJgRnn5eEskNruD4-bc8");
List<WxMpGuideBuyerResp> wxMpGuideBuyerResps = this.wxService.getGuideBuyerService().delGuideBuyerRelation(ACCOUNT, null, list);
assertThat(wxMpGuideBuyerResps).isNotNull();
}
@Test
public void testDelGuideBuyerRelationOnce() throws WxErrorException {
this.wxService.getGuideBuyerService().delGuideBuyerRelation(ACCOUNT, null, "oqlk8v0uTJgRnn5eEskNruD4-bc8");
}
@Test
public void testGetGuideBuyerRelationList() throws WxErrorException {
WxMpGuideBuyerInfoList list = this.wxService.getGuideBuyerService().getGuideBuyerRelationList(ACCOUNT, null, 0, 10);
assertThat(list).isNotNull();
}
@Test
public void testRebindGuideAcctForBuyer() throws WxErrorException {
List<String> list = new ArrayList<>();
list.add("oqlk8v0uTJgRnn5eEskNruD4-bc8");
list.add("oqlk8vybPMWapMwOfFTFVYqWpGM0");
List<WxMpGuideBuyerResp> enemytriplekill = this.wxService.getGuideBuyerService().rebindGuideAcctForBuyer(ACCOUNT, null, "enemytriplekill", null, list);
assertThat(enemytriplekill).isNotNull();
}
@Test
public void testRebindGuideAcctForBuyerOnce() throws WxErrorException {
this.wxService.getGuideBuyerService().rebindGuideAcctForBuyer(ACCOUNT, null, "enemytriplekill", null, "oqlk8v0uTJgRnn5eEskNruD4-bc8");
}
@Test
public void testUpdateGuideBuyerRelation() throws WxErrorException {
this.wxService.getGuideBuyerService().updateGuideBuyerRelation(ACCOUNT, null, "oqlk8v0uTJgRnn5eEskNruD4-bc8", "微信文档有坑");
}
@Test
public void testGetGuideBuyerRelationByBuyer() throws WxErrorException {
WxMpGuideBuyerRelation guideBuyerRelationByBuyer = this.wxService.getGuideBuyerService().getGuideBuyerRelationByBuyer("oqlk8v0uTJgRnn5eEskNruD4-bc8");
assertThat(guideBuyerRelationByBuyer).isNotNull();
}
@Test
public void testGetGuideBuyerRelation() throws WxErrorException {
WxMpGuideBuyerInfo guideBuyerRelation = this.wxService.getGuideBuyerService().getGuideBuyerRelation(ACCOUNT, null, "oqlk8v0uTJgRnn5eEskNruD4-bc8");
assertThat(guideBuyerRelation).isNotNull();
}
}

View File

@ -0,0 +1,66 @@
package me.chanjar.weixin.mp.api.impl;
import com.google.inject.Inject;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.bean.guide.WxMpGuideMassed;
import me.chanjar.weixin.mp.bean.guide.WxMpGuideMassedInfo;
import me.chanjar.weixin.mp.bean.guide.WxMpGuideMaterialInfo;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import java.util.ArrayList;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author <a href="https://www.sacoc.cn">广州跨界-宋心成</a>
* @date 2021/5/13/013
*/
@Guice(modules = ApiTestModule.class)
public class WxMpGuideMassedJobServiceImplTest {
@Inject
protected WxMpService wxService;
/**
* 顾问微信号 guide_account
*/
private static final String ACCOUNT = "sxc_Warm";
@Test
public void testAddGuideMassedJob() throws WxErrorException {
List<String> userOpenId = new ArrayList<>();
userOpenId.add("oqlk8v0uTJgRnn5eEskNruD4-bc8");
List<WxMpGuideMaterialInfo> list = new ArrayList<>();
list.add(WxMpGuideMaterialInfo.builder().type(1).word("文字素材测试").build());
list.add(WxMpGuideMaterialInfo.builder().type(3).mediaId("qDrCfXeDorLgy83d8h6VzVip9s6omPXF_2ILuoke1j0sY4bSFVaA8lkGzUaznU9e").build()); //图片素材
list.add(WxMpGuideMaterialInfo.builder().type(49).mediaId("qDrCfXeDorLgy83d8h6VzVip9s6omPXF_2ILuoke1j0sY4bSFVaA8lkGzUaznU9e").title("小程序标题").path("pages/login-type/index.html").appId("wx4f793c04fd3be5a8").build()); //图片素材
WxMpGuideMassed wxMpGuideMassed = this.wxService.getGuideMassedJobService().addGuideMassedJob(ACCOUNT, null, "群发任务", "群发任务备注", System.currentTimeMillis() / 1000, userOpenId, list);
assertThat(wxMpGuideMassed).isNotNull();
}
@Test
public void testGetGuideMassedJobList() throws WxErrorException {
List<WxMpGuideMassedInfo> guideMassedJobList = this.wxService.getGuideMassedJobService().getGuideMassedJobList(ACCOUNT, null, null, null, null);
assertThat(guideMassedJobList).isNotNull();
}
@Test
public void testGetGuideMassedJob() throws WxErrorException {
WxMpGuideMassedInfo guideMassedJob = this.wxService.getGuideMassedJobService().getGuideMassedJob("1867407932930228228");
assertThat(guideMassedJob).isNotNull();
}
@Test
public void testUpdateGuideMassedJob() throws WxErrorException {
this.wxService.getGuideMassedJobService().updateGuideMassedJob("1867407932930228228", "修改群发任务", null, null, null, null);
}
@Test
public void testCancelGuideMassedJob() throws WxErrorException {
this.wxService.getGuideMassedJobService().cancelGuideMassedJob("1867407932930228228");
}
}

View File

@ -0,0 +1,87 @@
package me.chanjar.weixin.mp.api.impl;
import com.google.inject.Inject;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.bean.guide.WxMpGuideCardMaterialInfo;
import me.chanjar.weixin.mp.bean.guide.WxMpGuideImgMaterialInfoList;
import me.chanjar.weixin.mp.bean.guide.WxMpGuideWordMaterialInfoList;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import java.io.File;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author <a href="https://www.sacoc.cn">广州跨界-宋心成</a>
* @date 2021/5/13/013
*/
@Guice(modules = ApiTestModule.class)
public class WxMpGuideMaterialServiceImplTest {
@Inject
protected WxMpService wxService;
/**
* 图片路径
*/
private static final String IMG_URL = "C:\\Users\\Administrator\\Desktop\\imgText.png";
@Test
public void testSetGuideCardMaterial() throws WxErrorException {
WxMediaUploadResult wxMediaUploadResult = this.wxService.getMaterialService()
.mediaUpload(WxConsts.MediaFileType.IMAGE, new File(IMG_URL));
this.wxService.getGuideMaterialService().setGuideCardMaterial(wxMediaUploadResult.getMediaId(), 0, "小程序素材标题", "pages/login-type/index.html", "wx4f793c04fd3be5a8");
}
@Test
public void testGetGuideCardMaterial() throws WxErrorException {
List<WxMpGuideCardMaterialInfo> guideCardMaterial = this.wxService.getGuideMaterialService().getGuideCardMaterial(0);
assertThat(guideCardMaterial).isNotNull();
}
@Test
public void testDelGuideCardMaterial() throws WxErrorException {
this.wxService.getGuideMaterialService().delGuideCardMaterial(0, "小程序素材标题", "pages/login-type/index.html", "wx4f793c04fd3be5a8");
}
@Test
public void testSetGuideImageMaterial() throws WxErrorException {
WxMediaUploadResult wxMediaUploadResult = this.wxService.getMaterialService()
.mediaUpload(WxConsts.MediaFileType.IMAGE, new File(IMG_URL));
this.wxService.getGuideMaterialService().setGuideImageMaterial(wxMediaUploadResult.getMediaId(), 0);
}
@Test
public void testGetGuideImageMaterial() throws WxErrorException {
WxMpGuideImgMaterialInfoList guideImageMaterial = this.wxService.getGuideMaterialService().getGuideImageMaterial(0, 0, 20);
assertThat(guideImageMaterial).isNotNull();
}
@Test
public void testDelGuideImageMaterial() throws WxErrorException {
this.wxService.getGuideMaterialService().delGuideImageMaterial(0, "http://mmbiz.qpic.cn/mmbiz_png/63bwCoCgX0neicbffKiaL4vqXAUChYwE1VO0ZG5b6SW3Shv7kR1ia46b3gS8zf78piaR7vk7I6MRqbVzibJVJoNtkEg/0");
}
@Test
public void testSetGuideWordMaterial() throws WxErrorException {
this.wxService.getGuideMaterialService().setGuideWordMaterial(0, "文字素材测试");
}
@Test
public void testGetGuideWordMaterial() throws WxErrorException {
WxMpGuideWordMaterialInfoList guideWordMaterial = this.wxService.getGuideMaterialService().getGuideWordMaterial(0, 0, 20);
assertThat(guideWordMaterial).isNotNull();
}
@Test
public void testDelGuideWordMaterial() throws WxErrorException {
this.wxService.getGuideMaterialService().delGuideWordMaterial(0, "文字素材测试");
}
}

View File

@ -4,11 +4,13 @@ import com.google.inject.Inject;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.bean.guide.WxMpGuideInfo;
import me.chanjar.weixin.mp.bean.guide.WxMpGuideList;
import me.chanjar.weixin.mp.bean.guide.*;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import java.util.ArrayList;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
/**
@ -22,30 +24,35 @@ public class WxMpGuideServiceImplTest {
@Inject
protected WxMpService wxService;
/**
* 顾问微信号 guide_account
*/
private static final String ACCOUNT = "sxc_Warm";
@Test
public void testAddGuide() throws WxErrorException {
this.wxService.getGuideService().addGuide("wx1java", "", null, null);
this.wxService.getGuideService().addGuide(ACCOUNT, "", null, null);
}
@Test
public void testAddGuide_another() throws WxErrorException {
this.wxService.getGuideService().addGuide(WxMpGuideInfo.builder().account("wx1java").build());
this.wxService.getGuideService().addGuide(WxMpGuideInfo.builder().account(ACCOUNT).build());
}
@Test
public void testGetGuide() throws WxErrorException {
final WxMpGuideInfo guideInfo = this.wxService.getGuideService().getGuide("wx1java", null);
final WxMpGuideInfo guideInfo = this.wxService.getGuideService().getGuide(ACCOUNT, null);
assertThat(guideInfo).isNotNull();
}
@Test
public void testUpdateGuide() throws WxErrorException {
this.wxService.getGuideService().updateGuide(WxMpGuideInfo.builder().account("wx1java").nickName("我是谁").build());
this.wxService.getGuideService().updateGuide(WxMpGuideInfo.builder().account(ACCOUNT).nickName("我是谁").build());
}
@Test
public void testDelGuide() throws WxErrorException {
this.wxService.getGuideService().delGuide("wx1java", null);
this.wxService.getGuideService().delGuide(ACCOUNT, null);
}
@Test
@ -53,4 +60,92 @@ public class WxMpGuideServiceImplTest {
final WxMpGuideList guideList = this.wxService.getGuideService().listGuide(0, 10);
assertThat(guideList).isNotNull();
}
@Test
public void testCreateGuideQrCode() throws WxErrorException {
String guideQrCode = this.wxService.getGuideService().createGuideQrCode(ACCOUNT, null, null);
assertThat(guideQrCode).isNotNull();
}
@Test
public void testGetGuideChatRecord() throws WxErrorException {
final WxMpGuideMsgList guideChatRecord = this.wxService.getGuideService().getGuideChatRecord(ACCOUNT, null, null, null, null, 0, 10);
assertThat(guideChatRecord).isNotNull();
}
@Test
public void testSetGuideConfig() throws WxErrorException {
List<String> list = new ArrayList<>();
list.add("自动回复设置" + ACCOUNT);
list.add("自动回复设置" + ACCOUNT);
this.wxService.getGuideService().setGuideConfig(null, null, true, list,
WxMpAddGuideAutoReply.builder().content("欢迎测试1").msgType(1).build(),
WxMpAddGuideAutoReply.builder().content("欢迎测试2").msgType(1).build());
}
@Test
public void testGetGuideConfig() throws WxErrorException {
final WxMpGuideConfig guideConfig = this.wxService.getGuideService().getGuideConfig(ACCOUNT, null);
assertThat(guideConfig).isNotNull();
}
@Test
public void testSetGuideAcctConfig() throws WxErrorException {
List<String> list = new ArrayList<>();
list.add("敏感词1");
list.add("敏感词2");
this.wxService.getGuideService().setGuideAcctConfig(false, list, "离线自动回复");
}
@Test
public void testGetGuideAcctConfig() throws WxErrorException {
final WxMpGuideAcctConfig guideAcctConfig = this.wxService.getGuideService().getGuideAcctConfig();
assertThat(guideAcctConfig).isNotNull();
}
@Test
public void testPushShowWxaPathMenu() throws WxErrorException {
this.wxService.getGuideService().pushShowWxaPathMenu("wx4f793c04fd3be5a8", ACCOUNT);
}
@Test
public void testNewGuideGroup() throws WxErrorException {
Long id = this.wxService.getGuideService().newGuideGroup("顾问分组名称");
assertThat(id).isNotNull();
}
@Test
public void testGetGuideGroup() throws WxErrorException {
List<WxMpGuideGroup> guideGroupList = this.wxService.getGuideService().getGuideGroupList();
assertThat(guideGroupList).isNotNull();
}
@Test
public void testGetGroupInfo() throws WxErrorException {
WxMpGuideGroupInfoList groupInfo = this.wxService.getGuideService().getGroupInfo(1860131524965138433L, 0, 10);
assertThat(groupInfo).isNotNull();
}
@Test
public void testAddGuide2GuideGroup() throws WxErrorException {
this.wxService.getGuideService().addGuide2GuideGroup(1860131524965138433L, ACCOUNT);
}
@Test
public void testDelGuide2GuideGroup() throws WxErrorException {
this.wxService.getGuideService().delGuide2GuideGroup(1860131524965138433L, ACCOUNT);
}
@Test
public void testGetGroupByGuide() throws WxErrorException {
List<Long> groupByGuide = this.wxService.getGuideService().getGroupByGuide(ACCOUNT);
assertThat(groupByGuide).isNotNull();
}
@Test
public void testDelGuideGroup() throws WxErrorException {
this.wxService.getGuideService().delGuideGroup(1860131524965138433L);
}
}

View File

@ -0,0 +1,115 @@
package me.chanjar.weixin.mp.api.impl;
import com.google.inject.Inject;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.test.ApiTestModule;
import me.chanjar.weixin.mp.bean.guide.WxMpGuideBuyerResp;
import me.chanjar.weixin.mp.bean.guide.WxMpGuideTagInfo;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import java.util.ArrayList;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author <a href="https://www.sacoc.cn">广州跨界-宋心成</a>
* @date 2021/5/13/013
*/
@Guice(modules = ApiTestModule.class)
public class WxMpGuideTagServiceImplTest {
@Inject
protected WxMpService wxService;
/**
* 顾问微信号 guide_account
*/
private static final String ACCOUNT = "sxc_Warm";
@Test
public void testNewGuideTagOption() throws WxErrorException {
List<String> list = new ArrayList<>();
list.add("分类一");
list.add("分类二");
list.add("分类三");
this.wxService.getGuideTagService().newGuideTagOption("A组", list);
}
@Test
public void testDelGuideTagOption() throws WxErrorException {
this.wxService.getGuideTagService().delGuideTagOption("A组");
}
@Test
public void testAddGuideTagOption() throws WxErrorException {
List<String> list = new ArrayList<>();
list.add("分类四");
this.wxService.getGuideTagService().addGuideTagOption("A组", list);
}
@Test
public void testGetGuideTagOption() throws WxErrorException {
List<WxMpGuideTagInfo> guideTagOption = this.wxService.getGuideTagService().getGuideTagOption();
assertThat(guideTagOption).isNotNull();
}
@Test
public void testAddGuideBuyerTag() throws WxErrorException {
List<String> list = new ArrayList<>();
list.add("oqlk8v0uTJgRnn5eEskNruD4-bc8");
list.add("oqlk8vybPMWapMwOfFTFVYqWpGM0");
List<WxMpGuideBuyerResp> wxMpGuideBuyerResps = this.wxService.getGuideTagService().addGuideBuyerTag(ACCOUNT, null, "分类一", list);
assertThat(wxMpGuideBuyerResps).isNotNull();
}
@Test
public void testAddGuideBuyerTagOnce() throws WxErrorException {
this.wxService.getGuideTagService().addGuideBuyerTag(ACCOUNT, null, "分类二", "oqlk8v0uTJgRnn5eEskNruD4-bc8");
}
@Test
public void testGetGuideBuyerTag() throws WxErrorException {
List<String> guideBuyerTag = this.wxService.getGuideTagService().getGuideBuyerTag(ACCOUNT, null, "oqlk8v0uTJgRnn5eEskNruD4-bc8", true);
assertThat(guideBuyerTag).isNotNull();
}
@Test
public void testQueryGuideBuyerByTag() throws WxErrorException {
List<String> list = new ArrayList<>();
list.add("分类一");
List<String> list1 = this.wxService.getGuideTagService().queryGuideBuyerByTag(ACCOUNT, null, 0, list);
assertThat(list1).isNotNull();
}
@Test
public void testdelGuideBuyerTag() throws WxErrorException {
List<String> list = new ArrayList<>();
list.add("oqlk8v0uTJgRnn5eEskNruD4-bc8");
list.add("oqlk8vybPMWapMwOfFTFVYqWpGM0");
List<WxMpGuideBuyerResp> respList = this.wxService.getGuideTagService().delGuideBuyerTag(ACCOUNT, null, "分类一", list);
assertThat(respList).isNotNull();
}
@Test
public void testDelGuideBuyerTagOnce() throws WxErrorException {
this.wxService.getGuideTagService().delGuideBuyerTag(ACCOUNT, null, "分类一", "oqlk8v0uTJgRnn5eEskNruD4-bc8");
}
@Test
public void testAddGuideBuyerDisplayTag() throws WxErrorException {
List<String> list = new ArrayList<>();
list.add("自定义信息1");
list.add("自定义信息2");
this.wxService.getGuideTagService().addGuideBuyerDisplayTag(ACCOUNT, null, "oqlk8v0uTJgRnn5eEskNruD4-bc8", list);
}
@Test
public void testGetGuideBuyerDisplayTag() throws WxErrorException {
List<String> list = this.wxService.getGuideTagService().getGuideBuyerDisplayTag(ACCOUNT, null, "oqlk8v0uTJgRnn5eEskNruD4-bc8");
assertThat(list).isNotNull();
}
}