package cn.hmsoft.weixin.request;

import cn.hmsoft.application.SpringHelper;
import cn.hmsoft.weixin.entity.request.TagUpdateRequestJson;
import cn.hmsoft.weixin.entity.response.WxResponseJson;

/**************************************
 * @note 删除一个标签
 * @author revisit@126.com
 * @Company: www.hmsoft.cn
 * @create 2017-05-09 00:50:21
 * @version 4.0.0
 */
public class TagDeleteRequest extends AbstractRequest<WxResponseJson, WxResponseJson, TagUpdateRequestJson> {

	private final static String url = "https://api.weixin.qq.com/cgi-bin/tags/delete?";

	/********************************
	 * 删除一个标签
	 * 
	 * @param tag_id
	 *            标签编号
	 */
	public TagDeleteRequest(int tag_id) {
		this.requestEntity = new TagUpdateRequestJson();
		TagUpdateRequestJson.Tag tg = requestEntity.new Tag();
		tg.setId(tag_id);
		requestEntity.setTag(tg);

	}

	@Override
	protected String makeUrl() {
		this.method = "POST";
		return url + "access_token=" + this.wxDefine.getApp_accesstoken();
	}

	@Override
	public void processBusiness() {
		this.returnEntity = this.jsonEntity;
		if (returnEntity.getErrcode() == 0)
			SpringHelper.AppGobalDao.delete(this.requestEntity.getTag().getId());
	}

}
