Commit 4651db99 authored by qinxunjia's avatar qinxunjia

短信插件的优化

parent b90775e7
......@@ -40,19 +40,25 @@ public class DmHubApi {
* @return
*/
@PostMapping("/sms/template")
public void template(@RequestBody DmHubTemplateRequest params, String appId, String timestamp, String signature) {
public String template(@RequestBody DmHubTemplateRequest params, String appId, String timestamp, String signature) {
log.info("**********创建模板接口入参*******:{},\r\n appId:{},timestamp:{},signature:{}", JSONObject.toJSONString(params), appId, timestamp, signature);
DmHubResponse response;
try {
boolean checkResult = this.checkSignature(timestamp, signature);
if (!checkResult) {
xiaoShuService.updateDmhubSmsTempStatus(REJECTED, params.getTemplateId(), "接口请求签名校验不通过");
log.info("**********创建模板接口出参*******:{}", "接口请求签名校验不通过");
return JSONObject.toJSONString(new DmHubResponse("999", "接口请求签名校验不通过"));
}
DmHubResponse dmHubResponse = messageService.createTemplate(params);
if (ResponseCode.SUCCESS.getCode().equals(dmHubResponse.getCode())) {
String retJson = JSONObject.toJSONString(new TemplateResponse());
log.info("返回内容:{}", retJson);
return retJson;
} else {
return JSONObject.toJSONString(dmHubResponse);
}
messageService.createTemplate(params);
} catch (Exception e) {
log.error("创建模板短信异常", e);
new DmHubResponse("999", "创建模板短信异常");
return JSONObject.toJSONString(new DmHubResponse("999", "创建模板短信异常"));
}
}
......
package com.bgy.sms.channel.dto;
public class TemplateResponse {
private String status;
public TemplateResponse() {
status = "applying";
}
public void setStatus(String status) {
this.status = status;
}
public String getStatus() {
return status;
}
}
......@@ -81,7 +81,6 @@ public class MessageServiceImpl implements MessageService {
);
if (dbInfo != null) {
log.error("Dm Hub请求创建模板,模板id已存在,模板id:【{}】", templateId);
xiaoShuService.updateDmhubSmsTempStatus(REJECTED, templateId, "模板id已存在,请重新创建");
return new DmHubResponse(ResponseCode.TEMPLATE_ALREADY_EXISTED);
}
SmsTemplateInfo info = new SmsTemplateInfo();
......@@ -99,8 +98,6 @@ public class MessageServiceImpl implements MessageService {
info.setParams(params);
boolean insert = smsTemplateService.insert(info);
if (!insert) {
log.error("模板插入DB异常:【{}】", JSONObject.toJSONString(info));
xiaoShuService.updateDmhubSmsTempStatus(REJECTED, templateId, "插件系统异常");
return new DmHubResponse(ResponseCode.SYSTEM_ERROR);
} else {
String pkID = info.getId();
......@@ -113,7 +110,6 @@ public class MessageServiceImpl implements MessageService {
CLBizResponse response = new CLBizResponse();
String account = xiaoShuService.selectUserIdByTemplate(templateId);
if (StringUtils.isBlank(account)) {
xiaoShuService.updateDmhubSmsTempStatus(REJECTED, templateId, "未找到当前登录用户的售楼系统ID");
return new DmHubResponse(ResponseCode.NO_USER_ID);
}
response = bgySmsService.createTemplate(upCreateStr, account, TEMPLATETYPE, pkID);
......@@ -126,14 +122,12 @@ public class MessageServiceImpl implements MessageService {
smsTemplateService.updateById(updateInfo);
return new DmHubResponse(ResponseCode.SUCCESS);
} else {
xiaoShuService.updateDmhubSmsTempStatus(REJECTED, templateId, msg);
return new DmHubResponse(code, msg);
}
}
} catch (Exception exception) {
log.error("创建模板业务逻辑异常,错误信息", exception);
if (!StringUtils.isBlank(templateId)) {
xiaoShuService.updateDmhubSmsTempStatus(REJECTED, templateId, "插件系统异常");
}
responseDTO = new DmHubResponse(ResponseCode.SYSTEM_ERROR);
}
......
......@@ -8,8 +8,8 @@ info:
spring:
profiles:
# active: test
active: ${sms-active}
active: test
# active: ${sms-active}
mybatis-plus:
mapper-locations: classpath:mapper/*.xml
......
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