Skip to content

Commit

Permalink
Merge branch '4.4.2' into gitee-4.5.0
Browse files Browse the repository at this point in the history
# Conflicts:
#	pom.xml
#	src/main/java/com/fangxuele/tool/push/ui/UiConsts.java
#	src/main/resources/version_summary.json
  • Loading branch information
rememberber committed Jan 9, 2022
2 parents ef887d1 + ade1f91 commit 6f91f11
Show file tree
Hide file tree
Showing 36 changed files with 1,642 additions and 161 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>4.0.0</weixin-java-mp.version>
<weixin-java-cp.version>4.0.0</weixin-java-cp.version>
<weixin-java-miniapp.version>4.0.0</weixin-java-miniapp.version>
<weixin-java-mp.version>4.1.0</weixin-java-mp.version>
<weixin-java-cp.version>4.1.0</weixin-java-cp.version>
<weixin-java-miniapp.version>4.1.0</weixin-java-miniapp.version>
<emoji-java.version>5.1.1</emoji-java.version>
<hutool-all.version>5.4.4</hutool-all.version>
<opencsv.version>5.2</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.TMsgMpSubscribe;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface TMsgMpSubscribeMapper {
int deleteByPrimaryKey(Integer id);

int insert(TMsgMpSubscribe record);

int insertSelective(TMsgMpSubscribe record);

TMsgMpSubscribe selectByPrimaryKey(Integer id);

int updateByPrimaryKeySelective(TMsgMpSubscribe record);

int updateByPrimaryKey(TMsgMpSubscribe record);

List<TMsgMpSubscribe> selectByMsgTypeAndWxAccountId(@Param("msgType") int msgType, @Param("wxAccountId") Integer wxAccountId);

int deleteByMsgTypeAndName(int msgType, String msgName);

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

int updateByMsgTypeAndMsgName(TMsgMpSubscribe tMsgMpSubscribe);
}
117 changes: 117 additions & 0 deletions src/main/java/com/fangxuele/tool/push/domain/TMsgMpSubscribe.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 TMsgMpSubscribe implements Serializable {
private Integer id;

private Integer msgType;

private String msgName;

private String templateId;

private String url;

private String maAppid;

private String maPagePath;

private String previewUser;

private Integer wxAccountId;

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 getUrl() {
return url;
}

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

public String getMaAppid() {
return maAppid;
}

public void setMaAppid(String maAppid) {
this.maAppid = maAppid == null ? null : maAppid.trim();
}

public String getMaPagePath() {
return maPagePath;
}

public void setMaPagePath(String maPagePath) {
this.maPagePath = maPagePath == null ? null : maPagePath.trim();
}

public String getPreviewUser() {
return previewUser;
}

public void setPreviewUser(String previewUser) {
this.previewUser = previewUser == null ? null : previewUser.trim();
}

public Integer getWxAccountId() {
return wxAccountId;
}

public void setWxAccountId(Integer wxAccountId) {
this.wxAccountId = wxAccountId;
}

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();
}
}
25 changes: 24 additions & 1 deletion src/main/java/com/fangxuele/tool/push/logic/MessageTypeEnum.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public enum MessageTypeEnum {
BD_YUN(15, "百度云短信"),
QI_NIU_YUN(16, "七牛云短信"),
WX_UNIFORM_MESSAGE(17, "小程序-统一服务消息"),
MA_SUBSCRIBE(18, "小程序-订阅消息");
MA_SUBSCRIBE(18, "小程序-订阅消息"),
MP_SUBSCRIBE(19, "公众号-订阅通知");

private int code;

Expand All @@ -51,6 +52,7 @@ public enum MessageTypeEnum {
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;
public static final int MP_SUBSCRIBE_CODE = 19;

MessageTypeEnum(int code, String name) {
this.code = code;
Expand Down Expand Up @@ -111,9 +113,30 @@ public static String getName(int code) {
case 18:
name = MA_SUBSCRIBE.name;
break;
case 19:
name = MP_SUBSCRIBE.name;
break;
default:
name = "";
}
return name;
}

public static boolean isWxMpType(int msgType) {
return msgType == MessageTypeEnum.KEFU_CODE
|| msgType == MessageTypeEnum.KEFU_PRIORITY_CODE
|| msgType == MessageTypeEnum.MP_TEMPLATE_CODE
|| msgType == MessageTypeEnum.MP_SUBSCRIBE_CODE;
}

public static boolean isWxMaType(int msgType) {
return msgType == MessageTypeEnum.MA_TEMPLATE_CODE
|| msgType == MessageTypeEnum.MA_SUBSCRIBE_CODE
|| msgType == MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE;
}

public static boolean isWxMaOrMpType(int msgType) {
return isWxMaType(msgType)
|| isWxMpType(msgType);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ public static boolean configCheck() {
int msgType = App.config.getMsgType();
switch (msgType) {
case MessageTypeEnum.MP_TEMPLATE_CODE:
case MessageTypeEnum.MP_SUBSCRIBE_CODE:
case MessageTypeEnum.KEFU_CODE:
case MessageTypeEnum.KEFU_PRIORITY_CODE:
case MessageTypeEnum.WX_UNIFORM_MESSAGE_CODE: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ public static IMsgMaker getMsgMaker() {
case MessageTypeEnum.QI_NIU_YUN_CODE:
iMsgMaker = new QiNiuYunMsgMaker();
break;
case MessageTypeEnum.MP_SUBSCRIBE_CODE:
iMsgMaker = new WxMpSubscribeMsgMaker();
break;
default:
}
return iMsgMaker;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ public WxMaSubscribeMessage makeMsg(String[] msgData) {
String templateUrlEvaluated = TemplateUtil.evaluate(templateUrl, velocityContext);
wxMaSubscribeMessage.setPage(templateUrlEvaluated);

WxMaSubscribeMessage.Data wxMaSubscribeData;
WxMaSubscribeMessage.MsgData wxMaSubscribeData;
for (TemplateData templateData : templateDataList) {
wxMaSubscribeData = new WxMaSubscribeMessage.Data();
wxMaSubscribeData = new WxMaSubscribeMessage.MsgData();
wxMaSubscribeData.setName(templateData.getName());
wxMaSubscribeData.setValue(TemplateUtil.evaluate(templateData.getValue(), velocityContext));
wxMaSubscribeMessage.addData(wxMaSubscribeData);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package com.fangxuele.tool.push.logic.msgmaker;

import com.fangxuele.tool.push.bean.TemplateData;
import com.fangxuele.tool.push.ui.form.msg.MpSubscribeMsgForm;
import com.fangxuele.tool.push.util.TemplateUtil;
import me.chanjar.weixin.mp.bean.subscribe.WxMpSubscribeMessage;
import org.apache.commons.compress.utils.Lists;
import org.apache.velocity.VelocityContext;

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

/**
* <pre>
* 公众号订阅通知加工器
* </pre>
*
* @author <a href="https://github.com/rememberber">Zhou Bo</a>
* @since 2021/3/23.
*/
public class WxMpSubscribeMsgMaker extends BaseMsgMaker implements IMsgMaker {

public static String templateId;

private static String templateUrl;

private static String miniAppId;

private static String miniAppPagePath;

public static List<TemplateData> templateDataList;

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

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

DefaultTableModel tableModel = (DefaultTableModel) MpSubscribeMsgForm.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 WxMpSubscribeMessage
*/
@Override
public WxMpSubscribeMessage makeMsg(String[] msgData) {
// 拼模板
WxMpSubscribeMessage wxMessageTemplate = new WxMpSubscribeMessage();
wxMessageTemplate.setTemplateId(templateId);

VelocityContext velocityContext = getVelocityContext(msgData);
String templateUrlEvaluated = TemplateUtil.evaluate(templateUrl, velocityContext);
wxMessageTemplate.setPage(templateUrlEvaluated);
String miniAppPagePathEvaluated = TemplateUtil.evaluate(miniAppPagePath, velocityContext);
WxMpSubscribeMessage.MiniProgram miniProgram = new WxMpSubscribeMessage.MiniProgram(miniAppId, miniAppPagePathEvaluated, false);
wxMessageTemplate.setMiniProgram(miniProgram);

Map<String, String> dataMap = new HashMap<>(10);
for (TemplateData templateData : templateDataList) {
dataMap.put(templateData.getName(), TemplateUtil.evaluate(templateData.getValue(), velocityContext));
}

wxMessageTemplate.setDataMap(dataMap);

return wxMessageTemplate;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ public static IMsgSender getMsgSender() {
case MessageTypeEnum.QI_NIU_YUN_CODE:
iMsgSender = new QiNiuYunMsgSender();
break;
case MessageTypeEnum.MP_SUBSCRIBE_CODE:
iMsgSender = new WxMpSubscribeMsgSender();
break;
default:
break;
}
Expand Down
Loading

0 comments on commit 6f91f11

Please sign in to comment.