Browse Source

提交demo代码

10.0
LAPTOP-SB56SG4Q\86185 4 years ago
parent
commit
f9d6a59bfc
  1. 4
      README.md
  2. 124
      build.gradle
  3. 13
      encrypt.xml
  4. 20
      plugin.xml
  5. 40
      src/main/java/com/tptj/demo/hg/third/sms/Demo.java
  6. 55
      src/main/java/com/tptj/demo/hg/third/sms/DemoResource.java
  7. 17
      src/main/java/com/tptj/demo/hg/third/sms/DemoServerBridge.java
  8. 177
      src/main/java/com/tptj/demo/hg/third/sms/SMSUserInfo.java
  9. 44
      src/main/java/com/tptj/demo/hg/third/sms/ThirdSMSSender.java

4
README.md

@ -1,3 +1,5 @@
# demo-third-sms
内网短信集成示例demo
内网短信集成示例demo\
可以在内网环境下开启并使用帆软的短信相关功能\
短信发送通过后台日志模拟的。

124
build.gradle

@ -0,0 +1,124 @@
apply plugin: 'java'
[compileJava,compileTestJava]*.options*.encoding = 'UTF-8'
ext {
/**
* jar的路径
* 1.jar需要打包到zip中,lib根目录下
* 2.jar仅仅是编译时需要lib下子目录下即可
*/
libPath = "$projectDir/../../webroot/WEB-INF/lib"
/**
* class进行加密保护
*/
guard = false
def pluginInfo = getPluginInfo()
pluginPre = "fine-plugin"
pluginName = pluginInfo.id
pluginVersion = pluginInfo.version
outputPath = "$projectDir/../../webroot/WEB-INF/plugins/plugin-" + pluginName + "-1.0/classes"
}
group = 'com.fr.plugin'
version = '10.0'
sourceCompatibility = '8'
sourceSets {
main {
java.outputDir = file(outputPath)
output.resourcesDir = file(outputPath)
}
}
ant.importBuild("encrypt.xml")
//ant变量
ant.projectDir = projectDir
ant.references["compile.classpath"] = ant.path {
fileset(dir: libPath, includes: '**/*.jar')
fileset(dir: ".",includes:"**/*.jar" )
}
classes.dependsOn('clean')
task copyFiles(type: Copy,dependsOn: 'classes'){
from outputPath
into "$projectDir/classes"
}
task preJar(type:Copy,dependsOn: guard ? 'compile_encrypt_javas' : 'compile_plain_javas'){
from "$projectDir/classes"
into "$projectDir/transform-classes"
include "**/*.*"
}
jar.dependsOn("preJar")
task makeJar(type: Jar,dependsOn: preJar){
from fileTree(dir: "$projectDir/transform-classes")
baseName pluginPre
appendix pluginName
version pluginVersion
destinationDir = file("$buildDir/libs")
doLast(){
delete file("$projectDir/classes")
delete file("$projectDir/transform-classes")
}
}
task copyFile(type: Copy,dependsOn: ["makeJar"]){
from "$buildDir/libs"
from("$projectDir/lib") {
include "*.jar"
}
from "$projectDir/plugin.xml"
into file("$buildDir/temp/plugin")
}
task zip(type:Zip,dependsOn:["copyFile"]){
from "$buildDir/temp/plugin"
destinationDir file("$buildDir/install")
baseName pluginPre
appendix pluginName
version pluginVersion
}
//build时包含哪些文件,
processResources {
// exclude everything
// *.css没效果
// exclude '**/*.css'
// except this file
// include 'xx.xml'
}
/*读取plugin.xml中的version*/
def getPluginInfo(){
def xmlFile = file("plugin.xml")
if (!xmlFile.exists()) {
return ["id":"none", "version":"1.0.0"]
}
def plugin = new XmlParser().parse(xmlFile)
def version = plugin.version[0].text()
def id = plugin.id[0].text()
return ["id":id,"version":version]
}
repositories {
mavenLocal()
maven {
url = uri('http://mvn.finedevelop.com/repository/maven-public/')
}
}
dependencies {
//使jar
implementation fileTree(dir: 'lib', include: ['**/*.jar'])
implementation fileTree(dir: libPath, include: ['**/*.jar'])
}

