2121 * @author binarywang (https://github.com/binarywang)
2222 */
2323public class WxMpStoreServiceImpl implements WxMpStoreService {
24- private static final String API_BASE_URL = "http://api.weixin.qq.com/cgi-bin/poi" ;
25-
2624 private WxMpService wxMpService ;
2725
2826 public WxMpStoreServiceImpl (WxMpService wxMpService ) {
@@ -33,8 +31,7 @@ public WxMpStoreServiceImpl(WxMpService wxMpService) {
3331 public void add (WxMpStoreBaseInfo request ) throws WxErrorException {
3432 BeanUtils .checkRequiredFields (request );
3533
36- String url = API_BASE_URL + "/addpoi" ;
37- String response = this .wxMpService .post (url , request .toJson ());
34+ String response = this .wxMpService .post (POI_ADD_URL , request .toJson ());
3835 WxError wxError = WxError .fromJson (response );
3936 if (wxError .getErrorCode () != 0 ) {
4037 throw new WxErrorException (wxError );
@@ -43,10 +40,9 @@ public void add(WxMpStoreBaseInfo request) throws WxErrorException {
4340
4441 @ Override
4542 public WxMpStoreBaseInfo get (String poiId ) throws WxErrorException {
46- String url = API_BASE_URL + "/getpoi" ;
4743 JsonObject paramObject = new JsonObject ();
4844 paramObject .addProperty ("poi_id" , poiId );
49- String response = this .wxMpService .post (url , paramObject .toString ());
45+ String response = this .wxMpService .post (POI_GET_URL , paramObject .toString ());
5046 WxError wxError = WxError .fromJson (response );
5147 if (wxError .getErrorCode () != 0 ) {
5248 throw new WxErrorException (wxError );
@@ -57,10 +53,9 @@ public WxMpStoreBaseInfo get(String poiId) throws WxErrorException {
5753
5854 @ Override
5955 public void delete (String poiId ) throws WxErrorException {
60- String url = API_BASE_URL + "/delpoi" ;
6156 JsonObject paramObject = new JsonObject ();
6257 paramObject .addProperty ("poi_id" , poiId );
63- String response = this .wxMpService .post (url , paramObject .toString ());
58+ String response = this .wxMpService .post (POI_DEL_URL , paramObject .toString ());
6459 WxError wxError = WxError .fromJson (response );
6560 if (wxError .getErrorCode () != 0 ) {
6661 throw new WxErrorException (wxError );
@@ -70,11 +65,10 @@ public void delete(String poiId) throws WxErrorException {
7065 @ Override
7166 public WxMpStoreListResult list (int begin , int limit )
7267 throws WxErrorException {
73- String url = API_BASE_URL + "/getpoilist" ;
7468 JsonObject params = new JsonObject ();
7569 params .addProperty ("begin" , begin );
7670 params .addProperty ("limit" , limit );
77- String response = this .wxMpService .post (url , params .toString ());
71+ String response = this .wxMpService .post (POI_LIST_URL , params .toString ());
7872
7973 WxError wxError = WxError .fromJson (response );
8074 if (wxError .getErrorCode () != 0 ) {
@@ -107,8 +101,7 @@ public List<WxMpStoreInfo> listAll() throws WxErrorException {
107101
108102 @ Override
109103 public void update (WxMpStoreBaseInfo request ) throws WxErrorException {
110- String url = API_BASE_URL + "/updatepoi" ;
111- String response = this .wxMpService .post (url , request .toJson ());
104+ String response = this .wxMpService .post (POI_UPDATE_URL , request .toJson ());
112105 WxError wxError = WxError .fromJson (response );
113106 if (wxError .getErrorCode () != 0 ) {
114107 throw new WxErrorException (wxError );
@@ -117,8 +110,7 @@ public void update(WxMpStoreBaseInfo request) throws WxErrorException {
117110
118111 @ Override
119112 public List <String > listCategories () throws WxErrorException {
120- String url = API_BASE_URL + "/getwxcategory" ;
121- String response = this .wxMpService .get (url , null );
113+ String response = this .wxMpService .get (POI_GET_WX_CATEGORY_URL , null );
122114 WxError wxError = WxError .fromJson (response );
123115 if (wxError .getErrorCode () != 0 ) {
124116 throw new WxErrorException (wxError );
0 commit comments