com.zopen.wechat.mp.dto.BaseResponse Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of zopen-ato-starter Show documentation
Show all versions of zopen-ato-starter Show documentation
Alibaba Tencent And Others For Spring Boot.
package com.zopen.wechat.mp.dto;
import com.zcj.util.UtilString;
import com.zopen.wechat.exception.WechatException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* 微信公众号接口返回的基类
*
* @author [email protected]
* @since 2019/8/26
*/
public class BaseResponse {
private static final Logger logger = LoggerFactory.getLogger(BaseResponse.class);
private Integer errcode;
private String errmsg;
public boolean success() {
return errcode == null || errcode.equals(0);
}
public void valid(String message) {
if (!success()) {
StringBuilder sb = new StringBuilder();
sb.append(UtilString.isNotBlank(message) ? message : "请求微信接口失败");
sb.append("{ errcode:" + errcode + ",errmsg:" + errmsg + " }");
String errorInfo = sb.toString();
logger.error(errorInfo);
throw new WechatException(errorInfo);
}
}
public Integer getErrcode() {
return errcode;
}
public void setErrcode(Integer errcode) {
this.errcode = errcode;
}
public String getErrmsg() {
return errmsg;
}
public void setErrmsg(String errmsg) {
this.errmsg = errmsg;
}
}