mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
使用lombok的@Data注解简化common模块的所有bean类
This commit is contained in:
@@ -229,10 +229,9 @@ public class WxMpCardServiceImpl implements WxMpCardService {
|
||||
String errcode = json.get("errcode").getAsString();
|
||||
if (!"0".equals(errcode)) {
|
||||
String errmsg = json.get("errmsg").getAsString();
|
||||
WxError error = new WxError();
|
||||
error.setErrorCode(Integer.valueOf(errcode));
|
||||
error.setErrorMsg(errmsg);
|
||||
throw new WxErrorException(error);
|
||||
throw new WxErrorException(WxError.builder()
|
||||
.errorCode(Integer.valueOf(errcode)).errorMsg(errmsg)
|
||||
.build());
|
||||
}
|
||||
|
||||
return responseContent;
|
||||
|
||||
@@ -112,11 +112,11 @@ public class WxMpKefuServiceImpl implements WxMpKefuService {
|
||||
@Override
|
||||
public WxMpKfMsgList kfMsgList(Date startTime, Date endTime, Long msgId, Integer number) throws WxErrorException {
|
||||
if (number > 10000) {
|
||||
throw new WxErrorException(WxError.newBuilder().setErrorMsg("非法参数请求,每次最多查询10000条记录!").build());
|
||||
throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg("非法参数请求,每次最多查询10000条记录!").build());
|
||||
}
|
||||
|
||||
if (startTime.after(endTime)) {
|
||||
throw new WxErrorException(WxError.newBuilder().setErrorMsg("起始时间不能晚于结束时间!").build());
|
||||
throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg("起始时间不能晚于结束时间!").build());
|
||||
}
|
||||
|
||||
JsonObject param = new JsonObject();
|
||||
|
||||
@@ -37,7 +37,7 @@ public class WxMpMaterialServiceImpl implements WxMpMaterialService {
|
||||
try {
|
||||
return this.mediaUpload(mediaType, FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), fileType));
|
||||
} catch (IOException e) {
|
||||
throw new WxErrorException(WxError.newBuilder().setErrorMsg(e.getMessage()).build(), e);
|
||||
throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg(e.getMessage()).build(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,13 +28,13 @@ public class WxMpQrcodeServiceImpl implements WxMpQrcodeService {
|
||||
@Override
|
||||
public WxMpQrCodeTicket qrCodeCreateTmpTicket(int sceneId, Integer expireSeconds) throws WxErrorException {
|
||||
if (sceneId == 0) {
|
||||
throw new WxErrorException(WxError.newBuilder().setErrorCode(-1).setErrorMsg("临时二维码场景值不能为0!").build());
|
||||
throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg("临时二维码场景值不能为0!").build());
|
||||
}
|
||||
|
||||
//expireSeconds 该二维码有效时间,以秒为单位。 最大不超过2592000(即30天),此字段如果不填,则默认有效期为30秒。
|
||||
if (expireSeconds != null && expireSeconds > 2592000) {
|
||||
throw new WxErrorException(WxError.newBuilder().setErrorCode(-1)
|
||||
.setErrorMsg("临时二维码有效时间最大不能超过2592000(即30天)!").build());
|
||||
throw new WxErrorException(WxError.builder().errorCode(-1)
|
||||
.errorMsg("临时二维码有效时间最大不能超过2592000(即30天)!").build());
|
||||
}
|
||||
|
||||
if (expireSeconds == null) {
|
||||
@@ -59,13 +59,13 @@ public class WxMpQrcodeServiceImpl implements WxMpQrcodeService {
|
||||
@Override
|
||||
public WxMpQrCodeTicket qrCodeCreateTmpTicket(String sceneStr, Integer expireSeconds) throws WxErrorException {
|
||||
if (StringUtils.isBlank(sceneStr)) {
|
||||
throw new WxErrorException(WxError.newBuilder().setErrorCode(-1).setErrorMsg("临时二维码场景值不能为空!").build());
|
||||
throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg("临时二维码场景值不能为空!").build());
|
||||
}
|
||||
|
||||
//expireSeconds 该二维码有效时间,以秒为单位。 最大不超过2592000(即30天),此字段如果不填,则默认有效期为30秒。
|
||||
if (expireSeconds != null && expireSeconds > 2592000) {
|
||||
throw new WxErrorException(WxError.newBuilder().setErrorCode(-1)
|
||||
.setErrorMsg("临时二维码有效时间最大不能超过2592000(即30天)!").build());
|
||||
throw new WxErrorException(WxError.builder().errorCode(-1)
|
||||
.errorMsg("临时二维码有效时间最大不能超过2592000(即30天)!").build());
|
||||
}
|
||||
|
||||
if (expireSeconds == null) {
|
||||
@@ -90,7 +90,9 @@ public class WxMpQrcodeServiceImpl implements WxMpQrcodeService {
|
||||
@Override
|
||||
public WxMpQrCodeTicket qrCodeCreateLastTicket(int sceneId) throws WxErrorException {
|
||||
if (sceneId < 1 || sceneId > 100000) {
|
||||
throw new WxErrorException(WxError.newBuilder().setErrorCode(-1).setErrorMsg("永久二维码的场景值目前只支持1--100000!").build());
|
||||
throw new WxErrorException(WxError.builder().errorCode(-1)
|
||||
.errorMsg("永久二维码的场景值目前只支持1--100000!")
|
||||
.build());
|
||||
}
|
||||
|
||||
String url = API_URL_PREFIX + "/create";
|
||||
@@ -137,9 +139,7 @@ public class WxMpQrcodeServiceImpl implements WxMpQrcodeService {
|
||||
|
||||
return resultUrl;
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
WxError error = WxError.newBuilder().setErrorCode(-1)
|
||||
.setErrorMsg(e.getMessage()).build();
|
||||
throw new WxErrorException(error);
|
||||
throw new WxErrorException(WxError.builder().errorCode(-1).errorMsg(e.getMessage()).build());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user