use of com.aliyun.dysmsapi20170525.Client in project eladmin by lWoHvYe.
the class DySMSUtil method querySendDetails.
/**
* 查询结果
*
* @param phoneNumbers
* @param bizId
* @date 2021/11/7 12:52 下午
*/
@SneakyThrows
public static void querySendDetails(@NotNull String phoneNumbers, String bizId) {
Client client = DySMSUtil.createClient();
// 3.查询结果
for (String phoneNum : phoneNumbers.split(",")) {
QuerySendDetailsRequest queryReq = new QuerySendDetailsRequest().setPhoneNumber(phoneNum.trim()).setBizId(bizId).setSendDate(DateUtil.today()).setPageSize(10L).setCurrentPage(1L);
QuerySendDetailsResponse queryResp = client.querySendDetails(queryReq);
var dtos = queryResp.body.smsSendDetailDTOs.smsSendDetailDTO;
// 打印结果
for (var dto : dtos) {
if (ObjectUtil.equals(dto.sendStatus, 3L)) {
log.info(" {} 发送成功,接收时间: {} ", dto.phoneNum, dto.receiveDate);
} else if (ObjectUtil.equals(dto.sendStatus, 2L)) {
log.info(" {} 发送失败", dto.phoneNum);
} else {
log.info(" {} 正在发送中...", dto.phoneNum);
}
}
}
}
use of com.aliyun.dysmsapi20170525.Client in project knife-starter by 1120023921.
the class KnifeSmsAliSenderContextImpl method buildClient.
private Client buildClient(AliAccount aliAccount) throws AliClientException {
final Config config = new Config().setAccessKeyId(aliAccount.getAccessKeyId()).setAccessKeySecret(aliAccount.getAccessSecret());
// 访问的域名
config.endpoint = "dysmsapi.aliyuncs.com";
try {
return new Client(config);
} catch (Exception e) {
throw new AliClientException("构造阿里云短信Client失败");
}
}
use of com.aliyun.dysmsapi20170525.Client in project tansci by typ1805.
the class AliSmsServiceImpl method querySmsTemplate.
/**
* @MonthName: querySmsTemplate
* @Description: 查询短信模板的审核状态
* @Author: tanyp
* @Date: 2021/6/7 14:50
* @Param: [template]
* @return: MessageVo
*/
@Override
public MessageVo querySmsTemplate(SmsTemplateDto template) {
try {
log.info("======查询短信模板的审核状态,请求参数:{}", JSON.toJSON(template));
Client client = createClient();
QuerySmsTemplateRequest request = new QuerySmsTemplateRequest();
request.setTemplateCode(template.getTemplateCode());
QuerySmsTemplateResponse res = client.querySmsTemplate(request);
if (Objects.equals(Constants.NEWS_SUCCESS_CODE, res.body.getCode())) {
log.info("======查询短信模板的审核状态,返回值:{}", JSON.toJSON(res.body));
return MessageVo.builder().code(Constants.NEWS_SUCCESS_CODE).message(Constants.NEWS_SUCCESS_MESSAGE).state(res.body.getTemplateStatus()).templateCode(res.body.templateCode).reason(res.body.reason).build();
} else {
log.info("======查询短信模板的审核状态,返回值:{}", JSON.toJSON(res.body));
return MessageVo.builder().code(Constants.NEWS_FAIL_CODE).message(Constants.NEWS_FAIL_MESSAGE).build();
}
} catch (Exception e) {
log.error("======查询短信模板的审核状态,异常:{}", e.getMessage());
e.printStackTrace();
return MessageVo.builder().code(Constants.NEWS_FAIL_CODE).message(Constants.NEWS_FAIL_MESSAGE).build();
}
}
use of com.aliyun.dysmsapi20170525.Client in project tansci by typ1805.
the class AliSmsServiceImpl method addSmsTemplate.
/**
* @MonthName: addSmsTemplate
* @Description: 申请短信模板
* @Author: tanyp
* @Date: 2021/6/7 14:50
* @Param: [template]
* @return: MessageVo
*/
@Override
public MessageVo addSmsTemplate(SmsTemplateDto template) {
try {
log.info("======申请短信模板,请求参数:{}", JSON.toJSON(template));
Client client = createClient();
AddSmsTemplateRequest request = new AddSmsTemplateRequest();
request.setTemplateType(template.getTemplateType());
request.setTemplateName(template.getTemplateName());
request.setTemplateContent(template.getTemplateContent());
request.setRemark(template.getRemark());
AddSmsTemplateResponse res = client.addSmsTemplate(request);
if (Objects.equals(Constants.NEWS_SUCCESS_CODE, res.body.getCode())) {
log.info("======申请短信模板,返回值:{}", JSON.toJSON(res.body));
return MessageVo.builder().code(Constants.NEWS_SUCCESS_CODE).message(Constants.NEWS_SUCCESS_MESSAGE).templateCode(res.getBody().templateCode).build();
} else {
log.info("======申请短信模板,返回值:{}", JSON.toJSON(res.body));
return MessageVo.builder().code(Constants.NEWS_FAIL_CODE).message(Constants.NEWS_FAIL_MESSAGE).build();
}
} catch (Exception e) {
log.error("======申请短信模板,异常:{}", e.getMessage());
e.printStackTrace();
return MessageVo.builder().code(Constants.NEWS_FAIL_CODE).message(Constants.NEWS_FAIL_MESSAGE).build();
}
}
use of com.aliyun.dysmsapi20170525.Client in project tansci by typ1805.
the class AliSmsServiceImpl method deleteSmsTemplate.
/**
* @MonthName: deleteSmsTemplate
* @Description: 删除短信模板
* @Author: tanyp
* @Date: 2021/6/7 14:50
* @Param: [template]
* @return: MessageVo
*/
@Override
public MessageVo deleteSmsTemplate(SmsTemplateDto template) {
try {
log.info("======删除短信模板,请求参数:{}", JSON.toJSON(template));
Client client = createClient();
DeleteSmsTemplateRequest request = new DeleteSmsTemplateRequest();
request.setTemplateCode(template.getTemplateCode());
DeleteSmsTemplateResponse res = client.deleteSmsTemplate(request);
if (Objects.equals(Constants.NEWS_SUCCESS_CODE, res.body.getCode())) {
log.info("======删除短信模板,返回值:{}", JSON.toJSON(res.body));
return MessageVo.builder().code(Constants.NEWS_SUCCESS_CODE).message(Constants.NEWS_SUCCESS_MESSAGE).build();
} else {
log.info("======删除短信模板,返回值:{}", JSON.toJSON(res.body));
return MessageVo.builder().code(Constants.NEWS_FAIL_CODE).message(Constants.NEWS_FAIL_MESSAGE).build();
}
} catch (Exception e) {
log.error("======删除短信模板,异常:{}", e);
return MessageVo.builder().code(Constants.NEWS_FAIL_CODE).message(Constants.NEWS_FAIL_MESSAGE).build();
}
}
Aggregations