forked from rememberber/WePush
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '4.4.2' into gitee-4.5.0
# Conflicts: # pom.xml # src/main/java/com/fangxuele/tool/push/ui/UiConsts.java # src/main/resources/version_summary.json
- Loading branch information
Showing
36 changed files
with
1,642 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/java/com/fangxuele/tool/push/dao/TMsgMpSubscribeMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
117
src/main/java/com/fangxuele/tool/push/domain/TMsgMpSubscribe.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
src/main/java/com/fangxuele/tool/push/logic/msgmaker/WxMpSubscribeMsgMaker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.