13
encrypt.xml

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project>
<target name="compile_encrypt_javas" depends="copyFiles">
<echo message="加密文件"/>
<echo message="${projectDir}"/>
<taskdef name="pretreatment" classname="com.fr.plugin.pack.PluginPretreatmentTask">
<classpath refid="compile.classpath"/>
</taskdef>
<pretreatment baseDir="${projectDir}"/>
</target>
<target name="compile_plain_javas" depends="copyFiles">
</target>
</project>

20
plugin.xml

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?><plugin>
<id>com.tptj.demo.hg.third.sms.v10</id>
<name><![CDATA[ Third SMS ]]></name>
<active>yes</active>
<version>1.0</version>
<env-version>10.0</env-version>
<vendor>tptj</vendor>
<jartime>2019-07-18</jartime>
<description><![CDATA[ ]]></description>
<change-notes><![CDATA[]]></change-notes>
<main-package>com.tptj.demo.hg.third.sms</main-package>
<function-recorder class="com.tptj.demo.hg.third.sms.ThirdSMSSender"/>
<extra-core>
<SiteTransformer class="com.tptj.demo.hg.third.sms.Demo"/>
<SMSServiceProvider class="com.tptj.demo.hg.third.sms.ThirdSMSSender"/>
</extra-core>
<extra-decision>
<ControllerRegisterProvider class="com.tptj.demo.hg.third.sms.DemoServerBridge"/>
</extra-decision>
</plugin>

40
src/main/java/com/tptj/demo/hg/third/sms/Demo.java

@ -0,0 +1,40 @@
package com.tptj.demo.hg.third.sms;
import com.fr.stable.StringUtils;
import com.fr.stable.fun.impl.AbstractSiteTransformer;
import java.util.HashMap;
import java.util.Map;
/**
* @author 秃破天际
* @version 10.0
* Created by 秃破天际 on 2021/7/23
**/
public class Demo extends AbstractSiteTransformer {
private static final String HOST = "http://localhost:8075/webroot/decision/shequ";
private static final Map<String,String> sites = new HashMap<String,String>(1);
static{
sites.put("bbs.login.api","/v1/user/login/");
sites.put("sms_app","/v1/sms/");
sites.put("sms_info","/v1/sms/user_info");
sites.put("ping","/v1/ping");
}
@Override
public boolean match(String old) {
return sites.containsKey(old);
}
@Override
public String transform(String old){
return HOST + sites.get(old);
}
@Override
public String transform() {
return StringUtils.EMPTY;
}
}

55
src/main/java/com/tptj/demo/hg/third/sms/DemoResource.java

@ -0,0 +1,55 @@
package com.tptj.demo.hg.third.sms;
import com.fr.decision.webservice.annotation.LoginStatusChecker;
import com.fr.general.GeneralUtils;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import com.fr.third.springframework.stereotype.Controller;
import com.fr.third.springframework.web.bind.annotation.RequestMapping;
import com.fr.third.springframework.web.bind.annotation.ResponseBody;
import com.fr.web.utils.WebUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* @author 秃破天际
* @version 10.0
* Created by 秃破天际 on 2021/7/23
**/
@Controller("SmsThirdSheQu")
@RequestMapping(value = "/shequ")
@LoginStatusChecker(required = false)
public class DemoResource {
@RequestMapping(value = "/**")
@ResponseBody
public void dispatcher( HttpServletRequest request, HttpServletResponse response ) throws Exception{
String info = request.getPathInfo();
String method = request.getMethod();
if( "/shequ/v1/user/login/".equals(info) ){
//内网下模拟帆软通行证登录
print(request,response,"{\"code\":200,\"message\":\"success\",\"data\":{\"access_token\":\"Um5rO7Ef5gvCqBWQw08LJkRilxtc4SGN\",\"expires_time\":1627015460,\"refresh_token\":\"HQqs6A9dTn1CElwP3tLJ4McX387pj2Uu\",\"refresh_expires_time\":1628217860,\"client\":{\"appid\":\"shequapp\",\"uid\":99999,\"username\":\"三方集成\"}},\"status\":0}");
}else if("/shequ/v1/sms/".equals(info) && "POST".equals(method)){
//内网下验证短信开启
print(request,response,"{\"status\":\"success\",\"data\":{\"app_key\":\"third_app_key\",\"app_secret\":\"third_app_secret\"}}");
}else if( "/shequ/v1/sms/user_info".equals(info) && "POST".equals(method) ){
//内网下获取短信模板
print( request, response, SMSUserInfo.DATA.toString() );
}else if( "/shequ/v1/ping".equals(info) ){
//内网下模拟在线
WebUtils.printAsString(response, StringUtils.EMPTY);
}
}
private static void print(HttpServletRequest req, HttpServletResponse res, String response){
try{
JSONObject obj = new JSONObject(response);
WebUtils.flushSuccessMessageAutoClose(req,res,obj);
}catch(Exception e){
FineLoggerFactory.getLogger().error(e.getMessage(),e);
}
}
}

