From 50d7f0a07fd3cf1711334ed697488186c95babaa Mon Sep 17 00:00:00 2001 From: wu Date: Tue, 24 Sep 2024 14:14:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0utils=E6=A8=A1=E5=9D=97;=20?= =?UTF-8?q?=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E6=A8=A1=E5=9D=97=E5=BC=95?= =?UTF-8?q?=E5=85=A5utils=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application-druid.yml | 2 +- alarm/pom.xml | 8 +++ alarm/src/main/resources/application-dev.yml | 2 +- fire/pom.xml | 8 +++ page/pom.xml | 9 +++ page/src/main/resources/application-dev.yml | 2 +- pom.xml | 1 + rescue/pom.xml | 8 +++ utils/pom.xml | 21 ++++++ utils/src/main/java/com/utils/SmsUtil.java | 64 +++++++++++++++++++ 10 files changed, 122 insertions(+), 3 deletions(-) create mode 100644 utils/pom.xml create mode 100644 utils/src/main/java/com/utils/SmsUtil.java diff --git a/RuoYi-Vue/ruoyi-admin/src/main/resources/application-druid.yml b/RuoYi-Vue/ruoyi-admin/src/main/resources/application-druid.yml index ce94fb1..717d999 100644 --- a/RuoYi-Vue/ruoyi-admin/src/main/resources/application-druid.yml +++ b/RuoYi-Vue/ruoyi-admin/src/main/resources/application-druid.yml @@ -48,7 +48,7 @@ spring: url-pattern: /druid/* # 控制台管理用户名和密码 login-username: ruoyi - login-password: 123456 + login-password: jichuang@123 filter: stat: enabled: true diff --git a/alarm/pom.xml b/alarm/pom.xml index 123dcc1..9ef63ba 100644 --- a/alarm/pom.xml +++ b/alarm/pom.xml @@ -17,6 +17,14 @@ UTF-8 + + + + com.yingji + utils + + + alarm diff --git a/alarm/src/main/resources/application-dev.yml b/alarm/src/main/resources/application-dev.yml index 39bad05..aaa5063 100644 --- a/alarm/src/main/resources/application-dev.yml +++ b/alarm/src/main/resources/application-dev.yml @@ -3,7 +3,7 @@ spring: datasource: url: jdbc:mysql://localhost:3306/algorithms?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 username: root - password: 123456 + password: jichuang@123 driverClassName: com.mysql.cj.jdbc.Driver diff --git a/fire/pom.xml b/fire/pom.xml index 478aa18..608d744 100644 --- a/fire/pom.xml +++ b/fire/pom.xml @@ -17,6 +17,14 @@ UTF-8 + + + + com.yingji + utils + + + fire diff --git a/page/pom.xml b/page/pom.xml index dff778d..d278003 100644 --- a/page/pom.xml +++ b/page/pom.xml @@ -16,6 +16,15 @@ 8 UTF-8 + + + + + com.yingji + utils + + + page diff --git a/page/src/main/resources/application-dev.yml b/page/src/main/resources/application-dev.yml index 1226d25..e8402b7 100644 --- a/page/src/main/resources/application-dev.yml +++ b/page/src/main/resources/application-dev.yml @@ -3,7 +3,7 @@ spring: datasource: url: jdbc:mysql://localhost:3306/algorithms?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 username: root - password: 123456 + password: jichuang@123 driverClassName: com.mysql.cj.jdbc.Driver diff --git a/pom.xml b/pom.xml index 4dbd5b4..b694479 100644 --- a/pom.xml +++ b/pom.xml @@ -13,6 +13,7 @@ rescue page fire + utils 1.8 diff --git a/rescue/pom.xml b/rescue/pom.xml index aadfc63..a8a4777 100644 --- a/rescue/pom.xml +++ b/rescue/pom.xml @@ -17,6 +17,14 @@ UTF-8 + + + + com.yingji + utils + + + rescue diff --git a/utils/pom.xml b/utils/pom.xml new file mode 100644 index 0000000..155d365 --- /dev/null +++ b/utils/pom.xml @@ -0,0 +1,21 @@ + + + 4.0.0 + + com.yingji + yingjiAlgorithms + 0.0.1-SNAPSHOT + + + utils + + + 8 + 8 + UTF-8 + + + + \ No newline at end of file diff --git a/utils/src/main/java/com/utils/SmsUtil.java b/utils/src/main/java/com/utils/SmsUtil.java new file mode 100644 index 0000000..f9dd42c --- /dev/null +++ b/utils/src/main/java/com/utils/SmsUtil.java @@ -0,0 +1,64 @@ +package com.utils; + +import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpRequest; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; + +import java.util.HashMap; +import java.util.Map; + +/** + * 短信通知工具类 + * + * @author wu + * @since 2024/9/24 10:18 + */ +public class SmsUtil { + + /** + * 获取短信接口token + * + * @return token + */ + public static String getSmsToken() { + Map bodyMap = new HashMap<>(); + bodyMap.put("uid", "yjglj_yjjyszzh"); + bodyMap.put("pwd", "f604d2d6de51573b5cef5c95c11ffabe"); + String bodyJson = JSONUtil.toJsonStr(bodyMap); + String responseStr = HttpRequest.post("http://2.46.42.43:80/admin-api/sms/token") + .body(bodyJson) + .execute() + .body(); + JSONObject responseJson = JSONUtil.parseObj(responseStr); + return (String) responseJson.get("data"); + } + + /** + * 发送短信 + * + * @param content 短信内容 + * @param tel 手机号多个使用,拼接 + * @return 响应类 + */ + public static Object sendSms(String content, String tel) { + String token = getSmsToken(); + Map bodyMap = new HashMap<>(); + bodyMap.put("uid", "yjglj_yjjyszzh"); + bodyMap.put("pwd", "f604d2d6de51573b5cef5c95c11ffabe"); + bodyMap.put("extensionNo", "2559"); + if (StrUtil.isNotEmpty(tel)) { + bodyMap.put("tel", tel); + } else { + bodyMap.put("tel", "18870257135,18261462112,15850922852,18112760590"); + } + bodyMap.put("content", "市应急局提醒: " + content); + String bodyJson = JSONUtil.toJsonStr(bodyMap); + String responseStr = HttpRequest.post("http://2.46.42.43:80/admin-api/sms/send") + .header("Authorization", token) + .body(bodyJson) + .execute() + .body(); + return JSONUtil.parseObj(responseStr); + } +}