Skip to content

Commit

Permalink
Merge pull request #224 from rememberber/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
rememberber committed Sep 28, 2019
2 parents 7404942 + fb68c58 commit 65ac607
Show file tree
Hide file tree
Showing 30 changed files with 1,782 additions and 184 deletions.
2 changes: 2 additions & 0 deletions download.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<details>
<summary>Windows</summary>

[WePush-v4.0.0_190928-x64-Setup.exe](http://download.zhoubochina.com/exe/WePush-v4.0.0_190928-x64-Setup.exe)
[WePush-v3.9.0_190915-x64-Setup.exe](http://download.zhoubochina.com/exe/WePush-v3.9.0_190915-x64-Setup.exe)
[WePush-v3.8.0_190909-x64-Setup.exe](http://download.zhoubochina.com/exe/WePush-v3.8.0_190909-x64-Setup.exe)
[WePush-v3.7.0_190904-x64-Setup.exe](http://download.zhoubochina.com/exe/WePush-v3.7.0_190904-x64-Setup.exe)
Expand Down Expand Up @@ -111,6 +112,7 @@
<details>
<summary>Linux</summary>

[v4.0.0_190928](http://download.zhoubochina.com/linux/WePush-4.0.0.zip)
[v3.9.0_190915](http://download.zhoubochina.com/linux/WePush-3.9.0.zip)
[v3.8.0_190909](http://download.zhoubochina.com/linux/WePush-3.8.0.zip)
[v3.7.0_190904](http://download.zhoubochina.com/linux/WePush-3.7.0.zip)
Expand Down
10 changes: 9 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
<quartz.version>2.3.1</quartz.version>
<okhttp.version>4.0.1</okhttp.version>
<aliyun-java-sdk-dysmsapi.version>1.1.0</aliyun-java-sdk-dysmsapi.version>
<bce-java-sdk.version>0.10.75</bce-java-sdk.version>
<qiniu-java-sdk.version>7.2.25</qiniu-java-sdk.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -306,7 +308,7 @@
<dependency>
<groupId>com.baidubce</groupId>
<artifactId>bce-java-sdk</artifactId>
<version>0.10.75</version>
<version>${bce-java-sdk.version}</version>
<exclusions>
<exclusion>
<artifactId>slf4j-api</artifactId>
Expand Down Expand Up @@ -387,6 +389,12 @@
</exclusions>
</dependency>

<dependency>
<groupId>com.qiniu</groupId>
<artifactId>qiniu-java-sdk</artifactId>
<version>${qiniu-java-sdk.version}</version>
</dependency>

</dependencies>

<build>
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/fangxuele/tool/push/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public class App {

public static SqlSession sqlSession = MybatisUtil.getSqlSession();

public static SystemTray tray;

public static TrayIcon trayIcon;

public static void main(String[] args) {
Init.initTheme();
mainFrame = new MainFrame();
Expand All @@ -53,5 +57,6 @@ public static void main(String[] args) {
mainFrame.addListeners();
mainFrame.remove(loadingPanel);
Init.initFontSize();
Init.initTray();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public enum MessageTypeEnum {
WX_CP(12, "微信企业号/企业微信"),
HTTP(13, "HTTP请求"),
DING(14, "钉钉"),
BD_YUN(15, "百度云短信");
BD_YUN(15, "百度云短信"),
QI_NIU_YUN(16, "七牛云短信");

private int code;

Expand All @@ -45,6 +46,7 @@ public enum MessageTypeEnum {
public static final int HTTP_CODE = 13;
public static final int DING_CODE = 14;
public static final int BD_YUN_CODE = 15;
public static final int QI_NIU_YUN_CODE = 16;

MessageTypeEnum(int code, String name) {
this.code = code;
Expand Down Expand Up @@ -96,6 +98,9 @@ public static String getName(int code) {
case 15:
name = BD_YUN.name;
break;
case 16:
name = QI_NIU_YUN.name;
break;
default:
name = "";
}
Expand Down
35 changes: 35 additions & 0 deletions src/main/java/com/fangxuele/tool/push/logic/PushControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,20 @@ public static boolean configCheck() {
case MessageTypeEnum.MP_TEMPLATE_CODE:
case MessageTypeEnum.KEFU_CODE:
case MessageTypeEnum.KEFU_PRIORITY_CODE: {
if (App.config.isMpUseOutSideAt()) {
if (App.config.isMpManualAt() &&
(StringUtils.isEmpty(App.config.getMpAt()) || StringUtils.isEmpty(App.config.getMpAtExpiresIn()))) {
JOptionPane.showMessageDialog(settingForm.getSettingPanel(), "请先在设置中填写并保存手动输入的外部accessToken信息!", "提示",
JOptionPane.INFORMATION_MESSAGE);
return false;
}
if (App.config.isMpApiAt() && StringUtils.isEmpty(App.config.getMpAtApiUrl())) {
JOptionPane.showMessageDialog(settingForm.getSettingPanel(), "请先在设置中填写并保存用于获取外部accessToken的URL!", "提示",
JOptionPane.INFORMATION_MESSAGE);
return false;
}
return true;
}
if (StringUtils.isEmpty(App.config.getWechatAppId()) || StringUtils.isEmpty(App.config.getWechatAppSecret())) {
JOptionPane.showMessageDialog(settingForm.getSettingPanel(), "请先在设置中填写并保存公众号相关配置!", "提示",
JOptionPane.INFORMATION_MESSAGE);
Expand Down Expand Up @@ -186,6 +200,27 @@ public static boolean configCheck() {
return false;
}
break;
case MessageTypeEnum.QI_NIU_YUN_CODE:
String qiniuAccessKey = App.config.getQiniuAccessKey();
String qiniuSecretKey = App.config.getQiniuSecretKey();

if (StringUtils.isEmpty(qiniuAccessKey) || StringUtils.isEmpty(qiniuSecretKey)) {
JOptionPane.showMessageDialog(settingForm.getSettingPanel(),
"请先在设置中填写并保存七牛云短信相关配置!", "提示",
JOptionPane.INFORMATION_MESSAGE);
return false;
}
break;
case MessageTypeEnum.UP_YUN_CODE:
String upAuthorizationToken = App.config.getUpAuthorizationToken();

if (StringUtils.isEmpty(upAuthorizationToken)) {
JOptionPane.showMessageDialog(settingForm.getSettingPanel(),
"请先在设置中填写并保存又拍云短信相关配置!", "提示",
JOptionPane.INFORMATION_MESSAGE);
return false;
}
break;
case MessageTypeEnum.BD_YUN_CODE:
String bdAccessKeyId = App.config.getBdAccessKeyId();
String bdSecretAccessKey = App.config.getBdSecretAccessKey();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
import com.fangxuele.tool.push.logic.msgthread.BaseMsgThread;
import com.fangxuele.tool.push.logic.msgthread.MsgSendThread;
import com.fangxuele.tool.push.ui.component.TableInCellProgressBarRenderer;
import com.fangxuele.tool.push.ui.form.MessageEditForm;
import com.fangxuele.tool.push.ui.form.PushForm;
import com.fangxuele.tool.push.util.ConsoleUtil;
import org.apache.commons.lang3.time.DateFormatUtils;

import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import java.awt.*;
import java.io.IOException;
import java.util.Date;
import java.util.concurrent.ThreadPoolExecutor;
Expand Down Expand Up @@ -178,6 +180,13 @@ private void timeMonitor() {
pushForm.getScheduleRunButton().setEnabled(true);
pushForm.getScheduleRunButton().updateUI();
pushForm.getScheduleDetailLabel().setText("");

if (App.trayIcon != null) {
MessageEditForm messageEditForm = MessageEditForm.getInstance();
String msgName = messageEditForm.getMsgNameField().getText();
App.trayIcon.displayMessage("WePush", msgName + " 发送完毕!", TrayIcon.MessageType.INFO);
}

String finishTip = "发送完毕!\n";
JOptionPane.showMessageDialog(pushForm.getPushPanel(), finishTip, "提示",
JOptionPane.INFORMATION_MESSAGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public void prepare() {
public Map<String, String> makeMsg(String[] msgData) {

VelocityContext velocityContext = getVelocityContext(msgData);
for (Map.Entry<String, String> stringStringEntry : paramMap.entrySet()) {
stringStringEntry.setValue(TemplateUtil.evaluate(stringStringEntry.getValue(), velocityContext));
for (Map.Entry<String, String> entry : paramMap.entrySet()) {
entry.setValue(TemplateUtil.evaluate(entry.getValue(), velocityContext));
}
return paramMap;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ public static IMsgMaker getMsgMaker() {
case MessageTypeEnum.BD_YUN_CODE:
iMsgMaker = new BdYunMsgMaker();
break;
case MessageTypeEnum.UP_YUN_CODE:
iMsgMaker = new UpYunMsgMaker();
break;
case MessageTypeEnum.QI_NIU_YUN_CODE:
iMsgMaker = new QiNiuYunMsgMaker();
break;
default:
}
return iMsgMaker;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.fangxuele.tool.push.logic.msgmaker;

import com.fangxuele.tool.push.ui.form.msg.QiNiuYunMsgForm;
import com.fangxuele.tool.push.util.TemplateUtil;
import com.google.common.collect.Maps;
import org.apache.velocity.VelocityContext;

import javax.swing.table.DefaultTableModel;
import java.util.Map;

/**
* <pre>
* 七牛云模板短信加工器
* </pre>
*
* @author <a href="https://github.com/rememberber">Zhou Bo</a>
* @since 2019/6/14.
*/
public class QiNiuYunMsgMaker extends BaseMsgMaker implements IMsgMaker {

public static String templateId;

public static Map<String, String> paramMap;

/**
* 准备(界面字段等)
*/
@Override
public void prepare() {
templateId = QiNiuYunMsgForm.getInstance().getMsgTemplateIdTextField().getText();

if (QiNiuYunMsgForm.getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) {
QiNiuYunMsgForm.initTemplateDataTable();
}

DefaultTableModel tableModel = (DefaultTableModel) QiNiuYunMsgForm.getInstance().getTemplateMsgDataTable().getModel();
int rowCount = tableModel.getRowCount();
paramMap = Maps.newHashMap();
for (int i = 0; i < rowCount; i++) {
String key = ((String) tableModel.getValueAt(i, 0));
String value = ((String) tableModel.getValueAt(i, 1));
paramMap.put(key, value);
}
}

/**
* 组织七牛云短信消息
*
* @param msgData 消息信息
* @return String[]
*/
@Override
public Map<String, String> makeMsg(String[] msgData) {

VelocityContext velocityContext = getVelocityContext(msgData);
for (Map.Entry<String, String> entry : paramMap.entrySet()) {
entry.setValue(TemplateUtil.evaluate(entry.getValue(), velocityContext));
}
return paramMap;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.fangxuele.tool.push.logic.msgmaker;

import com.fangxuele.tool.push.ui.form.msg.UpYunMsgForm;
import com.fangxuele.tool.push.util.TemplateUtil;
import org.apache.commons.compress.utils.Lists;
import org.apache.velocity.VelocityContext;

import javax.swing.table.DefaultTableModel;
import java.util.List;

/**
* <pre>
* 又拍云模板短信加工器
* </pre>
*
* @author <a href="https://github.com/rememberber">Zhou Bo</a>
* @since 2019/6/14.
*/
public class UpYunMsgMaker extends BaseMsgMaker implements IMsgMaker{

public static String templateId;

public static List<String> paramList;

/**
* 准备(界面字段等)
*/
@Override
public void prepare() {
templateId = UpYunMsgForm.getInstance().getMsgTemplateIdTextField().getText();

if (UpYunMsgForm.getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) {
UpYunMsgForm.initTemplateDataTable();
}

DefaultTableModel tableModel = (DefaultTableModel) UpYunMsgForm.getInstance().getTemplateMsgDataTable().getModel();
int rowCount = tableModel.getRowCount();
paramList = Lists.newArrayList();
for (int i = 0; i < rowCount; i++) {
String value = ((String) tableModel.getValueAt(i, 1));
paramList.add(value);
}
}

/**
* 组织又拍云短信消息
*
* @param msgData 消息信息
* @return String[]
*/
@Override
public String[] makeMsg(String[] msgData) {

VelocityContext velocityContext = getVelocityContext(msgData);
for (int i = 0; i < paramList.size(); i++) {
paramList.set(i, TemplateUtil.evaluate(paramList.get(i), velocityContext));
}
String[] paramArray = new String[paramList.size()];
return paramList.toArray(paramArray);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ public static IMsgSender getMsgSender() {
case MessageTypeEnum.BD_YUN_CODE:
iMsgSender = new BdYunMsgSender();
break;
case MessageTypeEnum.UP_YUN_CODE:
iMsgSender = new UpYunMsgSender();
break;
case MessageTypeEnum.QI_NIU_YUN_CODE:
iMsgSender = new QiNiuYunMsgSender();
break;
default:
break;
}
Expand Down
Loading

0 comments on commit 65ac607

Please sign in to comment.