#516 增加获取Wi-Fi门店列表接口

This commit is contained in:
Binary Wang 2018-06-10 22:26:42 +08:00
parent fa6fe78f8b
commit ba7905a205
6 changed files with 193 additions and 0 deletions

View File

@ -415,6 +415,13 @@ public interface WxMpService {
*/ */
WxMpAiOpenService getAiOpenService(); WxMpAiOpenService getAiOpenService();
/**
* 返回WIFI接口方法的实现类对象以方便调用其各个接口
*
* @return WxMpWifiService
*/
WxMpWifiService getWifiService();
void setKefuService(WxMpKefuService kefuService); void setKefuService(WxMpKefuService kefuService);
void setMaterialService(WxMpMaterialService materialService); void setMaterialService(WxMpMaterialService materialService);

View File

@ -0,0 +1,28 @@
package me.chanjar.weixin.mp.api;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.bean.wifi.WxMpWifiShopListResult;
/**
* <pre>
* 微信连接WI-FI接口.
* Created by BinaryWang on 2018/6/10.
* </pre>
*
* @author <a href="https://github.com/binarywang">Binary Wang</a>
*/
public interface WxMpWifiService {
/**
* <pre>
* 获取Wi-Fi门店列表.
* 通过此接口获取WiFi的门店列表该列表包括公众平台的门店信息以及添加设备后的WiFi相关信息创建门店方法请参考微信门店接口
* 微信连Wi-Fi下的所有接口中的shop_id必需先通过此接口获取
*
* http请求方式: POST
* 请求URLhttps://api.weixin.qq.com/bizwifi/shop/list?access_token=ACCESS_TOKEN
* </pre>
* @param pageIndex 分页下标默认从1开始
* @param pageSize 每页的个数默认10个最大20个
*/
WxMpWifiShopListResult listShop(int pageIndex, int pageSize) throws WxErrorException;
}

View File

@ -53,6 +53,7 @@ public abstract class BaseWxMpServiceImpl<H, P> implements WxMpService, RequestH
private WxMpMemberCardService memberCardService = new WxMpMemberCardServiceImpl(this); private WxMpMemberCardService memberCardService = new WxMpMemberCardServiceImpl(this);
private WxMpMassMessageService massMessageService = new WxMpMassMessageServiceImpl(this); private WxMpMassMessageService massMessageService = new WxMpMassMessageServiceImpl(this);
private WxMpAiOpenService aiOpenService = new WxMpAiOpenServiceImpl(this); private WxMpAiOpenService aiOpenService = new WxMpAiOpenServiceImpl(this);
private WxMpWifiService wifiService = new WxMpWifiServiceImpl(this);
private int retrySleepMillis = 1000; private int retrySleepMillis = 1000;
private int maxRetryTimes = 5; private int maxRetryTimes = 5;
@ -501,4 +502,9 @@ public abstract class BaseWxMpServiceImpl<H, P> implements WxMpService, RequestH
public void setAiOpenService(WxMpAiOpenService aiOpenService) { public void setAiOpenService(WxMpAiOpenService aiOpenService) {
this.aiOpenService = aiOpenService; this.aiOpenService = aiOpenService;
} }
@Override
public WxMpWifiService getWifiService() {
return this.wifiService;
}
} }

View File

@ -0,0 +1,31 @@
package me.chanjar.weixin.mp.api.impl;
import com.google.gson.JsonObject;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.WxMpWifiService;
import me.chanjar.weixin.mp.bean.wifi.WxMpWifiShopListResult;
/**
* <pre>
* Created by BinaryWang on 2018/6/10.
* </pre>
*
* @author <a href="https://github.com/binarywang">Binary Wang</a>
*/
public class WxMpWifiServiceImpl implements WxMpWifiService {
private WxMpService wxMpService;
public WxMpWifiServiceImpl(WxMpService wxMpService) {
this.wxMpService = wxMpService;
}
@Override
public WxMpWifiShopListResult listShop(int pageIndex, int pageSize) throws WxErrorException {
JsonObject json = new JsonObject();
json.addProperty("pageindex", pageIndex);
json.addProperty("pagesize", pageSize);
final String result = this.wxMpService.post("https://api.weixin.qq.com/bizwifi/shop/list", json.toString());
return WxMpWifiShopListResult.fromJson(result);
}
}

View File

@ -0,0 +1,90 @@
package me.chanjar.weixin.mp.bean.wifi;
import com.google.gson.JsonParser;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
import java.util.List;
/**
* <pre>
* Created by BinaryWang on 2018/6/10.
* </pre>
*
* @author <a href="https://github.com/binarywang">Binary Wang</a>
*/
@Data
public class WxMpWifiShopListResult {
public static WxMpWifiShopListResult fromJson(String json) {
return WxMpGsonBuilder.create().fromJson(
new JsonParser().parse(json).getAsJsonObject().get("data"),
WxMpWifiShopListResult.class);
}
/**
* 总数
*/
@SerializedName("totalcount")
private int totalCount;
/**
* 分页下标
*/
@SerializedName("pageindex")
private int pageIndex;
/**
* 分页页数
*/
@SerializedName("pagecount")
private int pageCount;
private List<Record> records;
@Data
public static class Record {
/**
* 门店ID适用于微信连Wi-Fi业务
*/
@SerializedName("shop_id")
private Integer shopId;
/**
* 门店名称
*/
@SerializedName("shop_name")
private String shopName;
/**
* 无线网络设备的ssid未添加设备为空多个ssid时显示第一个
*/
@SerializedName("ssid")
private String ssid;
/**
* 无线网络设备的ssid列表返回数组格式
*/
@SerializedName("ssid_list")
private List<String> ssidList;
/**
* 门店内设备的设备类型0-未添加设备1-专业型设备4-密码型设备5-portal自助型设备31-portal改造型设备
*/
@SerializedName("protocol_type")
private Integer protocolType;
/**
* 商户自己的id与门店poi_id对应关系建议在添加门店时候建立关联关系具体请参考微信门店接口
*/
@SerializedName("sid")
private String sid;
/**
* 门店ID适用于微信卡券微信门店业务具体定义参考微信门店与shop_id一一对应
*/
@SerializedName("poi_id")
private String poiId;
}
}

View File

@ -0,0 +1,31 @@
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.wifi.WxMpWifiShopListResult;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import static org.testng.Assert.*;
/**
* <pre>
* Created by BinaryWang on 2018/6/10.
* </pre>
*
* @author <a href="https://github.com/binarywang">Binary Wang</a>
*/
@Test
@Guice(modules = ApiTestModule.class)
public class WxMpWifiServiceImplTest {
@Inject
private WxMpService wxService;
@Test
public void testListShop() throws WxErrorException {
final WxMpWifiShopListResult result = this.wxService.getWifiService().listShop(1, 2);
System.out.println(result);
}
}