短信打印日志

This commit is contained in:
2265829957@qq.com 2021-11-29 18:23:39 +08:00
parent b9ea2cfedf
commit e696258984

View File

@ -10,6 +10,8 @@ import com.xhpc.common.redis.service.RedisService;
import com.xhpc.general.domain.XhpcSms; import com.xhpc.general.domain.XhpcSms;
import com.xhpc.general.mapper.XhpcSmsMapper; import com.xhpc.general.mapper.XhpcSmsMapper;
import com.xhpc.general.util.sms.SmsUtil; import com.xhpc.general.util.sms.SmsUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -31,6 +33,7 @@ public class XhpcSmsServiceImpl implements IXhpcSmsService {
public static final String accessKeyId = "LTAI5tBWjnuQGxGicnThwMF1"; public static final String accessKeyId = "LTAI5tBWjnuQGxGicnThwMF1";
public static final String accessKeySecret = "b0WNtFYtWyTEkZzcr2WOAPoZg6w2Xu"; public static final String accessKeySecret = "b0WNtFYtWyTEkZzcr2WOAPoZg6w2Xu";
private static final Logger logger = LoggerFactory.getLogger(XhpcSmsServiceImpl.class);
@Autowired @Autowired
private RedisService redisService; private RedisService redisService;
@Autowired @Autowired
@ -77,11 +80,12 @@ public class XhpcSmsServiceImpl implements IXhpcSmsService {
String pvToken = "pvToken:" + phone; String pvToken = "pvToken:" + phone;
//用户频繁调用的判断的Key //用户频繁调用的判断的Key
String token = "token:" + phone; String token = "token:" + phone;
logger.info("------------------------------");
String cacheObject = REDIS.getCacheObject(token); String cacheObject = REDIS.getCacheObject(token);
if (cacheObject != null) { if (cacheObject != null) {
return AjaxResult.error("1012", "操作过于频繁请于1分钟后重试"); return AjaxResult.error("1012", "操作过于频繁请于1分钟后重试");
} }
logger.info("------------------------------");
//使用阿里云发送通知短信 //使用阿里云发送通知短信
Map<String, String> neededParam = aliyunSmsNotice(phone, signatureName, templateId, paramMap); Map<String, String> neededParam = aliyunSmsNotice(phone, signatureName, templateId, paramMap);
@ -90,6 +94,7 @@ public class XhpcSmsServiceImpl implements IXhpcSmsService {
} }
xhpcSms.setPhone(phone); xhpcSms.setPhone(phone);
xhpcSms.setContent(neededParam.get("templateContent")); xhpcSms.setContent(neededParam.get("templateContent"));
logger.info("============================");
xhpcSms.setCreateTime(new Date()); xhpcSms.setCreateTime(new Date());
xhpcSms.setRemark(neededParam.get("jsonResult")); xhpcSms.setRemark(neededParam.get("jsonResult"));
@ -101,6 +106,7 @@ public class XhpcSmsServiceImpl implements IXhpcSmsService {
REDIS.setCacheObject(token, random, 60L, TimeUnit.SECONDS); REDIS.setCacheObject(token, random, 60L, TimeUnit.SECONDS);
xhpcSms.setStatus(0); xhpcSms.setStatus(0);
xhpcSmsMapper.addXhpcSms(xhpcSms); xhpcSmsMapper.addXhpcSms(xhpcSms);
logger.info("****************************");
return AjaxResult.success(); return AjaxResult.success();
} else { } else {
xhpcSms.setStatus(1); xhpcSms.setStatus(1);
@ -108,6 +114,7 @@ public class XhpcSmsServiceImpl implements IXhpcSmsService {
return AjaxResult.error(1012, "服务器繁忙,请稍后再试"); return AjaxResult.error(1012, "服务器繁忙,请稍后再试");
} }
} catch (Exception e) { } catch (Exception e) {
logger.info("++++++++++++++++++++++++++++");
e.printStackTrace(); e.printStackTrace();
xhpcSms.setStatus(3); xhpcSms.setStatus(3);
xhpcSmsMapper.addXhpcSms(xhpcSms); xhpcSmsMapper.addXhpcSms(xhpcSms);