短信服务集成

This commit is contained in:
xy
2026-04-21 16:10:35 +08:00
parent 8041c5f27e
commit f5b97d83b3
9 changed files with 139 additions and 103 deletions

View File

@@ -3,7 +3,9 @@ package com.njcn.access.utils;
import com.alibaba.nacos.shaded.com.google.gson.Gson;
import com.njcn.access.pojo.dto.NoticeUserDto;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.io.BufferedReader;
@@ -21,12 +23,17 @@ import java.nio.charset.StandardCharsets;
@Component
@Slf4j
@AllArgsConstructor
@RequiredArgsConstructor
public class SendMessageUtil {
@Value("${app.sendUrl:https://fc-mp-ff7b310f-94c9-4468-8260-109111c0a6b2.next.bspapp.com/push}")
private String appSendUrl;
//App客户端消息推送
public void sendEventToUser(NoticeUserDto noticeUserDto) {
try {
// 创建一个URL对象指定目标HTTPS接口地址
URL url = new URL("https://fc-mp-ff7b310f-94c9-4468-8260-109111c0a6b2.next.bspapp.com/push");
URL url = new URL(appSendUrl);
// 打开HTTPS连接
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
// 设置请求方法为POST