短信统计,写了三个Mapper方法
This commit is contained in:
parent
ed876cdb1f
commit
77f99d897d
@ -25,7 +25,7 @@ public class XhpcSmsController extends BaseController {
|
||||
* 注册获取手机号验证码
|
||||
*/
|
||||
@GetMapping(value = "/getLogonPhoneCode")
|
||||
public AjaxResult getLogonPhoneCode(@RequestParam("phone") String phone) throws Exception {
|
||||
public AjaxResult getLogonPhoneCode(@RequestParam("phone") String phone) {
|
||||
|
||||
String signatureName = null;
|
||||
String templateId = null;
|
||||
@ -75,4 +75,12 @@ public class XhpcSmsController extends BaseController {
|
||||
xhpcSmsService.sendNotice(phone, signatureName, templateId, paramMap);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping(value = "/getAliyunShortMessageInfo")
|
||||
public AjaxResult getAliyunShortMessageInfo() {
|
||||
|
||||
Object messageInfo = xhpcSmsService.getAliyunShortMessageInfo();
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -14,6 +14,37 @@ public interface XhpcSmsMapper {
|
||||
|
||||
int addXhpcSms(XhpcSms xhpcSms);
|
||||
|
||||
List<Map<String, Object>> getList(@Param("status") Integer status, @Param("phone") String phone);
|
||||
|
||||
/**
|
||||
* 查询阿里云中发送失败的短信条数
|
||||
*
|
||||
* @return 返回发送失败的条数
|
||||
* @author WH
|
||||
* @date 2021/11/29 14:11
|
||||
* @since version-1.0
|
||||
*/
|
||||
Long querySumOfFailMessage();
|
||||
|
||||
/**
|
||||
* 查询阿里云中的发送成功的短信条数
|
||||
*
|
||||
* @return 发送成功的短信的条数
|
||||
* @author WH
|
||||
* @date 2021/11/29
|
||||
* @since version-1.0
|
||||
*/
|
||||
Long querySumOfSuccessMessage();
|
||||
|
||||
/**
|
||||
* 查询发送的短信的总记录数
|
||||
*
|
||||
* @return 返回发送过的短信的总记录数
|
||||
* @author WH
|
||||
* @date 2021/11/29 14:25
|
||||
* @since version-1.0
|
||||
*/
|
||||
Long querySumOfMessage();
|
||||
|
||||
|
||||
List<Map<String,Object>> getList(@Param("status") Integer status,@Param("phone") String phone);
|
||||
}
|
||||
|
||||
@ -46,4 +46,15 @@ public interface IXhpcSmsService {
|
||||
* @param paramMap 模板中的参数
|
||||
*/
|
||||
void sendNotice(String phone, String signatureName, String templateId, Map<String, String> paramMap);
|
||||
|
||||
/**
|
||||
* 获取阿里云短信服务信息
|
||||
*
|
||||
* @return 一个装有阿里云短信信息的对象
|
||||
* @author WH
|
||||
* @date 2021/11/29 10:31
|
||||
* @since version-1.0
|
||||
*/
|
||||
Object getAliyunShortMessageInfo();
|
||||
|
||||
}
|
||||
|
||||
@ -10,11 +10,11 @@ import com.xhpc.common.redis.service.RedisService;
|
||||
import com.xhpc.general.domain.XhpcSms;
|
||||
import com.xhpc.general.mapper.XhpcSmsMapper;
|
||||
import com.xhpc.general.util.sms.SmsUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Matcher;
|
||||
@ -24,6 +24,7 @@ import java.util.regex.Pattern;
|
||||
* @author yuyang
|
||||
* @date 2021/7/30 18:50
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class XhpcSmsServiceImpl implements IXhpcSmsService {
|
||||
|
||||
@ -78,12 +79,20 @@ public class XhpcSmsServiceImpl implements IXhpcSmsService {
|
||||
//用户频繁调用的判断的Key
|
||||
String token = "token:" + phone;
|
||||
String cacheObject = REDIS.getCacheObject(token);
|
||||
System.out.println("过了redis");
|
||||
if (cacheObject != null) {
|
||||
return AjaxResult.error("1012", "操作过于频繁,请于1分钟后重试");
|
||||
}
|
||||
|
||||
//使用阿里云发送通知短信
|
||||
Map<String, String> neededParam = aliyunSmsNotice(phone, signatureName, templateId, paramMap);
|
||||
Map<String, String> neededParam = null;
|
||||
try {
|
||||
neededParam = aliyunSmsNotice(phone, signatureName, templateId, paramMap);
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
throw new RuntimeException("阿里短信服务异常,neededParam为null");
|
||||
}
|
||||
System.out.println("过了阿里云");
|
||||
|
||||
if (!"".equals(random) && random != null) {
|
||||
xhpcSms.setCode(random);
|
||||
@ -155,6 +164,12 @@ public class XhpcSmsServiceImpl implements IXhpcSmsService {
|
||||
xhpcSmsMapper.addXhpcSms(xhpcSms);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getAliyunShortMessageInfo() {
|
||||
//todo
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
for (int i = 0; i < 50; i++) {
|
||||
@ -191,39 +206,20 @@ public class XhpcSmsServiceImpl implements IXhpcSmsService {
|
||||
String templateParam = JSONUtil.toJsonStr(paramMap);
|
||||
sendSmsRequest.setTemplateParam(templateParam);
|
||||
SendSmsResponse sendSmsResponse = client.sendSms(sendSmsRequest);
|
||||
|
||||
//获取发送结果状态码
|
||||
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);
|
||||
|
||||
// //获取所发送的模板信息
|
||||
// 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字符串
|
||||
SendSmsResponseBody body = sendSmsResponse.getBody();
|
||||
String jsonResult = JSONUtil.toJsonStr(body);
|
||||
|
||||
System.out.println("阿里云返回值的json字符串=============》" + jsonResult);
|
||||
//存放后面需要使用的返回值
|
||||
HashMap<String, String> valueParam = new HashMap<>();
|
||||
valueParam.put("statusCode", statusCode);
|
||||
valueParam.put("templateContent", templateContent);
|
||||
valueParam.put("jsonResult", jsonResult);
|
||||
System.out.println(("valueParam的值===========》" + valueParam));
|
||||
return valueParam;
|
||||
}
|
||||
|
||||
|
||||
@ -98,7 +98,7 @@
|
||||
phone,
|
||||
content,
|
||||
status,
|
||||
create_time as createTime
|
||||
create_time as createTime
|
||||
from xhpc_sms
|
||||
where del_flag=0
|
||||
<if test="null!=status">
|
||||
@ -108,4 +108,29 @@
|
||||
and phone like concat('%',#{phone},'%')
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="querySumOfFailMessage" resultType="java.lang.Long">
|
||||
|
||||
SELECT count(sms_id)
|
||||
FROM xhpc_sms
|
||||
WHERE status = 1
|
||||
AND del_flag = 0
|
||||
|
||||
</select>
|
||||
|
||||
<select id="querySumOfSuccessMessage" resultType="java.lang.Long">
|
||||
|
||||
SELECT count(sms_id)
|
||||
FROM xhpc_sms
|
||||
WHERE remark LIKE "%bizId%"
|
||||
AND del_flag = 0
|
||||
|
||||
</select>
|
||||
|
||||
<select id="querySumOfMessage" resultType="java.lang.Long">
|
||||
SELECT count(sms_id)
|
||||
FROM `xhpc_sms`
|
||||
WHERE del_flag = 0
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user