Skip to content

Commit

Permalink
Merge pull request #121 from rememberber/develop
Browse files Browse the repository at this point in the history
release:3.1.0
  • Loading branch information
rememberber authored May 25, 2019
2 parents 79c4227 + 9a655af commit ca61b8a
Show file tree
Hide file tree
Showing 53 changed files with 2,501 additions and 1,318 deletions.
6 changes: 5 additions & 1 deletion src/main/java/com/fangxuele/tool/push/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import com.fangxuele.tool.push.ui.form.LoadingForm;
import com.fangxuele.tool.push.ui.form.MainWindow;
import com.fangxuele.tool.push.ui.frame.MainFrame;
import com.fangxuele.tool.push.util.ConfigUtil;
import com.fangxuele.tool.push.util.MybatisUtil;
import com.fangxuele.tool.push.util.UpgradeUtil;
import org.apache.ibatis.session.SqlSession;

import javax.swing.*;
Expand All @@ -20,16 +22,18 @@
public class App {
public static MainFrame mainFrame;

public static ConfigUtil config = ConfigUtil.getInstance();

public static SqlSession sqlSession = MybatisUtil.getSqlSession();

public static void main(String[] args) {
UpgradeUtil.smoothUpgrade();
Init.initTheme();
mainFrame = new MainFrame();
mainFrame.init();
JPanel loadingPanel = new LoadingForm().getLoadingPanel();
mainFrame.add(loadingPanel);
mainFrame.pack();
mainFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);
mainFrame.setVisible(true);

SwingUtilities.invokeLater(() -> {
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/com/fangxuele/tool/push/dao/TWxAccountMapper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.fangxuele.tool.push.dao;

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

import java.util.List;

public interface TWxAccountMapper {
int deleteByPrimaryKey(Integer id);

int insert(TWxAccount record);

int insertSelective(TWxAccount record);

TWxAccount selectByPrimaryKey(Integer id);

int updateByPrimaryKeySelective(TWxAccount record);

int updateByPrimaryKey(TWxAccount record);

List<TWxAccount> selectByAccountTypeAndAccountName(@Param("accountType") String accountType, @Param("accountName") String accountName);

List<TWxAccount> selectByAccountType(String wxAccountType);
}
97 changes: 97 additions & 0 deletions src/main/java/com/fangxuele/tool/push/domain/TWxAccount.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package com.fangxuele.tool.push.domain;

import java.io.Serializable;

public class TWxAccount implements Serializable {
private Integer id;

private String accountType;

private String accountName;

private String appId;

private String appSecret;

private String token;

private String aesKey;

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 String getAccountType() {
return accountType;
}

public void setAccountType(String accountType) {
this.accountType = accountType == null ? null : accountType.trim();
}

public String getAccountName() {
return accountName;
}

public void setAccountName(String accountName) {
this.accountName = accountName == null ? null : accountName.trim();
}

public String getAppId() {
return appId;
}

public void setAppId(String appId) {
this.appId = appId == null ? null : appId.trim();
}

public String getAppSecret() {
return appSecret;
}

public void setAppSecret(String appSecret) {
this.appSecret = appSecret == null ? null : appSecret.trim();
}

public String getToken() {
return token;
}

public void setToken(String token) {
this.token = token == null ? null : token.trim();
}

public String getAesKey() {
return aesKey;
}

public void setAesKey(String aesKey) {
this.aesKey = aesKey == null ? null : aesKey.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
@@ -1,6 +1,6 @@
package com.fangxuele.tool.push.logic;

import com.fangxuele.tool.push.ui.Init;
import com.fangxuele.tool.push.App;
import com.fangxuele.tool.push.ui.form.PushForm;
import com.taobao.api.DefaultTaobaoClient;
import com.taobao.api.TaobaoClient;
Expand Down Expand Up @@ -33,9 +33,9 @@ public void run() {
// 初始化当前线程
initCurrentThread();

String aliServerUrl = Init.config.getAliServerUrl();
String aliAppKey = Init.config.getAliAppKey();
String aliAppSecret = Init.config.getAliAppSecret();
String aliServerUrl = App.config.getAliServerUrl();
String aliAppKey = App.config.getAliAppKey();
String aliAppSecret = App.config.getAliAppSecret();

TaobaoClient client = new DefaultTaobaoClient(aliServerUrl, aliAppKey, aliAppSecret);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.profile.IClientProfile;
import com.fangxuele.tool.push.ui.Init;
import com.fangxuele.tool.push.App;
import com.fangxuele.tool.push.ui.form.PushForm;

/**
Expand Down Expand Up @@ -35,8 +35,8 @@ public void run() {
// 初始化当前线程
initCurrentThread();

String aliyunAccessKeyId = Init.config.getAliyunAccessKeyId();
String aliyunAccessKeySecret = Init.config.getAliyunAccessKeySecret();
String aliyunAccessKeyId = App.config.getAliyunAccessKeyId();
String aliyunAccessKeySecret = App.config.getAliyunAccessKeySecret();

//初始化acsClient,暂不支持region化
IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", aliyunAccessKeyId, aliyunAccessKeySecret);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ public void run() {
* 初始化当前线程
*/
void initCurrentThread() {
PushManage.console("线程" + this.getName() + "负责处理:" + startIndex + "-" +
endIndex + "的分片数据");
PushManage.console("线程" + this.getName() + "负责处理第:" + startIndex + "-" +
endIndex + "条的数据");

list = PushData.toSendList.subList(startIndex, endIndex);

Expand All @@ -105,7 +105,7 @@ void initCurrentThread() {
*/
void currentThreadFinish() {
PushManage.console(this.getName() + "已处理完第" + startIndex + "-" +
endIndex + "页的数据");
endIndex + "条的数据");

PushData.increaseStopedThread();
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/fangxuele/tool/push/logic/MessageMaker.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import cn.hutool.json.JSONUtil;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
import com.aliyuncs.http.MethodType;
import com.fangxuele.tool.push.ui.Init;
import com.fangxuele.tool.push.App;
import com.fangxuele.tool.push.ui.form.MessageEditForm;
import com.fangxuele.tool.push.util.TemplateUtil;
import com.taobao.api.request.AlibabaAliqinFcSmsNumSendRequest;
Expand Down Expand Up @@ -163,7 +163,7 @@ synchronized static SendSmsRequest makeAliyunMessage(String[] msgData) {
//使用post提交
request.setMethod(MethodType.POST);
//必填:短信签名-可在短信控制台中找到
request.setSignName(Init.config.getAliyunSign());
request.setSignName(App.config.getAliyunSign());

// 模板参数
Map<String, String> paramMap = new HashMap<String, String>();
Expand Down Expand Up @@ -233,7 +233,7 @@ synchronized static AlibabaAliqinFcSmsNumSendRequest makeAliTemplateMessage(Stri

// 短信签名,传入的短信签名必须是在阿里大鱼“管理中心-短信签名管理”中的可用签名。如“阿里大鱼”已在短信签名管理中通过审核,
// 则可传入”阿里大鱼“(传参时去掉引号)作为短信签名。短信效果示例:【阿里大鱼】欢迎使用阿里大鱼服务。
request.setSmsFreeSignName(Init.config.getAliSign());
request.setSmsFreeSignName(App.config.getAliSign());
// 短信模板ID,传入的模板必须是在阿里大鱼“管理中心-短信模板管理”中的可用模板。示例:SMS_585014
request.setSmsTemplateCode(MessageEditForm.messageEditForm.getMsgTemplateIdTextField().getText());

Expand Down
46 changes: 23 additions & 23 deletions src/main/java/com/fangxuele/tool/push/logic/PushManage.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.profile.IClientProfile;
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.ui.Init;
import com.fangxuele.tool.push.ui.form.MessageEditForm;
import com.fangxuele.tool.push.ui.form.PushForm;
import com.fangxuele.tool.push.ui.form.PushHisForm;
Expand Down Expand Up @@ -88,7 +88,7 @@ public static boolean preview() throws Exception {
msgDataList.add(data.split(MemberListener.TXT_FILE_DATA_SEPERATOR_REGEX));
}

switch (Init.config.getMsgType()) {
switch (App.config.getMsgType()) {
case MessageTypeEnum.MP_TEMPLATE_CODE:
WxMpTemplateMessage wxMessageTemplate;
WxMpService wxMpService = getWxMpService();
Expand Down Expand Up @@ -153,8 +153,8 @@ public static boolean preview() throws Exception {
}
break;
case MessageTypeEnum.ALI_YUN_CODE:
String aliyunAccessKeyId = Init.config.getAliyunAccessKeyId();
String aliyunAccessKeySecret = Init.config.getAliyunAccessKeySecret();
String aliyunAccessKeyId = App.config.getAliyunAccessKeyId();
String aliyunAccessKeySecret = App.config.getAliyunAccessKeySecret();

if (StringUtils.isEmpty(aliyunAccessKeyId) || StringUtils.isEmpty(aliyunAccessKeySecret)) {
JOptionPane.showMessageDialog(SettingForm.settingForm.getSettingPanel(),
Expand All @@ -180,8 +180,8 @@ public static boolean preview() throws Exception {
}
break;
case MessageTypeEnum.TX_YUN_CODE:
String txyunAppId = Init.config.getTxyunAppId();
String txyunAppKey = Init.config.getTxyunAppKey();
String txyunAppId = App.config.getTxyunAppId();
String txyunAppKey = App.config.getTxyunAppKey();

if (StringUtils.isEmpty(txyunAppId) || StringUtils.isEmpty(txyunAppKey)) {
JOptionPane.showMessageDialog(SettingForm.settingForm.getSettingPanel(),
Expand All @@ -196,16 +196,16 @@ public static boolean preview() throws Exception {
String[] params = MessageMaker.makeTxyunMessage(msgData);
SmsSingleSenderResult result = ssender.sendWithParam("86", msgData[0],
Integer.valueOf(MessageEditForm.messageEditForm.getMsgTemplateIdTextField().getText()),
params, Init.config.getAliyunSign(), "", "");
params, App.config.getAliyunSign(), "", "");
if (result.result != 0) {
throw new Exception(result.toString());
}
}
break;
case MessageTypeEnum.ALI_TEMPLATE_CODE:
String aliServerUrl = Init.config.getAliServerUrl();
String aliAppKey = Init.config.getAliAppKey();
String aliAppSecret = Init.config.getAliAppSecret();
String aliServerUrl = App.config.getAliServerUrl();
String aliAppKey = App.config.getAliAppKey();
String aliAppSecret = App.config.getAliAppSecret();

if (StringUtils.isEmpty(aliServerUrl) || StringUtils.isEmpty(aliAppKey)
|| StringUtils.isEmpty(aliAppSecret)) {
Expand All @@ -227,7 +227,7 @@ public static boolean preview() throws Exception {
}
break;
case MessageTypeEnum.YUN_PIAN_CODE:
String yunpianApiKey = Init.config.getYunpianApiKey();
String yunpianApiKey = App.config.getYunpianApiKey();

if (StringUtils.isEmpty(yunpianApiKey)) {
JOptionPane.showMessageDialog(SettingForm.settingForm.getSettingPanel(),
Expand Down Expand Up @@ -260,7 +260,7 @@ public static boolean preview() throws Exception {
* @return WxMpConfigStorage
*/
private static WxMpInMemoryConfigStorage wxMpConfigStorage() {
if (StringUtils.isEmpty(Init.config.getWechatAppId()) || StringUtils.isEmpty(Init.config.getWechatAppSecret())) {
if (StringUtils.isEmpty(App.config.getWechatAppId()) || StringUtils.isEmpty(App.config.getWechatAppSecret())) {
JOptionPane.showMessageDialog(SettingForm.settingForm.getSettingPanel(), "请先在设置中填写并保存公众号相关配置!", "提示",
JOptionPane.INFORMATION_MESSAGE);
PushForm.pushForm.getScheduleRunButton().setEnabled(true);
Expand All @@ -270,10 +270,10 @@ private static WxMpInMemoryConfigStorage wxMpConfigStorage() {
return null;
}
WxMpInMemoryConfigStorage configStorage = new WxMpInMemoryConfigStorage();
configStorage.setAppId(Init.config.getWechatAppId());
configStorage.setSecret(Init.config.getWechatAppSecret());
configStorage.setToken(Init.config.getWechatToken());
configStorage.setAesKey(Init.config.getWechatAesKey());
configStorage.setAppId(App.config.getWechatAppId());
configStorage.setSecret(App.config.getWechatAppSecret());
configStorage.setToken(App.config.getWechatToken());
configStorage.setAesKey(App.config.getWechatAesKey());
return configStorage;
}

Expand All @@ -284,8 +284,8 @@ private static WxMpInMemoryConfigStorage wxMpConfigStorage() {
*/
private static WxMaInMemoryConfig wxMaConfigStorage() {
WxMaInMemoryConfig configStorage = new WxMaInMemoryConfig();
if (StringUtils.isEmpty(Init.config.getMiniAppAppId()) || StringUtils.isEmpty(Init.config.getMiniAppAppSecret())
|| StringUtils.isEmpty(Init.config.getMiniAppToken()) || StringUtils.isEmpty(Init.config.getMiniAppAesKey())) {
if (StringUtils.isEmpty(App.config.getMiniAppAppId()) || StringUtils.isEmpty(App.config.getMiniAppAppSecret())
|| StringUtils.isEmpty(App.config.getMiniAppToken()) || StringUtils.isEmpty(App.config.getMiniAppAesKey())) {
JOptionPane.showMessageDialog(SettingForm.settingForm.getSettingPanel(), "请先在设置中填写并保存小程序相关配置!", "提示",
JOptionPane.INFORMATION_MESSAGE);
PushForm.pushForm.getScheduleRunButton().setEnabled(true);
Expand All @@ -294,10 +294,10 @@ private static WxMaInMemoryConfig wxMaConfigStorage() {
PushForm.pushForm.getPushTotalProgressBar().setIndeterminate(false);
return null;
}
configStorage.setAppid(Init.config.getMiniAppAppId());
configStorage.setSecret(Init.config.getMiniAppAppSecret());
configStorage.setToken(Init.config.getMiniAppToken());
configStorage.setAesKey(Init.config.getMiniAppAesKey());
configStorage.setAppid(App.config.getMiniAppAppId());
configStorage.setSecret(App.config.getMiniAppAppSecret());
configStorage.setToken(App.config.getMiniAppToken());
configStorage.setAesKey(App.config.getMiniAppAesKey());
configStorage.setMsgDataFormat("JSON");
return configStorage;
}
Expand Down Expand Up @@ -364,7 +364,7 @@ static void savePushData() throws IOException {
String msgName = MessageEditForm.messageEditForm.getMsgNameField().getText();
String nowTime = DateUtil.now().replace(":", "_").replace(" ", "_");
CSVWriter writer;
int msgType = Init.config.getMsgType();
int msgType = App.config.getMsgType();
String now = SqliteUtil.nowDateForSqlite();

// 保存已发送
Expand Down
Loading

0 comments on commit ca61b8a

Please sign in to comment.