Commit 25a9fc00 authored by qinxunjia's avatar qinxunjia

优化

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