17
src/main/java/com/tptj/demo/hg/third/sms/DemoServerBridge.java

@ -0,0 +1,17 @@
package com.tptj.demo.hg.third.sms;
import com.fr.decision.fun.impl.AbstractControllerRegisterProvider;
/**
* @author 秃破天际
* @version 10.0
* Created by 秃破天际 on 2021/7/23
**/
public class DemoServerBridge extends AbstractControllerRegisterProvider {
@Override
public Class<?>[] getControllers() {
return new Class[]{
DemoResource.class
};
}
}

177
src/main/java/com/tptj/demo/hg/third/sms/SMSUserInfo.java

@ -0,0 +1,177 @@
package com.tptj.demo.hg.third.sms;
import com.fr.json.JSONArray;
import com.fr.json.JSONObject;
import java.util.HashMap;
import java.util.Map;
/**
* @author 秃破天际
* @version 10.0
* Created by 秃破天际 on 2021/7/23
**/
public class SMSUserInfo {
public static final JSONObject DATA = JSONObject.create()
.put("data", getData() )
.put("status","success");
private static JSONObject getData(){
return JSONObject.create()
.put("balance",1000)
.put("testSMSNum",5)
.put("userId",99999)
.put("sign",getSigns())
.put("public_tpl",getPublicTpl())
.put("private_tpl",getPrivateTpl());
}
private static JSONArray getSigns(){
return JSONArray.create()
.put(newSign(2,"【信息平台】",null,"success", true ) )
.put(newSign(3,"【帆软软件】",null,"success", true ) )
.put(newSign(4,"【呵呵平台】",null,"success", true ) );
}
private static JSONArray getPublicTpl(){
return JSONArray.create()
.put(newTpl( 10,"【信息平台】尊敬的管理员,#taskname#于#time#运行失败,请知晓。", "zh_CN", true ))
.put(newTpl( 11,"【帆软软件】尊敬的#name#,您有一个工单号为:#order_number#的待处理工单,请您及时处理!", "zh_CN", true ))
.put(newTpl( 13,"【帆软软件】您好,#webname#系统内存持续#m#分钟内存高于#n#,可能存在宕机风险,请及时关注。", "zh_CN", true ))
.put(newTpl( 14,"【帆软软件】尊敬的管理员,#taskname#于#time#运行失败,请知晓。", "zh_CN", true ))
.put(newTpl( 15,"【帆软软件】您好,#taskname#于#time#运行成功。", "zh_CN", true ))
.put(newTpl( 16,"【帆软软件】您的手机验证码为#Verifiecode#,请于10分钟内正确输入。", "zh_CN", true ))
.put(newTpl( 17,"【信息平台】您好,#webname#系统内存持续#m#分钟内存高于#n#,可能存在宕机风险,请及时关注。", "zh_CN", true ))
.put(newTpl( 18,"【信息平台】恭喜!您的短信服务已经配置成功。", "zh_CN", true ))
.put(newTpl( 20,"【信息平台】您的手机验证码为#verifiecode#,请于10分钟内正确输入。", "zh_CN", true ))
.put(newTpl( 49,"【信息平台】您好,#webname#系统日志文件已大于#logsize#M,请及时登录平台进行日志清理。", "zh_CN", true ))
.put(newTpl( 50,"【信息平台】您好,#webname#系统#clustername#内存持续#m#分钟内存高于#n#,可能存在宕机风险,请及时关注。", "zh_CN", true ))
.put(newTpl( 51,"【信息平台】你好,#task#出错,请及时处理。该任务开始执行时间:#time#", "zh_CN", true ))
.put(newTpl( 53,"【信息平台】上报任务 #task#,已经到您这里#time#,请尽快处理!", "zh_CN", true ))
.put(newTpl( 54,"【信息平台】#name#您好,上报任务#task#已经发起,请尽快处理!", "zh_CN", true ))
.put(newTpl( 63,"【信息平台】节点#nodename2#,与节点#nodename1#系统时间相差超过#time_different#秒,为避免影响用户使用,请及时调整使各节点时间保持一致。", "zh_CN", true ))
.put(newTpl( 64,"【信息平台】节点#nodename#已脱离集群环境,可能原因为:节点FullGC、节点宕机、节点间通…其他异常。为避免影响用户使用,请及时检查该节点状态,若该节点长时间无法自行恢复,则建议重启该节点。", "zh_CN", true ))
.put(newTpl( 89,"【信息平台】节点#nodename#,与节点#node1name#的jar包不一致,将影响集群工程的稳定性,请前往集群节点管理页面查看详细异常信息,并及时处理。", "zh_CN", true ))
.put(newTpl( 90,"【信息平台】节点#nodename#情况异常,用户不能正常访问,请及时检查该节点状态。", "zh_CN", true ))
.put(newTpl( 125,"【信息平台】您有个#proname#任务即将过期,请您尽快办理。", "zh_CN", true ))
.put(newTpl( 127,"【信息平台】您有个#proname#任务需要处理,请您尽快办理。发起人:#startpeople#,发起时间:#starttime#。", "zh_CN", true ))
.put(newTpl( 134,"【信息平台】Redis集群#ip_port#节点已无法正常使用,可能原因为:节点宕机、内存已满、其他异常。为避免影响用户使用,请前往状态服务器配置页面查看详情,并及时处理。", "zh_CN", true ))
.put(newTpl( 135,"【信息平台】文件服务器出现无法读写的情况,可能原因为:文件服务器宕机、磁盘已满、其他异常。为避免影响用户使用,请及时检查文件服务器状态。", "zh_CN", true ))
.put(newTpl( 136,"【信息平台】您好,#webname#系统#clustername#当前负载状态过高,可能存在宕机风险,请及时关注。建议使用管理系统-智能运维-云端运维功能分析当前系统存在的性能问题。", "zh_CN", true ))
.put(newTpl( 239,"【帆软软件】您好,预警任务#warningname#达到阈值被触发,请及时关注!模板路径:#templatePath#", "zh_CN", true ))
.put(newTpl( 264,"【信息平台】更新任务「#job_name#」结束。任务开始于#year#年#month#月#day#…aset# , 关联更新 #success_relation#/#total_relation#。", "zh_CN", true ))
.put(newTpl( 265,"【信息平台】报表系统已宕机,请访问运维工具关注问题处理状态或及时进行系统重启。", "zh_CN", true ))
.put(newTpl( 266,"【信息平台】报表系统已宕机,自动重启系统失败,请及时进行手动重启。", "zh_CN", true ))
.put(newTpl( 269,"【信息平台】检查到系统环境配置存有不合理项,请及时查看并改正不合理项。", "zh_CN", true ))
.put(newTpl( 276,"【信息平台】你好,[#taskname#]备份失败,请及时处理,备份时间:#time#", "zh_CN", true ))
.put(newTpl( 306,"【信息平台】尊敬的管理員,#taskname#於#time#運行失敗,請知曉。", "zh_TW", true ))
.put(newTpl( 307,"【信息平台】您好,#webname#系統記憶體持續#m#分鐘記憶體高於#n#,可能存在宕機風險,請及時關注。", "zh_TW", true ))
.put(newTpl( 308,"【信息平台】恭喜!您的簡訊服務已經配置成功。", "zh_TW", true ))
.put(newTpl( 309,"【信息平台】您的手機驗證碼為#verifiecode#,請於10分鐘內正確輸入。", "zh_TW", true ))
.put(newTpl( 310,"【信息平台】您好,#webname#系統日誌檔已大於#logsize#M,請及時登入平臺進行日誌清理。", "zh_TW", true ))
.put(newTpl( 311,"【信息平台】您好,#webname#系統#clustername#記憶體持續#m#分鐘記憶體高於#n#,可能存在宕機風險,請及時關注。", "zh_TW", true ))
.put(newTpl( 312,"【信息平台】你好,#task#出錯,請及時處理。該任務開始執行時間:#time#", "zh_TW", true ))
.put(newTpl( 313,"【信息平台】上報任務#task#,已經到您這裡#time#,請儘快處理!", "zh_TW", true ))
.put(newTpl( 314,"【信息平台】#name#您好,上報任務#task#已經發起,請儘快處理!", "zh_TW", true ))
.put(newTpl( 315,"【信息平台】系統檢測到,節點#node_id#的系統時間與其他節點不一致。請配置時間伺服器,實現節點時間的自動同步。", "zh_TW", true ))
.put(newTpl( 316,"【信息平台】節點#nodename#已脫離叢集環境,可能原因為:節點FullGC、節點宕機、節點間通…他异常。為避免影響使用者使用,請及時檢查該節點狀態,若該節點長時間無法自行恢復,則建議重啓該節點。", "zh_TW", true ))
.put(newTpl( 317,"【信息平台】節點#nodename#,與節點#node1name#的jar包不一致,將影響叢集工程的穩定性,請前往叢集節點管理頁面查看詳細异常資訊,並及時處理。", "zh_TW", true ))
.put(newTpl( 318,"【信息平台】節點#nodename#情况异常,使用者不能正常訪問,請及時檢查該節點狀態。", "zh_TW", true ))
.put(newTpl( 319,"【信息平台】您有個#proname#任務即將過期,請您儘快辦理。", "zh_TW", true ))
.put(newTpl( 320,"【信息平台】您有個#proname#任務需要處理,請您儘快辦理。發起人:#startpeople#,發起時間:#starttime#。", "zh_TW", true ))
.put(newTpl( 321,"【信息平台】Redis叢集#ip_port#節點已無法正常使用,可能原因為:節點宕機、記憶體已滿、其他異常。為避免影響使用者使用,請前往狀態伺服器配置頁面檢視詳情,並及時處理。", "zh_TW", true ))
.put(newTpl( 322,"【信息平台】檔案伺服器出現無法讀寫的情况,可能原因為:檔案伺服器宕機、磁片已滿、其他异常。為避免影響使用者使用,請及時檢查檔案伺服器狀態。", "zh_TW", true ))
.put(newTpl( 323,"【信息平台】您好,#webname#系統#clustername#當前負載狀態過高,可能存在宕機風險,請及時關注。", "zh_TW", true ))
.put(newTpl( 324,"【信息平台】更新任務「#job_name#」結束。任務開始於#year#年#month#月#day#…dataset#,關聯更新#success_relation#/#total_relation#。", "zh_TW", true ))
.put(newTpl( 325,"【信息平台】報表系統已宕機,請訪問維運工具關注問題處理狀態或及時進行系統重啓。", "zh_TW", true ))
.put(newTpl( 326,"【信息平台】報表系統已宕機,自動重啟系統失敗,請及時進行手動重啓。", "zh_TW", true ))
.put(newTpl( 327,"【信息平台】檢查到系統環境配置存有不合理項,請及時查看並改正不合理項。", "zh_TW", true ))
.put(newTpl( 328,"【信息平台】你好,[#taskname#]備份失敗,請及時處理,備份時間:#time#", "zh_TW", true ))
.put(newTpl( 329,"【信息平台】Dear administrator, #taskname# failed to run at #time#.", "en_US", true ))
.put(newTpl( 330,"【信息平台】Hello, the system memory of #webname# keeps …y be downtime risk. Please pay attention in time.", "en_US", true ))
.put(newTpl( 331,"【信息平台】Congratulations! Your SMS service has been configured successfully.", "en_US", true ))
.put(newTpl( 332,"【信息平台】Your mobile phone verification code is #veri…de#. Please input it correctly within 10 minutes.", "en_US", true ))
.put(newTpl( 333,"【信息平台】Hello, the system log files of #webname# occ…g in the platform to clean the log files in time.", "en_US", true ))
.put(newTpl( 334,"【信息平台】Hello, the memory of #clustername# in system…y be downtime risk. Please pay attention in time.", "en_US", true ))
.put(newTpl( 335,"【信息平台】Hello, there is an error in the task #task#,…t in time. The start time of the task is: #time#.", "en_US", true ))
.put(newTpl( 336,"【信息平台】Reporting task #task# has arrived at #time#. Please deal with it as soon as possible!", "en_US", true ))
.put(newTpl( 337,"【信息平台】Hello #name#, the reporting task #task# has … initiated. Please handle it as soon as possible!", "en_US", true ))
.put(newTpl( 338,"【信息平台】The system detects that the system time of n…o realize automatic synchronization of node time.", "en_US", true ))
.put(newTpl( 339,"【信息平台】Node #nodename# has been out of the cluster …der to avoid affecting the user's use, please che", "en_US", true ))
.put(newTpl( 340,"【信息平台】The jar packages of node #nodename# and node…iled exception information and handle it in time.", "en_US", true ))
.put(newTpl( 341,"【信息平台】There exists abnormal condition of node #nod…lly. Please check the status of the node in time.", "en_US", true ))
.put(newTpl( 342,"【信息平台】Task #proname# will expire recently. Please handle it as soon as possible.", "en_US", true ))
.put(newTpl( 343,"【信息平台】Task #proname# needs to be handled. Please h…nitiator: #startpeople#. Start time: #starttime#.", "en_US", true ))
.put(newTpl( 344,"【信息平台】The Redis cluster #ip_port# node is no longe…page, check the details and deal with it in time.", "en_US", true ))
.put(newTpl( 345,"【信息平台】The file server is unable to read and write.…ease check the status of the file server in time.", "en_US", true ))
.put(newTpl( 346,"【信息平台】Hello, the load of #clustername# in system #…intenance and use the function of Cloud Operation", "en_US", true ))
.put(newTpl( 347,"【信息平台】Update task 「#job_name#」is completed. The ta…table#/#total_basetable# basic table, #success_da", "en_US", true ))
.put(newTpl( 348,"【信息平台】The report system has been down. Please use … processing status or restart the system in time.", "en_US", true ))
.put(newTpl( 349,"【信息平台】The report system has been down, and automat… restart failed. Please restart manually in time.", "en_US", true ))
.put(newTpl( 350,"【信息平台】It is found that there are unreasonable item…check and correct the unreasonable items in time.", "en_US", true ))
.put(newTpl( 351,"【信息平台】Hello, [#taskname#] backup failed. Please handle it in time. Backup time: #time#.", "en_US", true ))
.put(newTpl( 367,"【信息平台】集群节点#node_name#与基准节点存在不一致文件,且无法自动同步。请检查该节点状态", "zn_CN", true ))
.put(newTpl( 368,"【信息平台】集群节点#node_name#与基准节点存在不一致文件,已自动同步与基准节点一致,不一致文件备份在该节点工程WEB-INF/#directory#/下", "zh_CN", true ))
.put(newTpl( 369,"【信息平台】節點#nodename1#與節點#nodename1#之間通訊異常,無法加入節點管理,請…7830, 7840, 7850,7860,7870][UDP:45588~65536 隨機埠]。", "zh_TW", true ))
.put(newTpl( 370,"【信息平台】節點#node_name#的#type#模組存在異常,暫無法正常提供服務,請及時對異常狀況進行排查", "zh_TW", true ))
.put(newTpl( 371,"【信息平台】叢集節點#node_name#與基準節點存在不一致檔案,且無法自動同步。請檢查該節點狀態", "zh_TW", true ))
.put(newTpl( 372,"【信息平台】叢集節點#node_name#與基準節點存在不一致檔案,已自動同步與基準節點一致,不一致檔案備份在該節點工程WEB-INF/#directory#/下", "zh_TW", true ))
.put(newTpl( 373,"【信息平台】The communication between node #nodename1# a…7850,7860,7870] [UDP: 45588 ~ 65536 random port].", "en_US", true ))
.put(newTpl( 374,"【信息平台】The #node_name# node #type# module has start…ng. Please check for abnormal conditions in time.", "en_US", true ))
.put(newTpl( 375,"【信息平台】Cluster node #node_name# has inconsistent fi…ized automatically. Please check the node status.", "en_US", true ))
.put(newTpl( 376,"【信息平台】The cluster node #node_name# has an inconsis…up under the node project WEB-INF/ #directory# /.", "en_US", true ))
.put(newTpl( 401,"【信息平台】Hello, #taskname# runs successfully on #time#.", "en_US", true ))
.put(newTpl( 402,"【信息平台】您好,#taskname#於#time#運行成功運行。", "zh_TW", true ))
.put(newTpl( 509,"【信息平台】尊敬的管理员,用户管理-同步用户于#time#运行失败,可手动触发同步,以查看详细报错。", "zh_CN", true ))
.put(newTpl( 550,"【信息平台】Dear administrator, \\\"User>Sync user\\\" failed … sync manually to view the detailed error report.", "en_US", true ))
.put(newTpl( 551,"【信息平台】尊敬的管理員,使用者管理-同步使用者於#time#執行失敗,可手動觸發同步,以檢視詳細報錯。", "zh_TW", true ))
.put(newTpl( 998,"【信息平台】节点#nodename1#与节点#nodename2#之间通信异常,无法加入节点管理,请…830, 7840, 7850,7860,7870][UDP:45588~65536 随机端口]。", "zh_CN", true ))
.put(newTpl( 999,"【信息平台】节点#node_name#的#type#模块存在异常,暂无法正常提供服务,请及时对异常状况进行排查", "zh_CN", true ))
.put(newTpl( 1001,"【信息平台】随便测试一下", "zh_CN", true ))
.put(newTpl( 1002,"【呵呵平台】随便测试一下", "zh_CN", true ));
}
public static Map<String,String> getTpls(){
JSONArray arrs = getPublicTpl();
Map<String,String> rt = new HashMap<String,String>();
for( int i=0,len=arrs.length();i<len;i++ ){
JSONObject tpl = arrs.optJSONObject(i);
rt.put( ""+tpl.optInt("id"), tpl.optString("content") );
}
arrs = getPrivateTpl();
for( int i=0,len=arrs.length();i<len;i++ ){
JSONObject tpl = arrs.optJSONObject(i);
rt.put( ""+tpl.optInt("id"), tpl.optString("content") );
}
return rt;
}
private static JSONArray getPrivateTpl(){
return JSONArray.create();
}
private static JSONObject newSign(int id, String sign, String remark, String status, boolean isDefault){
return JSONObject.create()
.put("id",id)
.put("sign",sign)
.put("remark",remark)
.put("status",status)
.put("is_default",isDefault);
}
private static JSONObject newTpl( int id, String content, String language, boolean isDefault ){
return JSONObject.create()
.put("id",id)
.put("content",content)
.put("language",language)
.put("remark",(String)null)
.put("status","success")
.put("is_default",isDefault);
}
}

