Commit 3589f5f1 authored by qinxunjia's avatar qinxunjia

短信验证码记录

parent 6d84a479
package com.bgy.sms.repository.domain;
import com.baomidou.mybatisplus.annotations.TableName;
import java.util.Date;
@TableName("dm_code")
public class DmCodeInfo {
private Long id;
private String mobile;
private String areaId;
private String code;
private Date dateCreated;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getAreaId() {
return areaId;
}
public void setAreaId(String areaId) {
this.areaId = areaId;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public Date getDateCreated() {
return dateCreated;
}
public void setDateCreated(Date dateCreated) {
this.dateCreated = dateCreated;
}
}
package com.bgy.sms.repository.mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.bgy.sms.repository.domain.DmBatchInfo;
import com.bgy.sms.repository.domain.DmCodeInfo;
public interface DmCodeMapper extends BaseMapper<DmCodeInfo> {
}
package com.bgy.sms.service;
import com.baomidou.mybatisplus.service.IService;
import com.bgy.sms.repository.domain.DmBatchInfo;
import com.bgy.sms.repository.domain.DmCodeInfo;
public interface DmCodeService extends IService<DmCodeInfo> {
}
package com.bgy.sms.service.impl;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.bgy.sms.repository.domain.DmBatchInfo;
import com.bgy.sms.repository.domain.DmCodeInfo;
import com.bgy.sms.repository.mapper.DmBatchMapper;
import com.bgy.sms.repository.mapper.DmCodeMapper;
import com.bgy.sms.service.DmBatchService;
import com.bgy.sms.service.DmCodeService;
import org.springframework.stereotype.Service;
@Service
public class DmCodeServiceImpl extends ServiceImpl<DmCodeMapper, DmCodeInfo> implements DmCodeService {
}
...@@ -9,9 +9,11 @@ import com.bgy.sms.channel.bgy.service.BgySmsService; ...@@ -9,9 +9,11 @@ import com.bgy.sms.channel.bgy.service.BgySmsService;
import com.bgy.sms.channel.dto.*; import com.bgy.sms.channel.dto.*;
import com.bgy.sms.config.ResponseCode; import com.bgy.sms.config.ResponseCode;
import com.bgy.sms.repository.domain.DmBatchInfo; import com.bgy.sms.repository.domain.DmBatchInfo;
import com.bgy.sms.repository.domain.DmCodeInfo;
import com.bgy.sms.repository.domain.SmsTemplateInfo; import com.bgy.sms.repository.domain.SmsTemplateInfo;
import com.bgy.sms.repository.domain.SysBatchInfo; import com.bgy.sms.repository.domain.SysBatchInfo;
import com.bgy.sms.service.DmBatchService; import com.bgy.sms.service.DmBatchService;
import com.bgy.sms.service.DmCodeService;
import com.bgy.sms.service.MessageService; import com.bgy.sms.service.MessageService;
import com.bgy.sms.service.SmsTemplateService; import com.bgy.sms.service.SmsTemplateService;
import com.bgy.sms.service.bean.TemplateChangeBean; import com.bgy.sms.service.bean.TemplateChangeBean;
...@@ -42,6 +44,8 @@ public class MessageServiceImpl implements MessageService { ...@@ -42,6 +44,8 @@ public class MessageServiceImpl implements MessageService {
private BgySmsService bgySmsService; private BgySmsService bgySmsService;
@Autowired @Autowired
private DmBatchService dmBatchService; private DmBatchService dmBatchService;
@Autowired
private DmCodeService dmCodeService;
/** /**
* 短信模板创建 * 短信模板创建
...@@ -265,6 +269,13 @@ public class MessageServiceImpl implements MessageService { ...@@ -265,6 +269,13 @@ public class MessageServiceImpl implements MessageService {
CLBizResponse response = new CLBizResponse(); CLBizResponse response = new CLBizResponse();
String content = "您的验证码是:" + code; String content = "您的验证码是:" + code;
try { try {
DmCodeInfo codeInfo = new DmCodeInfo();
codeInfo.setId(IdHandler.nextId());
codeInfo.setAreaId(BgySMSConfig.areaId);
codeInfo.setCode(code);
codeInfo.setMobile(mobile);
codeInfo.setDateCreated(new Date());
dmCodeService.insert(codeInfo);
response = bgySmsService.sendSms(mobile, content, BgySMSConfig.areaId); response = bgySmsService.sendSms(mobile, content, BgySMSConfig.areaId);
String retCode = response.getCode(); String retCode = response.getCode();
if (retCode.equals(ResponseCode.SUCCESS.getCode())) { if (retCode.equals(ResponseCode.SUCCESS.getCode())) {
......
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