mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-05-04 04:37:46 +08:00
优化代码
This commit is contained in:
parent
113407a213
commit
d451d3b779
@ -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.bean.result.WxMpMassUploadResult;
|
||||||
import me.chanjar.weixin.mp.enums.WxMpApiUrl;
|
import me.chanjar.weixin.mp.enums.WxMpApiUrl;
|
||||||
|
|
||||||
|
import static me.chanjar.weixin.mp.enums.WxMpApiUrl.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 群发消息服务类
|
* 群发消息服务类
|
||||||
@ -26,31 +28,31 @@ public class WxMpMassMessageServiceImpl implements WxMpMassMessageService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WxMpMassUploadResult massNewsUpload(WxMpMassNews news) throws WxErrorException {
|
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);
|
return WxMpMassUploadResult.fromJson(responseContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WxMpMassUploadResult massVideoUpload(WxMpMassVideo video) throws WxErrorException {
|
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);
|
return WxMpMassUploadResult.fromJson(responseContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WxMpMassSendResult massGroupMessageSend(WxMpMassTagMessage message) throws WxErrorException {
|
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);
|
return WxMpMassSendResult.fromJson(responseContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WxMpMassSendResult massOpenIdsMessageSend(WxMpMassOpenIdsMessage message) throws WxErrorException {
|
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);
|
return WxMpMassSendResult.fromJson(responseContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WxMpMassSendResult massMessagePreview(WxMpMassPreviewMessage wxMpMassPreviewMessage) throws WxErrorException {
|
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);
|
return WxMpMassSendResult.fromJson(responseContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +61,7 @@ public class WxMpMassMessageServiceImpl implements WxMpMassMessageService {
|
|||||||
JsonObject jsonObject = new JsonObject();
|
JsonObject jsonObject = new JsonObject();
|
||||||
jsonObject.addProperty("msg_id", msgId);
|
jsonObject.addProperty("msg_id", msgId);
|
||||||
jsonObject.addProperty("article_idx", articleIndex);
|
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 按标签群发的消息
|
* 按标签群发的消息.
|
||||||
*
|
*
|
||||||
* @author chanjarster
|
* @author chanjarster
|
||||||
*/
|
*/
|
||||||
@ -16,12 +16,12 @@ public class WxMpMassTagMessage implements Serializable {
|
|||||||
private static final long serialVersionUID = -6625914040986749286L;
|
private static final long serialVersionUID = -6625914040986749286L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 标签id,如果不设置则就意味着发给所有用户
|
* 标签id,如果不设置则就意味着发给所有用户.
|
||||||
*/
|
*/
|
||||||
private Long tagId;
|
private Long tagId;
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 消息类型
|
* 消息类型.
|
||||||
* 请使用
|
* 请使用
|
||||||
* {@link WxConsts.MassMsgType#IMAGE}
|
* {@link WxConsts.MassMsgType#IMAGE}
|
||||||
* {@link WxConsts.MassMsgType#MPNEWS}
|
* {@link WxConsts.MassMsgType#MPNEWS}
|
||||||
@ -35,17 +35,17 @@ public class WxMpMassTagMessage implements Serializable {
|
|||||||
private String content;
|
private String content;
|
||||||
private String mediaId;
|
private String mediaId;
|
||||||
/**
|
/**
|
||||||
* 是否群发给所有用户
|
* 是否群发给所有用户.
|
||||||
*/
|
*/
|
||||||
private boolean isSendAll = false;
|
private boolean isSendAll = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文章被判定为转载时,是否继续进行群发操作。
|
* 文章被判定为转载时,是否继续进行群发操作.
|
||||||
*/
|
*/
|
||||||
private boolean sendIgnoreReprint = false;
|
private boolean sendIgnoreReprint = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 开发者侧群发msgid,长度限制64字节,如不填,则后台默认以群发范围和群发内容的摘要值做为clientmsgid
|
* 开发者侧群发msgid,长度限制64字节,如不填,则后台默认以群发范围和群发内容的摘要值做为clientmsgid.
|
||||||
*/
|
*/
|
||||||
private String clientMsgId;
|
private String clientMsgId;
|
||||||
|
|
||||||
|
@ -11,7 +11,9 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author someone
|
* 群发消息json转换适配器.
|
||||||
|
*
|
||||||
|
* @author chanjarster
|
||||||
*/
|
*/
|
||||||
public class WxMpMassTagMessageGsonAdapter implements JsonSerializer<WxMpMassTagMessage> {
|
public class WxMpMassTagMessageGsonAdapter implements JsonSerializer<WxMpMassTagMessage> {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user