44
src/main/java/com/tptj/demo/hg/third/sms/ThirdSMSSender.java

@ -0,0 +1,44 @@
package com.tptj.demo.hg.third.sms;
import com.fr.intelli.record.Focus;
import com.fr.json.JSONArray;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.stable.fun.impl.AbstractSMSServiceProvider;
import com.fr.web.utils.WebUtils;
import java.util.List;
import java.util.Map;
/**
* @author 秃破天际
* @version 10.0
* Created by 秃破天际 on 2021/7/23
**/
@EnableMetrics
public class ThirdSMSSender extends AbstractSMSServiceProvider {
@Override
public Map<String, String> mapping() {
return SMSUserInfo.getTpls();
}
@Override
public Response sendTest(String mobile) {
FineLoggerFactory.getLogger().info("ThirdSMSSender#sendTest-> {} ",mobile);
return Response.create(Response.RES_STATUS_SUCCESS, "Send Test Sms Message", JSONObject.create().put("mobile",mobile) );
}
@Override
@Focus(id = "com.tptj.demo.hg.third.sms.v10",text = "Third SMS")
public Response send(String template, String mobile, JSONObject para, String receiver) throws Exception {
FineLoggerFactory.getLogger().info("ThirdSMSSender#send-> {}:{},{}=== {}",mobile,template,para.toString(),receiver);
return Response.create(Response.RES_STATUS_SUCCESS, "Send Sms Message", JSONObject.create().put("mobile",mobile) );
}
@Override
public Response batchSendSMS(String template, List<String> mobiles, JSONArray params, List<String> receivers) throws Exception {
FineLoggerFactory.getLogger().info("ThirdSMSSender#batchSendSMS({})",template);
return Response.create(Response.RES_STATUS_SUCCESS,"123",JSONObject.create().put("template",template));
}
}
Loading…
Cancel
Save