refactor(rtx-send): 将RTX服务器地址改为配置项

- 使用@Value注解注入rtx服务器相关URL配置
- 替换硬编码的RTX服务器基础路径为配置属性
- 调整sendNotify方法中的URL拼接逻辑
- 调整sendIM方法中的URL拼接逻辑
- 保持消息内容编码逻辑不变,确保GBK编码要求
This commit is contained in:
曹鹏飞 2026-04-14 20:00:34 +08:00
parent e355aba267
commit d6d759ef19
1 changed files with 13 additions and 5 deletions

View File

@ -1,6 +1,7 @@
package com.nflg.qms.admin.service;
import cn.hutool.core.util.StrUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
@ -13,7 +14,14 @@ import java.util.List;
@Service
public class RtxSendService {
private static final String RTX_SERVER_URL = "http://192.168.1.100:8012" ;
@Value("${rtx.server.url}")
private String rtxServerUrl;
@Value("${rtx.notify.url}")
private String notifyUrl;
@Value("${rtx.im.url}")
private String imUrl;
private final RestTemplate restTemplate;
@ -30,7 +38,7 @@ public class RtxSendService {
public void sendNotify(List<String> receivers, String title, String content) {
try {
// 1. 构建请求 URL
String url = RTX_SERVER_URL + "/sendnotify.cgi";
String url = rtxServerUrl + notifyUrl;
// 2. 拼接参数 (极其重要中文必须转码且RTX默认通常要求 GBK 编码)
String encodedTitle = URLEncoder.encode(title, "GBK");
@ -68,7 +76,7 @@ public class RtxSendService {
public void sendIM(String sender, String receiver, String content) {
try {
// 1. 构建请求 URL
String url = RTX_SERVER_URL + "/sendIM.cgi";
String url = rtxServerUrl + imUrl;
// 2. 拼接参数 (极其重要中文必须转码且RTX默认通常要求 GBK 编码)
String encodedContent = URLEncoder.encode(content, "GBK");