Skip to content

Commit

Permalink
Merge pull request #234 from rememberber/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
rememberber authored Nov 29, 2019
2 parents 26e1970 + 6b68188 commit cdaaaf3
Show file tree
Hide file tree
Showing 44 changed files with 1,072 additions and 82 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

<java.version>1.8</java.version>
<logback.version>1.2.3</logback.version>
<weixin-java-mp.version>3.5.0</weixin-java-mp.version>
<weixin-java-cp.version>3.5.0</weixin-java-cp.version>
<weixin-java-miniapp.version>3.5.0</weixin-java-miniapp.version>
<weixin-java-mp.version>3.6.0</weixin-java-mp.version>
<weixin-java-cp.version>3.6.0</weixin-java-cp.version>
<weixin-java-miniapp.version>3.6.0</weixin-java-miniapp.version>
<emoji-java.version>4.0.0</emoji-java.version>
<hutool-all.version>4.6.2</hutool-all.version>
<opencsv.version>4.6</opencsv.version>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.fangxuele.tool.push.dao;

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

import java.util.List;

public interface TMsgMaSubscribeMapper {
int deleteByPrimaryKey(Integer id);

int insert(TMsgMaSubscribe record);

int insertSelective(TMsgMaSubscribe record);

TMsgMaSubscribe selectByPrimaryKey(Integer id);

int updateByPrimaryKeySelective(TMsgMaSubscribe record);

int updateByPrimaryKey(TMsgMaSubscribe record);

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

int updateByMsgTypeAndMsgName(TMsgMaSubscribe tMsgMaSubscribe);

List<TMsgMaSubscribe> selectByMsgType(int msgType);

int deleteByMsgTypeAndName(@Param("msgType") int msgType, @Param("msgName") String msgName);
}
77 changes: 77 additions & 0 deletions src/main/java/com/fangxuele/tool/push/domain/TMsgMaSubscribe.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package com.fangxuele.tool.push.domain;

import java.io.Serializable;

