优化代码

This commit is contained in:
Binary Wang 2019-07-14 14:56:25 +08:00
parent 113407a213
commit d451d3b779
3 changed files with 17 additions and 13 deletions

View File

@ -11,6 +11,8 @@ import me.chanjar.weixin.mp.bean.result.WxMpMassSendResult;
import me.chanjar.weixin.mp.bean.result.WxMpMassUploadResult;
import me.chanjar.weixin.mp.enums.WxMpApiUrl;
import static me.chanjar.weixin.mp.enums.WxMpApiUrl.*;
/**
* <pre>
* 群发消息服务类
@ -26,31 +28,31 @@ public class WxMpMassMessageServiceImpl implements WxMpMassMessageService {
@Override
public WxMpMassUploadResult massNewsUpload(WxMpMassNews news) throws WxErrorException {
String responseContent = this.wxMpService.post(WxMpApiUrl.MassMessage.MEDIA_UPLOAD_NEWS_URL, news.toJson());
String responseContent = this.wxMpService.post(MassMessage.MEDIA_UPLOAD_NEWS_URL, news.toJson());
return WxMpMassUploadResult.fromJson(responseContent);
}
@Override
public WxMpMassUploadResult massVideoUpload(WxMpMassVideo video) throws WxErrorException {
String responseContent = this.wxMpService.post(WxMpApiUrl.MassMessage.MEDIA_UPLOAD_VIDEO_URL, video.toJson());
String responseContent = this.wxMpService.post(MassMessage.MEDIA_UPLOAD_VIDEO_URL, video.toJson());
return WxMpMassUploadResult.fromJson(responseContent);
}
@Override
public WxMpMassSendResult massGroupMessageSend(WxMpMassTagMessage message) throws WxErrorException {
String responseContent = this.wxMpService.post(WxMpApiUrl.MassMessage.MESSAGE_MASS_SENDALL_URL, message.toJson());
String responseContent = this.wxMpService.post(MassMessage.MESSAGE_MASS_SENDALL_URL, message.toJson());
return WxMpMassSendResult.fromJson(responseContent);
}
@Override
public WxMpMassSendResult massOpenIdsMessageSend(WxMpMassOpenIdsMessage message) throws WxErrorException {
String responseContent = this.wxMpService.post(WxMpApiUrl.MassMessage.MESSAGE_MASS_SEND_URL, message.toJson());
String responseContent = this.wxMpService.post(MassMessage.MESSAGE_MASS_SEND_URL, message.toJson());
return WxMpMassSendResult.fromJson(responseContent);
}
@Override
public WxMpMassSendResult massMessagePreview(WxMpMassPreviewMessage wxMpMassPreviewMessage) throws WxErrorException {
String responseContent = this.wxMpService.post(WxMpApiUrl.MassMessage.MESSAGE_MASS_PREVIEW_URL, wxMpMassPreviewMessage.toJson());
String responseContent = this.wxMpService.post(MassMessage.MESSAGE_MASS_PREVIEW_URL, wxMpMassPreviewMessage.toJson());
return WxMpMassSendResult.fromJson(responseContent);
}
@ -59,7 +61,7 @@ public class WxMpMassMessageServiceImpl implements WxMpMassMessageService {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("msg_id", msgId);
jsonObject.addProperty("article_idx", articleIndex);
this.wxMpService.post(WxMpApiUrl.MassMessage.MESSAGE_MASS_DELETE_URL, jsonObject.toString());
this.wxMpService.post(MassMessage.MESSAGE_MASS_DELETE_URL, jsonObject.toString());
}
}

View File

@ -7,7 +7,7 @@ import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
import java.io.Serializable;
/**
* 按标签群发的消息
* 按标签群发的消息.
*
* @author chanjarster
*/
@ -16,12 +16,12 @@ public class WxMpMassTagMessage implements Serializable {
private static final long serialVersionUID = -6625914040986749286L;
/**
* 标签id如果不设置则就意味着发给所有用户
* 标签id如果不设置则就意味着发给所有用户.
*/
private Long tagId;
/**
* <pre>
* 消息类型
* 消息类型.
* 请使用
* {@link WxConsts.MassMsgType#IMAGE}
* {@link WxConsts.MassMsgType#MPNEWS}
@ -35,17 +35,17 @@ public class WxMpMassTagMessage implements Serializable {
private String content;
private String mediaId;
/**
* 是否群发给所有用户
* 是否群发给所有用户.
*/
private boolean isSendAll = false;
/**
* 文章被判定为转载时是否继续进行群发操作
* 文章被判定为转载时是否继续进行群发操作.
*/
private boolean sendIgnoreReprint = false;
/**
* 开发者侧群发msgid长度限制64字节如不填则后台默认以群发范围和群发内容的摘要值做为clientmsgid
* 开发者侧群发msgid长度限制64字节如不填则后台默认以群发范围和群发内容的摘要值做为clientmsgid.
*/
private String clientMsgId;

View File

@ -11,7 +11,9 @@ import org.apache.commons.lang3.StringUtils;
import java.lang.reflect.Type;
/**
* @author someone
* 群发消息json转换适配器.
*
* @author chanjarster
*/
public class WxMpMassTagMessageGsonAdapter implements JsonSerializer<WxMpMassTagMessage> {