77
88import com .google .gson .JsonObject ;
99
10+ import me .chanjar .weixin .common .bean .result .WxError ;
1011import me .chanjar .weixin .common .exception .WxErrorException ;
1112import me .chanjar .weixin .mp .api .WxMpService ;
1213import me .chanjar .weixin .mp .api .WxMpUserTagService ;
@@ -32,12 +33,12 @@ public WxMpUserTagServiceImpl(WxMpService wxMpService) {
3233 public WxUserTag tagCreate (String name ) throws WxErrorException {
3334 String url = API_URL_PREFIX + "/create" ;
3435 JsonObject json = new JsonObject ();
35- JsonObject groupJson = new JsonObject ();
36- groupJson .addProperty ("name" , name );
37- json .add ("tag" , groupJson );
36+ JsonObject tagJson = new JsonObject ();
37+ tagJson .addProperty ("name" , name );
38+ json .add ("tag" , tagJson );
3839
3940 String responseContent = this .wxMpService .post (url , json .toString ());
40- this .log .debug ("\n url:{}\n params:{}\n response:{}" , url , name ,
41+ this .log .debug ("\n url:{}\n params:{}\n response:{}" , url , json . toString () ,
4142 responseContent );
4243 return WxUserTag .fromJson (responseContent );
4344 }
@@ -51,4 +52,20 @@ public List<WxUserTag> tagGet() throws WxErrorException {
5152 responseContent );
5253 return WxUserTag .listFromJson (responseContent );
5354 }
55+
56+ @ Override
57+ public Boolean tagUpdate (Integer id , String name ) throws WxErrorException {
58+ String url = API_URL_PREFIX + "/update" ;
59+
60+ JsonObject json = new JsonObject ();
61+ JsonObject tagJson = new JsonObject ();
62+ tagJson .addProperty ("id" , id );
63+ tagJson .addProperty ("name" , name );
64+ json .add ("tag" , tagJson );
65+
66+ String responseContent = this .wxMpService .post (url , json .toString ());
67+ this .log .debug ("\n url:{}\n params:{}\n response:{}" , url , json .toString (), responseContent );
68+ WxError wxError = WxError .fromJson (responseContent );
69+ return wxError .getErrorCode () == 0 ;
70+ }
5471}
0 commit comments