public class TMsgMaSubscribe implements Serializable {
private Integer id;

private Integer msgType;

private String msgName;

private String templateId;

private String page;

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 getTemplateId() {
return templateId;
}

public void setTemplateId(String templateId) {
this.templateId = templateId == null ? null : templateId.trim();
}

public String getPage() {
return page;
}

public void setPage(String page) {
this.page = page == null ? null : page.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 @@ -27,7 +27,8 @@ public enum MessageTypeEnum {
DING(14, "钉钉"),
BD_YUN(15, "百度云短信"),
QI_NIU_YUN(16, "七牛云短信"),
WX_UNIFORM_MESSAGE(17, "小程序-统一服务消息");
WX_UNIFORM_MESSAGE(17, "小程序-统一服务消息"),
MA_SUBSCRIBE(18, "小程序-订阅消息");

private int code;

Expand All @@ -49,6 +50,7 @@ public enum MessageTypeEnum {
public static final int BD_YUN_CODE = 15;
public static final int QI_NIU_YUN_CODE = 16;
public static final int WX_UNIFORM_MESSAGE_CODE = 17;
public static final int MA_SUBSCRIBE_CODE = 18;

MessageTypeEnum(int code, String name) {
this.code = code;
Expand Down Expand Up @@ -106,6 +108,9 @@ public static String getName(int code) {
case 17:
name = WX_UNIFORM_MESSAGE.name;
break;
case 18:
name = MA_SUBSCRIBE.name;
break;
default:
name = "";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ public static boolean configCheck() {
break;
}
case MessageTypeEnum.MA_TEMPLATE_CODE:
case MessageTypeEnum.MA_SUBSCRIBE_CODE:
if (StringUtils.isEmpty(App.config.getMiniAppAppId()) || StringUtils.isEmpty(App.config.getMiniAppAppSecret())) {
JOptionPane.showMessageDialog(settingForm.getSettingPanel(), "请先在设置中填写并保存小程序相关配置!", "提示",
JOptionPane.INFORMATION_MESSAGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public static IMsgMaker getMsgMaker() {
case MessageTypeEnum.MA_TEMPLATE_CODE:
iMsgMaker = new WxMaTemplateMsgMaker();
break;
case MessageTypeEnum.MA_SUBSCRIBE_CODE:
iMsgMaker = new WxMaSubscribeMsgMaker();
break;
case MessageTypeEnum.KEFU_CODE:
iMsgMaker = new WxKefuMsgMaker();
break;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package com.fangxuele.tool.push.logic.msgmaker;

import cn.binarywang.wx.miniapp.bean.WxMaSubscribeData;
import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage;
import com.fangxuele.tool.push.bean.TemplateData;
import com.fangxuele.tool.push.ui.form.msg.MaTemplateMsgForm;
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/11/29.
*/
public class WxMaSubscribeMsgMaker extends BaseMsgMaker implements IMsgMaker {

public static String templateId;
private static String templateUrl;
public static List<TemplateData> templateDataList;

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

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

DefaultTableModel tableModel = (DefaultTableModel) MaTemplateMsgForm.getInstance().getTemplateMsgDataTable().getModel();
int rowCount = tableModel.getRowCount();
TemplateData templateData;
templateDataList = Lists.newArrayList();
for (int i = 0; i < rowCount; i++) {
String name = ((String) tableModel.getValueAt(i, 0)).trim();
String value = ((String) tableModel.getValueAt(i, 1)).trim();
String color = ((String) tableModel.getValueAt(i, 2)).trim();
templateData = new TemplateData();
templateData.setName(name);
templateData.setValue(value);
templateData.setColor(color);
templateDataList.add(templateData);
}
}

/**
* 组织订阅消息-小程序
*
* @param msgData 消息信息
* @return WxMaTemplateMessage
*/
@Override
public WxMaSubscribeMessage makeMsg(String[] msgData) {
// 拼模板
WxMaSubscribeMessage wxMaSubscribeMessage = new WxMaSubscribeMessage();
wxMaSubscribeMessage.setTemplateId(templateId);
VelocityContext velocityContext = getVelocityContext(msgData);
String templateUrlEvaluated = TemplateUtil.evaluate(templateUrl, velocityContext);
wxMaSubscribeMessage.setPage(templateUrlEvaluated);

WxMaSubscribeData wxMaSubscribeData;
for (TemplateData templateData : templateDataList) {
wxMaSubscribeData = new WxMaSubscribeData();
wxMaSubscribeData.setName(templateData.getName());
wxMaSubscribeData.setValue(TemplateUtil.evaluate(templateData.getValue(), velocityContext));
wxMaSubscribeData.setColor(templateData.getColor());
wxMaSubscribeMessage.addData(wxMaSubscribeData);
}

return wxMaSubscribeMessage;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.fangxuele.tool.push.logic.PushControl;
import com.fangxuele.tool.push.logic.msgmaker.AliyunMsgMaker;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.exception.ExceptionUtils;

/**
* <pre>
Expand Down Expand Up @@ -56,7 +57,7 @@ public SendResult send(String[] msgData) {
} catch (Exception e) {
sendResult.setSuccess(false);
sendResult.setInfo(e.getMessage());
log.error(e.toString());
log.error(ExceptionUtils.getStackTrace(e));
}

return sendResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.fangxuele.tool.push.logic.PushControl;
import com.fangxuele.tool.push.logic.msgmaker.BdYunMsgMaker;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.exception.ExceptionUtils;

import java.util.Map;

Expand Down Expand Up @@ -70,7 +71,7 @@ public SendResult send(String[] msgData) {
} catch (Exception e) {
sendResult.setSuccess(false);
sendResult.setInfo(e.getMessage());
log.error(e.toString());
log.error(ExceptionUtils.getStackTrace(e));
}

return sendResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.compress.utils.Lists;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;

import java.util.List;

Expand Down Expand Up @@ -85,7 +86,7 @@ public SendResult sendWorkMsg(String[] msgData) {
} catch (Exception e) {
sendResult.setSuccess(false);
sendResult.setInfo(e.getMessage());
log.error(e.toString());
log.error(ExceptionUtils.getStackTrace(e));
return sendResult;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import okhttp3.RequestBody;
import okhttp3.Response;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;

import java.net.HttpCookie;
import java.net.InetSocketAddress;
Expand Down Expand Up @@ -124,7 +125,7 @@ public HttpSendResult sendUseHutool(String[] msgData) {
} catch (Exception e) {
sendResult.setSuccess(false);
sendResult.setInfo(e.toString());
log.error(e.toString());
log.error(ExceptionUtils.getStackTrace(e));
return sendResult;
}
StringBuilder headerBuilder = StrUtil.builder();
Expand Down Expand Up @@ -260,7 +261,7 @@ public HttpSendResult sendUseOkHttp(String[] msgData) {
} catch (Exception e) {
sendResult.setSuccess(false);
sendResult.setInfo(e.getMessage());
log.error(e.toString());
log.error(ExceptionUtils.getStackTrace(e));
return sendResult;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.compress.utils.Lists;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;

import java.io.File;
import java.util.List;
Expand Down Expand Up @@ -61,7 +62,7 @@ public SendResult send(String[] msgData) {
} catch (Exception e) {
sendResult.setSuccess(false);
sendResult.setInfo(e.getMessage());
log.error(e.toString());
log.error(ExceptionUtils.getStackTrace(e));
}

return sendResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public static IMsgSender getMsgSender() {
case MessageTypeEnum.MA_TEMPLATE_CODE:
iMsgSender = new WxMaTemplateMsgSender();
break;
case MessageTypeEnum.MA_SUBSCRIBE_CODE:
iMsgSender = new WxMaSubscribeMsgSender();
break;
case MessageTypeEnum.KEFU_CODE:
iMsgSender = new WxKefuMsgSender();
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.qiniu.sms.SmsManager;
import com.qiniu.util.Auth;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.exception.ExceptionUtils;

import java.util.Map;

Expand Down Expand Up @@ -57,7 +58,7 @@ public SendResult send(String[] msgData) {
} catch (Exception e) {
sendResult.setSuccess(false);
sendResult.setInfo(e.getMessage());
log.error(e.toString());
log.error(ExceptionUtils.getStackTrace(e));
}

return sendResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.github.qcloudsms.SmsSingleSender;
import com.github.qcloudsms.SmsSingleSenderResult;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.exception.ExceptionUtils;

/**
* <pre>
Expand Down Expand Up @@ -54,7 +55,7 @@ public SendResult send(String[] msgData) {
} catch (Exception e) {
sendResult.setSuccess(false);
sendResult.setInfo(e.getMessage());
log.error(e.toString());
log.error(ExceptionUtils.getStackTrace(e));
}

return sendResult;
Expand Down
Loading

0 comments on commit cdaaaf3

Please sign in to comment.