添加短信猫
This commit is contained in:
@@ -194,6 +194,7 @@
|
||||
class="home__danger-text"
|
||||
type="text"
|
||||
size="mini"
|
||||
|
||||
:loading="isDeleting(scope.row)"
|
||||
:disabled="isSaving(scope.row) || isDeleting(scope.row)"
|
||||
>
|
||||
@@ -611,6 +612,7 @@ export default {
|
||||
|
||||
.home__danger-text {
|
||||
color: #f56c6c;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
:global(.home__message-box--mobile-center) {
|
||||
|
||||
@@ -9,6 +9,16 @@ public class Registration {
|
||||
private String powerType;
|
||||
private String note;
|
||||
private String status;
|
||||
private String msgId;
|
||||
|
||||
public String getMsgId() {
|
||||
return msgId;
|
||||
}
|
||||
|
||||
public void setMsgId(String msgId) {
|
||||
this.msgId = msgId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件访问链接
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
package com.reg.server.registration;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.core.net.URLEncodeUtil;
|
||||
|
||||
import javax.xml.xpath.XPath;
|
||||
import javax.xml.xpath.XPathConstants;
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
|
||||
import com.aliyun.tea.TeaException;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -79,6 +86,31 @@ public class RegistrationController {
|
||||
if ("已登记".equals(registration.getStatus().trim()) && registration.getFileName() != null) {
|
||||
urlPath = RandomUtil.randomString(5);
|
||||
registration.setUrlPath(urlPath);
|
||||
// 发送短信通知
|
||||
String smsUrl = "http://172.27.77.221:8060/send";
|
||||
|
||||
String text = "【国家电网】尊敬的" + registration.getCustomerName() + ",感谢您的支持!您咨询的业务办理详情可点击:" + "http://192.168.32.24:8080/#/getfile/"+urlPath+"查阅。";
|
||||
String fullUrl = smsUrl + "?password=1&recipient=" + registration.getContact() + "&text=" + URLEncodeUtil.encode(text) + "&encoding=U";
|
||||
String response = HttpUtil.get(fullUrl);
|
||||
// 解析 XML 响应
|
||||
try {
|
||||
XPathFactory xPathFactory = XPathFactory.newInstance();
|
||||
XPath xpath = xPathFactory.newXPath();
|
||||
javax.xml.parsers.DocumentBuilderFactory factory = javax.xml.parsers.DocumentBuilderFactory.newInstance();
|
||||
javax.xml.parsers.DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
org.w3c.dom.Document doc = builder.parse(new org.xml.sax.InputSource(new java.io.StringReader(response)));
|
||||
String error = xpath.evaluate("//send/error/text()", doc);
|
||||
if (!"0".equals(error)) {
|
||||
throw new Exception("短信发送失败!状态码:" + error);
|
||||
}
|
||||
String messageStatus = xpath.evaluate("//send/message_status/text()", doc);
|
||||
String msgId = xpath.evaluate("//send/msg_id/text()", doc);
|
||||
System.out.println("短信发送结果 error=" + error + ", message_status=" + messageStatus + "msgId=" + msgId);
|
||||
registration.setMsgId(msgId);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return ResponseEntity.badRequest().build();
|
||||
}
|
||||
}
|
||||
boolean updated = service.update(id, registration);
|
||||
return updated ? ResponseEntity.noContent().build() : ResponseEntity.notFound().build();
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
<result property="status" column="status"/>
|
||||
<result property="fileName" column="file_name"/>
|
||||
<result property="urlPath" column="url_path" />
|
||||
<result property="msgId" column="msg_id" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
|
||||
@@ -22,12 +23,12 @@
|
||||
</insert>
|
||||
|
||||
<select id="findById" resultMap="registrationResultMap">
|
||||
SELECT id, register_time, customer_name, contact, service_type, power_type, note, status, file_name,url_path
|
||||
SELECT id, register_time, customer_name, contact, service_type, power_type, note, status, file_name,url_path,msg_id
|
||||
FROM registrations WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="findAll" resultMap="registrationResultMap">
|
||||
SELECT id, register_time, customer_name, contact, service_type, power_type, note, status, file_name,url_path
|
||||
SELECT id, register_time, customer_name, contact, service_type, power_type, note, status, file_name,url_path,msg_id
|
||||
FROM registrations ORDER BY register_time DESC
|
||||
</select>
|
||||
|
||||
@@ -41,7 +42,8 @@
|
||||
note = #{note},
|
||||
status = #{status},
|
||||
file_name = #{fileName},
|
||||
url_path = #{urlPath}
|
||||
url_path = #{urlPath},
|
||||
msg_id = #{msgId}
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user