Commit 25a9fc00 authored by qinxunjia's avatar qinxunjia

优化

parent 01b28df6
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<groupId>org.example</groupId> <groupId>org.example</groupId>
<artifactId>sms-plugin</artifactId> <artifactId>sms-plugin</artifactId>
<version>1.0.4</version> <version>1.0.5</version>
<name>插件服务</name> <name>插件服务</name>
<description>DM hub集成插件服务</description> <description>DM hub集成插件服务</description>
......
...@@ -66,6 +66,10 @@ public class MessageServiceImpl implements MessageService { ...@@ -66,6 +66,10 @@ public class MessageServiceImpl implements MessageService {
String templateId = null; String templateId = null;
try { try {
String templateContent = requestDTO.getTemplateContent(); String templateContent = requestDTO.getTemplateContent();
boolean baseCheck = this.checkSendContent(templateContent);
if (baseCheck) {
return new DmHubResponse("500", "短信模板不能包含换行符");
}
String signature = requestDTO.getSignature(); String signature = requestDTO.getSignature();
String smsType = requestDTO.getSmsType(); String smsType = requestDTO.getSmsType();
String tenantId = requestDTO.getTenantId(); String tenantId = requestDTO.getTenantId();
...@@ -85,8 +89,9 @@ public class MessageServiceImpl implements MessageService { ...@@ -85,8 +89,9 @@ public class MessageServiceImpl implements MessageService {
.eq("tenant_id", tenantId) .eq("tenant_id", tenantId)
); );
if (dbInfo != null) { if (dbInfo != null) {
log.error("Dm Hub请求创建模板,模板id已存在,模板id:【{}】", templateId); // log.error("Dm Hub请求创建模板,模板id已存在,模板id:【{}】", templateId);
return new DmHubResponse(ResponseCode.TEMPLATE_ALREADY_EXISTED); // return new DmHubResponse(ResponseCode.TEMPLATE_ALREADY_EXISTED);
smsTemplateService.deleteById(dbInfo.getId());
} }
String areaId = messageMapper.selectAreaId(); String areaId = messageMapper.selectAreaId();
if (StringUtils.isBlank(areaId)) { if (StringUtils.isBlank(areaId)) {
...@@ -130,9 +135,6 @@ public class MessageServiceImpl implements MessageService { ...@@ -130,9 +135,6 @@ public class MessageServiceImpl implements MessageService {
updateInfo.setId(pkID); updateInfo.setId(pkID);
smsTemplateService.updateById(updateInfo); smsTemplateService.updateById(updateInfo);
return new DmHubResponse(ResponseCode.SUCCESS); return new DmHubResponse(ResponseCode.SUCCESS);
} else {
boolean b = smsTemplateService.deleteById(info.getId());
return new DmHubResponse(code, msg);
} }
} }
} catch (Exception exception) { } catch (Exception exception) {
...@@ -144,13 +146,21 @@ public class MessageServiceImpl implements MessageService { ...@@ -144,13 +146,21 @@ public class MessageServiceImpl implements MessageService {
return responseDTO; return responseDTO;
} }
/***
* 校验初始模板内容
* @param templateContent
*/
private boolean checkSendContent(String templateContent) {
return templateContent.contains("\n");
}
public static void main(String[] args) { public static void main(String[] args) {
String str = "dafdsfadsfadfadf]"; String str = "dafdsfads\nfadfadf";
String regEx = "[\\[\\]()()【】]"; String regEx = "[\\[\\]()()【】]";
Pattern p = Pattern.compile(regEx); if (str.contains("\n")) {
Matcher m = p.matcher(str); String a = "";
boolean b = m.find(); }
System.out.println(b);
} }
private boolean checkContent(String upCreateStr) { private boolean checkContent(String upCreateStr) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment