|
|
@@ -21,8 +21,6 @@ import java.util.List; |
|
|
|
* @author binarywang (https://github.com/binarywang) |
|
|
|
*/ |
|
|
|
public class WxMpStoreServiceImpl implements WxMpStoreService { |
|
|
|
private static final String API_BASE_URL = "http://api.weixin.qq.com/cgi-bin/poi"; |
|
|
|
|
|
|
|
private WxMpService wxMpService; |
|
|
|
|
|
|
|
public WxMpStoreServiceImpl(WxMpService wxMpService) { |
|
|
@@ -33,8 +31,7 @@ public class WxMpStoreServiceImpl implements WxMpStoreService { |
|
|
|
public void add(WxMpStoreBaseInfo request) throws WxErrorException { |
|
|
|
BeanUtils.checkRequiredFields(request); |
|
|
|
|
|
|
|
String url = API_BASE_URL + "/addpoi"; |
|
|
|
String response = this.wxMpService.post(url, request.toJson()); |
|
|
|
String response = this.wxMpService.post(POI_ADD_URL, request.toJson()); |
|
|
|
WxError wxError = WxError.fromJson(response); |
|
|
|
if (wxError.getErrorCode() != 0) { |
|
|
|
throw new WxErrorException(wxError); |
|
|
@@ -43,10 +40,9 @@ public class WxMpStoreServiceImpl implements WxMpStoreService { |
|
|
|
|
|
|
|
@Override |
|
|
|
public WxMpStoreBaseInfo get(String poiId) throws WxErrorException { |
|
|
|
String url = API_BASE_URL + "/getpoi"; |
|
|
|
JsonObject paramObject = new JsonObject(); |
|
|
|
paramObject.addProperty("poi_id", poiId); |
|
|
|
String response = this.wxMpService.post(url, paramObject.toString()); |
|
|
|
String response = this.wxMpService.post(POI_GET_URL, paramObject.toString()); |
|
|
|
WxError wxError = WxError.fromJson(response); |
|
|
|
if (wxError.getErrorCode() != 0) { |
|
|
|
throw new WxErrorException(wxError); |
|
|
@@ -57,10 +53,9 @@ public class WxMpStoreServiceImpl implements WxMpStoreService { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void delete(String poiId) throws WxErrorException { |
|
|
|
String url = API_BASE_URL + "/delpoi"; |
|
|
|
JsonObject paramObject = new JsonObject(); |
|
|
|
paramObject.addProperty("poi_id", poiId); |
|
|
|
String response = this.wxMpService.post(url, paramObject.toString()); |
|
|
|
String response = this.wxMpService.post(POI_DEL_URL, paramObject.toString()); |
|
|
|
WxError wxError = WxError.fromJson(response); |
|
|
|
if (wxError.getErrorCode() != 0) { |
|
|
|
throw new WxErrorException(wxError); |
|
|
@@ -70,11 +65,10 @@ public class WxMpStoreServiceImpl implements WxMpStoreService { |
|
|
|
@Override |
|
|
|
public WxMpStoreListResult list(int begin, int limit) |
|
|
|
throws WxErrorException { |
|
|
|
String url = API_BASE_URL + "/getpoilist"; |
|
|
|
JsonObject params = new JsonObject(); |
|
|
|
params.addProperty("begin", begin); |
|
|
|
params.addProperty("limit", limit); |
|
|
|
String response = this.wxMpService.post(url, params.toString()); |
|
|
|
String response = this.wxMpService.post(POI_LIST_URL, params.toString()); |
|
|
|
|
|
|
|
WxError wxError = WxError.fromJson(response); |
|
|
|
if (wxError.getErrorCode() != 0) { |
|
|
@@ -107,8 +101,7 @@ public class WxMpStoreServiceImpl implements WxMpStoreService { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void update(WxMpStoreBaseInfo request) throws WxErrorException { |
|
|
|
String url = API_BASE_URL + "/updatepoi"; |
|
|
|
String response = this.wxMpService.post(url, request.toJson()); |
|
|
|
String response = this.wxMpService.post(POI_UPDATE_URL, request.toJson()); |
|
|
|
WxError wxError = WxError.fromJson(response); |
|
|
|
if (wxError.getErrorCode() != 0) { |
|
|
|
throw new WxErrorException(wxError); |
|
|
@@ -117,8 +110,7 @@ public class WxMpStoreServiceImpl implements WxMpStoreService { |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<String> listCategories() throws WxErrorException { |
|
|
|
String url = API_BASE_URL + "/getwxcategory"; |
|
|
|
String response = this.wxMpService.get(url, null); |
|
|
|
String response = this.wxMpService.get(POI_GET_WX_CATEGORY_URL, null); |
|
|
|
WxError wxError = WxError.fromJson(response); |
|
|
|
if (wxError.getErrorCode() != 0) { |
|
|
|
throw new WxErrorException(wxError); |
|
|
|