-
Notifications
You must be signed in to change notification settings - Fork 998
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 #222 from rememberber/develop
Develop
- Loading branch information
Showing
28 changed files
with
2,123 additions
and
187 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
61 changes: 61 additions & 0 deletions
61
src/main/java/com/fangxuele/tool/push/logic/msgmaker/BdYunMsgMaker.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.BdYunMsgForm; | ||
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 BdYunMsgMaker extends BaseMsgMaker implements IMsgMaker { | ||
|
||
public static String templateId; | ||
|
||
public static Map<String, String> paramMap; | ||
|
||
/** | ||
* 准备(界面字段等) | ||
*/ | ||
@Override | ||
public void prepare() { | ||
templateId = BdYunMsgForm.getInstance().getMsgTemplateIdTextField().getText(); | ||
|
||
if (BdYunMsgForm.getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) { | ||
BdYunMsgForm.initTemplateDataTable(); | ||
} | ||
|
||
DefaultTableModel tableModel = (DefaultTableModel) BdYunMsgForm.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> stringStringEntry : paramMap.entrySet()) { | ||
stringStringEntry.setValue(TemplateUtil.evaluate(stringStringEntry.getValue(), velocityContext)); | ||
} | ||
return paramMap; | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
src/main/java/com/fangxuele/tool/push/logic/msgmaker/HwYunMsgMaker.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.HwYunMsgForm; | ||
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 HwYunMsgMaker extends BaseMsgMaker implements IMsgMaker{ | ||
|
||
public static String templateId; | ||
|
||
public static List<String> paramList; | ||
|
||
/** | ||
* 准备(界面字段等) | ||
*/ | ||
@Override | ||
public void prepare() { | ||
templateId = HwYunMsgForm.getInstance().getMsgTemplateIdTextField().getText(); | ||
|
||
if (HwYunMsgForm.getInstance().getTemplateMsgDataTable().getModel().getRowCount() == 0) { | ||
HwYunMsgForm.initTemplateDataTable(); | ||
} | ||
|
||
DefaultTableModel tableModel = (DefaultTableModel) HwYunMsgForm.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.