Skip to content

Commit

Permalink
Merge pull request #184 from rememberber/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
rememberber committed Jul 21, 2019
2 parents 899473c + 47e5535 commit bd02fee
Show file tree
Hide file tree
Showing 93 changed files with 5,120 additions and 1,651 deletions.
4 changes: 4 additions & 0 deletions download.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<details>
<summary>Windows</summary>

[WePush-v3.6.0_190721-x64-Setup.exe](http://download.zhoubochina.com/exe/WePush-v3.6.0_190721-x64-Setup.exe)
[WePush-with-jre-v3.6.0_190721-x64-Setup.exe](http://download.zhoubochina.com/exe/WePush-with-jre-v3.6.0_190721-x64-Setup.exe)
[WePush-v3.5.0_190713-x64-Setup.exe](http://download.zhoubochina.com/exe/WePush-v3.5.0_190713-x64-Setup.exe)
[WePush-with-jre-v3.5.0_190713-x64-Setup.exe](http://download.zhoubochina.com/exe/WePush-with-jre-v3.5.0_190713-x64-Setup.exe)
[WePush-v3.4.2_190630-x64-Setup.exe](http://download.zhoubochina.com/exe/WePush-v3.4.2_190630-x64-Setup.exe)
Expand Down Expand Up @@ -61,6 +63,7 @@
<details>
<summary>Mac OS</summary>

[v_3.6.0_190721.app](http://download.zhoubochina.com/mac/3.6.0.zip)
[v_3.5.0_190713.app](http://download.zhoubochina.com/mac/3.5.0.zip)
[v_3.4.1_190624.app](http://download.zhoubochina.com/mac/3.4.1.zip)
[v_3.4.2_190630.app](http://download.zhoubochina.com/mac/3.4.2.zip)
Expand Down Expand Up @@ -98,6 +101,7 @@
<details>
<summary>Linux</summary>

[v3.6.0_190721](http://download.zhoubochina.com/linux/WePush-3.6.0.zip)
[v3.5.0_190713](http://download.zhoubochina.com/linux/WePush-3.5.0.zip)
[v3.4.2_190630](http://download.zhoubochina.com/linux/WePush-3.4.2.zip)
[v3.4.1_190624](http://download.zhoubochina.com/linux/WePush-3.4.1.zip)
Expand Down
37 changes: 37 additions & 0 deletions src/main/java/com/fangxuele/tool/push/bean/HttpMsg.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.fangxuele.tool.push.bean;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.io.Serializable;
import java.net.HttpCookie;
import java.util.List;
import java.util.Map;

/**
* <pre>
* HttpMsg
* </pre>
*
* @author <a href="https://github.com/rememberber">Zhou Bo</a>
* @since 2019/7/18.
*/
@Getter
@Setter
@ToString
public class HttpMsg implements Serializable {

private static final long serialVersionUID = 114436270588113296L;

private String url;

private String body;

private Map<String, Object> paramMap;

private Map<String, Object> headerMap;

private List<HttpCookie> cookies;

}
2 changes: 2 additions & 0 deletions src/main/java/com/fangxuele/tool/push/bean/MailMsg.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
@ToString
public class MailMsg implements Serializable {

private static final long serialVersionUID = 7269816872586216264L;

/**
* 标题
*/
Expand Down
26 changes: 26 additions & 0 deletions src/main/java/com/fangxuele/tool/push/dao/TMsgHttpMapper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.fangxuele.tool.push.dao;

import com.fangxuele.tool.push.domain.TMsgHttp;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface TMsgHttpMapper {
int deleteByPrimaryKey(Integer id);

int insert(TMsgHttp record);

int insertSelective(TMsgHttp record);

TMsgHttp selectByPrimaryKey(Integer id);

int updateByPrimaryKeySelective(TMsgHttp record);

int updateByPrimaryKey(TMsgHttp record);

List<TMsgHttp> selectByMsgTypeAndMsgName(@Param("msgType") int msgType, @Param("msgName") String msgName);

int updateByMsgTypeAndMsgName(TMsgHttp tMsgHttp);

List<TMsgHttp> selectByMsgType(int msgType);
}
117 changes: 117 additions & 0 deletions src/main/java/com/fangxuele/tool/push/domain/TMsgHttp.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
package com.fangxuele.tool.push.domain;

import java.io.Serializable;

public class TMsgHttp implements Serializable {
private Integer id;

private Integer msgType;

private String msgName;

private String method;

private String url;

private String params;

private String headers;

private String cookies;

private String body;

private String createTime;

private String modifiedTime;

private static final long serialVersionUID = 1L;

public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

public Integer getMsgType() {
return msgType;
}

public void setMsgType(Integer msgType) {
this.msgType = msgType;
}

public String getMsgName() {
return msgName;
}

public void setMsgName(String msgName) {
this.msgName = msgName == null ? null : msgName.trim();
}

public String getMethod() {
return method;
}

public void setMethod(String method) {
this.method = method == null ? null : method.trim();
}

public String getUrl() {
return url;
}

public void setUrl(String url) {
this.url = url == null ? null : url.trim();
}

public String getParams() {
return params;
}

public void setParams(String params) {
this.params = params == null ? null : params.trim();
}

public String getHeaders() {
return headers;
}

public void setHeaders(String headers) {
this.headers = headers == null ? null : headers.trim();
}

public String getCookies() {
return cookies;
}

public void setCookies(String cookies) {
this.cookies = cookies == null ? null : cookies.trim();
}

public String getBody() {
return body;
}

public void setBody(String body) {
this.body = body == null ? null : body.trim();
}

public String getCreateTime() {
return createTime;
}

public void setCreateTime(String createTime) {
this.createTime = createTime == null ? null : createTime.trim();
}

public String getModifiedTime() {
return modifiedTime;
}

public void setModifiedTime(String modifiedTime) {
this.modifiedTime = modifiedTime == null ? null : modifiedTime.trim();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private void preparePushRun() {

// 拷贝准备的目标用户
PushData.toSendList.addAll(PushData.allUser);
PushData.toSendCount.set(PushData.allUser.size());
PushData.TO_SEND_COUNT.set(PushData.allUser.size());
// 总记录数
PushData.totalRecords = PushData.toSendList.size();

Expand Down Expand Up @@ -117,7 +117,7 @@ private void timeMonitor() {
long startTimeMillis = System.currentTimeMillis();
// 计时
while (true) {
if (PushData.toSendCount.get() <= PushData.successRecords.longValue() + PushData.failRecords.longValue()) {
if (PushData.TO_SEND_COUNT.get() <= PushData.successRecords.longValue() + PushData.failRecords.longValue()) {
if (!PushData.fixRateScheduling) {
BoostForm.boostForm.getStopButton().setEnabled(false);
BoostForm.boostForm.getStopButton().updateUI();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public enum MessageTypeEnum {
UP_YUN(9, "又拍云短信"),
HW_YUN(10, "华为云短信"),
EMAIL(11, "E-Mail"),
WX_CP(12, "微信企业号/企业微信");
WX_CP(12, "微信企业号/企业微信"),
HTTP(13, "HTTP请求");

private int code;

Expand All @@ -41,6 +42,7 @@ public enum MessageTypeEnum {
public static final int HW_YUN_CODE = 10;
public static final int EMAIL_CODE = 11;
public static final int WX_CP_CODE = 12;
public static final int HTTP_CODE = 13;

MessageTypeEnum(int code, String name) {
this.code = code;
Expand Down Expand Up @@ -86,6 +88,9 @@ public static String getName(int code) {
case 12:
name = WX_CP.name;
break;
case 13:
name = HTTP.name;
break;
default:
}
return name;
Expand Down
74 changes: 27 additions & 47 deletions src/main/java/com/fangxuele/tool/push/logic/PushControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,11 @@
import cn.hutool.core.date.BetweenFormater;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.json.JSONUtil;
import com.fangxuele.tool.push.App;
import com.fangxuele.tool.push.dao.TPushHistoryMapper;
import com.fangxuele.tool.push.domain.TPushHistory;
import com.fangxuele.tool.push.logic.msgmaker.AliTemplateMsgMaker;
import com.fangxuele.tool.push.logic.msgmaker.AliyunMsgMaker;
import com.fangxuele.tool.push.logic.msgmaker.MailMsgMaker;
import com.fangxuele.tool.push.logic.msgmaker.TxYunMsgMaker;
import com.fangxuele.tool.push.logic.msgmaker.WxCpMsgMaker;
import com.fangxuele.tool.push.logic.msgmaker.WxKefuMsgMaker;
import com.fangxuele.tool.push.logic.msgmaker.WxMaTemplateMsgMaker;
import com.fangxuele.tool.push.logic.msgmaker.WxMpTemplateMsgMaker;
import com.fangxuele.tool.push.logic.msgmaker.YunPianMsgMaker;
import com.fangxuele.tool.push.logic.msgmaker.MsgMakerFactory;
import com.fangxuele.tool.push.logic.msgsender.IMsgSender;
import com.fangxuele.tool.push.logic.msgsender.MailMsgSender;
import com.fangxuele.tool.push.logic.msgsender.MsgSenderFactory;
Expand All @@ -32,6 +25,7 @@
import com.fangxuele.tool.push.util.SqliteUtil;
import com.fangxuele.tool.push.util.SystemUtil;
import com.opencsv.CSVWriter;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;

Expand All @@ -43,6 +37,7 @@
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
* <pre>
Expand All @@ -59,6 +54,8 @@ public class PushControl {
*/
public static boolean dryRun;

public volatile static boolean saveResponseBody = false;

private static TPushHistoryMapper pushHistoryMapper = MybatisUtil.getSqlSession().getMapper(TPushHistoryMapper.class);

/**
Expand Down Expand Up @@ -109,7 +106,12 @@ public static boolean pushCheck() {
return false;
}
if (PushData.allUser == null || PushData.allUser.size() == 0) {
JOptionPane.showMessageDialog(MainWindow.mainWindow.getMainPanel(), "请先准备目标用户!", "提示",
int msgType = App.config.getMsgType();
String tipsTitle = "请先准备目标用户!";
if (msgType == MessageTypeEnum.HTTP_CODE) {
tipsTitle = "请先准备消息变量!";
}
JOptionPane.showMessageDialog(MainWindow.mainWindow.getMainPanel(), tipsTitle, "提示",
JOptionPane.INFORMATION_MESSAGE);

return false;
Expand Down Expand Up @@ -262,10 +264,22 @@ static void savePushData() throws IOException {

// 保存未发送
for (String[] str : PushData.sendSuccessList) {
PushData.toSendList.remove(str);
if (msgType == MessageTypeEnum.HTTP_CODE && PushControl.saveResponseBody) {
str = ArrayUtils.remove(str, str.length - 1);
String[] finalStr = str;
PushData.toSendList = PushData.toSendList.stream().filter(strings -> !JSONUtil.toJsonStr(strings).equals(JSONUtil.toJsonStr(finalStr))).collect(Collectors.toList());
} else {
PushData.toSendList.remove(str);
}
}
for (String[] str : PushData.sendFailList) {
PushData.toSendList.remove(str);
if (msgType == MessageTypeEnum.HTTP_CODE && PushControl.saveResponseBody) {
str = ArrayUtils.remove(str, str.length - 1);
String[] finalStr = str;
PushData.toSendList = PushData.toSendList.stream().filter(strings -> !JSONUtil.toJsonStr(strings).equals(JSONUtil.toJsonStr(finalStr))).collect(Collectors.toList());
} else {
PushData.toSendList.remove(str);
}
}

if (PushData.toSendList.size() > 0) {
Expand Down Expand Up @@ -366,41 +380,7 @@ private static void savePushResult(String msgName, String resultInfo, File file)
* 准备消息构造器
*/
static void prepareMsgMaker() {
int msgType = App.config.getMsgType();
switch (msgType) {
case MessageTypeEnum.MP_TEMPLATE_CODE:
WxMpTemplateMsgMaker.prepare();
break;
case MessageTypeEnum.MA_TEMPLATE_CODE:
WxMaTemplateMsgMaker.prepare();
break;
case MessageTypeEnum.KEFU_CODE:
WxKefuMsgMaker.prepare();
break;
case MessageTypeEnum.KEFU_PRIORITY_CODE:
WxKefuMsgMaker.prepare();
WxMpTemplateMsgMaker.prepare();
break;
case MessageTypeEnum.ALI_YUN_CODE:
AliyunMsgMaker.prepare();
break;
case MessageTypeEnum.ALI_TEMPLATE_CODE:
AliTemplateMsgMaker.prepare();
break;
case MessageTypeEnum.TX_YUN_CODE:
TxYunMsgMaker.prepare();
break;
case MessageTypeEnum.YUN_PIAN_CODE:
YunPianMsgMaker.prepare();
break;
case MessageTypeEnum.EMAIL_CODE:
MailMsgMaker.prepare();
break;
case MessageTypeEnum.WX_CP_CODE:
WxCpMsgMaker.prepare();
break;
default:
}
MsgMakerFactory.getMsgMaker().prepare();
}

/**
Expand Down
Loading

0 comments on commit bd02fee

Please sign in to comment.