完成阿里云短信服务信息查询的功能
This commit is contained in:
parent
1619cf9196
commit
87aed0f600
@ -75,12 +75,9 @@ public class XhpcSmsController extends BaseController {
|
|||||||
xhpcSmsService.sendNotice(phone, signatureName, templateId, paramMap);
|
xhpcSmsService.sendNotice(phone, signatureName, templateId, paramMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping(value = "/getAliyunShortMessageInfo")
|
@GetMapping(value = "/getAliyunShortMessageInfo")
|
||||||
public AjaxResult getAliyunShortMessageInfo() {
|
public AjaxResult getAliyunShortMessageInfo() {
|
||||||
|
|
||||||
Object messageInfo = xhpcSmsService.getAliyunShortMessageInfo();
|
Object messageInfo = xhpcSmsService.getAliyunShortMessageInfo();
|
||||||
return AjaxResult.success();
|
return AjaxResult.success(messageInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,7 +37,7 @@ public interface XhpcSmsMapper {
|
|||||||
Long querySumOfSuccessMessage();
|
Long querySumOfSuccessMessage();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询发送的短信的总记录数
|
* 查询所有发送的短信的总记录数(包括异常,失败)
|
||||||
*
|
*
|
||||||
* @return 返回发送过的短信的总记录数
|
* @return 返回发送过的短信的总记录数
|
||||||
* @author WH
|
* @author WH
|
||||||
|
|||||||
@ -26,6 +26,7 @@ import java.util.regex.Pattern;
|
|||||||
* @author yuyang
|
* @author yuyang
|
||||||
* @date 2021/7/30 18:50
|
* @date 2021/7/30 18:50
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class XhpcSmsServiceImpl implements IXhpcSmsService {
|
public class XhpcSmsServiceImpl implements IXhpcSmsService {
|
||||||
|
|
||||||
@ -82,6 +83,7 @@ public class XhpcSmsServiceImpl implements IXhpcSmsService {
|
|||||||
String token = "token:" + phone;
|
String token = "token:" + phone;
|
||||||
logger.info("------------------------------");
|
logger.info("------------------------------");
|
||||||
String cacheObject = REDIS.getCacheObject(token);
|
String cacheObject = REDIS.getCacheObject(token);
|
||||||
|
System.out.println("过了redis");
|
||||||
if (cacheObject != null) {
|
if (cacheObject != null) {
|
||||||
return AjaxResult.error("1012", "操作过于频繁,请于1分钟后重试");
|
return AjaxResult.error("1012", "操作过于频繁,请于1分钟后重试");
|
||||||
}
|
}
|
||||||
@ -162,6 +164,19 @@ public class XhpcSmsServiceImpl implements IXhpcSmsService {
|
|||||||
xhpcSmsMapper.addXhpcSms(xhpcSms);
|
xhpcSmsMapper.addXhpcSms(xhpcSms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getAliyunShortMessageInfo() {
|
||||||
|
|
||||||
|
Long successMessage = xhpcSmsMapper.querySumOfSuccessMessage();
|
||||||
|
Long failMessage = xhpcSmsMapper.querySumOfFailMessage();
|
||||||
|
Long sumOfMessage = successMessage + failMessage;
|
||||||
|
Map<String, Long> messageInfoMap = new HashMap<>();
|
||||||
|
messageInfoMap.put("successMessage", successMessage);
|
||||||
|
messageInfoMap.put("failMessage", failMessage);
|
||||||
|
messageInfoMap.put("sumOfMessage", sumOfMessage);
|
||||||
|
return messageInfoMap;
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
for (int i = 0; i < 50; i++) {
|
for (int i = 0; i < 50; i++) {
|
||||||
@ -198,39 +213,20 @@ public class XhpcSmsServiceImpl implements IXhpcSmsService {
|
|||||||
String templateParam = JSONUtil.toJsonStr(paramMap);
|
String templateParam = JSONUtil.toJsonStr(paramMap);
|
||||||
sendSmsRequest.setTemplateParam(templateParam);
|
sendSmsRequest.setTemplateParam(templateParam);
|
||||||
SendSmsResponse sendSmsResponse = client.sendSms(sendSmsRequest);
|
SendSmsResponse sendSmsResponse = client.sendSms(sendSmsRequest);
|
||||||
|
|
||||||
//获取发送结果状态码
|
//获取发送结果状态码
|
||||||
String statusCode = sendSmsResponse.getBody().getCode();
|
String statusCode = sendSmsResponse.getBody().getCode();
|
||||||
//获取短信的Biz号
|
|
||||||
//String bizId = sendSmsResponse.getBody().getBizId();
|
|
||||||
//获取短信的发送日期,并将其转换为yyyyMMdd的格式
|
|
||||||
//String date = sendSmsResponse.getHeaders().get("date");
|
|
||||||
//Date realDate = new Date(date);
|
|
||||||
//SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
|
||||||
//String formatData = sdf.format(realDate);
|
|
||||||
|
|
||||||
//获取实际的模板内容
|
//获取实际的模板内容
|
||||||
String templateContent = getTemplateContent(templateId, paramMap);
|
String templateContent = getTemplateContent(templateId, paramMap);
|
||||||
|
|
||||||
// //获取所发送的模板信息
|
|
||||||
// QuerySendDetailsRequest querySendDetailsRequest = new QuerySendDetailsRequest();
|
|
||||||
// querySendDetailsRequest.setPhoneNumber(phone);
|
|
||||||
// querySendDetailsRequest.setBizId(bizId);
|
|
||||||
// querySendDetailsRequest.setSendDate(formatData);
|
|
||||||
// querySendDetailsRequest.setCurrentPage(1L);
|
|
||||||
// querySendDetailsRequest.setPageSize(10L);
|
|
||||||
// Thread.sleep(400);
|
|
||||||
// String templateContent = client.querySendDetails(querySendDetailsRequest).getBody().getSmsSendDetailDTOs().getSmsSendDetailDTO().get(0).getContent();
|
|
||||||
|
|
||||||
//获取阿里云的返回值json字符串
|
//获取阿里云的返回值json字符串
|
||||||
SendSmsResponseBody body = sendSmsResponse.getBody();
|
SendSmsResponseBody body = sendSmsResponse.getBody();
|
||||||
String jsonResult = JSONUtil.toJsonStr(body);
|
String jsonResult = JSONUtil.toJsonStr(body);
|
||||||
|
System.out.println("阿里云返回值的json字符串=============》" + jsonResult);
|
||||||
//存放后面需要使用的返回值
|
//存放后面需要使用的返回值
|
||||||
HashMap<String, String> valueParam = new HashMap<>();
|
HashMap<String, String> valueParam = new HashMap<>();
|
||||||
valueParam.put("statusCode", statusCode);
|
valueParam.put("statusCode", statusCode);
|
||||||
valueParam.put("templateContent", templateContent);
|
valueParam.put("templateContent", templateContent);
|
||||||
valueParam.put("jsonResult", jsonResult);
|
valueParam.put("jsonResult", jsonResult);
|
||||||
|
System.out.println(("valueParam的值===========》" + valueParam));
|
||||||
return valueParam;
|
return valueParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user