package cn.hmsoft.weixin.request;

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

/**************************
 * @note 为用户添加备注
 * @author revisit@126.com
 * @Company: www.hmsoft.cn
 * @create 2017-05-09 01:14:01
 * @version 4.0.0
 */
public class UserRemarkRequest extends AbstractRequest<WxResponseJson, WxResponseJson, UserRemarkRequestJson> {

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

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

	public UserRemarkRequest(String open_id, String remark) {
		this.requestEntity = new UserRemarkRequestJson();
		this.requestEntity.setOpenid(open_id);
		this.requestEntity.setRemark(remark);
	}

	@Override
	public void processBusiness() {
		// 更新
		if (this.jsonEntity.getErrcode() == 0)
			SpringHelper.AppGobalDao.updateBySql("update wx_user set remark=? where open_id=? and wx_id=?",
					this.requestEntity.getRemark(), this.requestEntity.getOpenid(),this.wxDefine.getWx_id());

	}
}
