-
Notifications
You must be signed in to change notification settings - Fork 996
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #224 from rememberber/develop
Develop
- Loading branch information
Showing
30 changed files
with
1,782 additions
and
184 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
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
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
61 changes: 61 additions & 0 deletions
61
src/main/java/com/fangxuele/tool/push/logic/msgmaker/QiNiuYunMsgMaker.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,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; | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
src/main/java/com/fangxuele/tool/push/logic/msgmaker/UpYunMsgMaker.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,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); | ||
} | ||
} |
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.