|
|
@@ -7,6 +7,7 @@ import org.slf4j.LoggerFactory; |
|
|
|
|
|
|
|
import com.google.gson.JsonObject; |
|
|
|
|
|
|
|
import me.chanjar.weixin.common.bean.result.WxError; |
|
|
|
import me.chanjar.weixin.common.exception.WxErrorException; |
|
|
|
import me.chanjar.weixin.mp.api.WxMpService; |
|
|
|
import me.chanjar.weixin.mp.api.WxMpUserTagService; |
|
|
@@ -32,12 +33,12 @@ public class WxMpUserTagServiceImpl implements WxMpUserTagService { |
|
|
|
public WxUserTag tagCreate(String name) throws WxErrorException { |
|
|
|
String url = API_URL_PREFIX + "/create"; |
|
|
|
JsonObject json = new JsonObject(); |
|
|
|
JsonObject groupJson = new JsonObject(); |
|
|
|
groupJson.addProperty("name", name); |
|
|
|
json.add("tag", groupJson); |
|
|
|
JsonObject tagJson = new JsonObject(); |
|
|
|
tagJson.addProperty("name", name); |
|
|
|
json.add("tag", tagJson); |
|
|
|
|
|
|
|
String responseContent = this.wxMpService.post(url, json.toString()); |
|
|
|
this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, name, |
|
|
|
this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, json.toString(), |
|
|
|
responseContent); |
|
|
|
return WxUserTag.fromJson(responseContent); |
|
|
|
} |
|
|
@@ -51,4 +52,20 @@ public class WxMpUserTagServiceImpl implements WxMpUserTagService { |
|
|
|
responseContent); |
|
|
|
return WxUserTag.listFromJson(responseContent); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Boolean tagUpdate(Integer id, String name) throws WxErrorException { |
|
|
|
String url = API_URL_PREFIX + "/update"; |
|
|
|
|
|
|
|
JsonObject json = new JsonObject(); |
|
|
|
JsonObject tagJson = new JsonObject(); |
|
|
|
tagJson.addProperty("id", id); |
|
|
|
tagJson.addProperty("name", name); |
|
|
|
json.add("tag", tagJson); |
|
|
|
|
|
|
|
String responseContent = this.wxMpService.post(url, json.toString()); |
|
|
|
this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, json.toString(), responseContent); |
|
|
|
WxError wxError = WxError.fromJson(responseContent); |
|
|
|
return wxError.getErrorCode() == 0; |
|
|
|
} |
|
|
|
} |