fix: 增加一个批量发送验证码功能
This commit is contained in:
parent
8038df7dcf
commit
ae34d93001
@ -124,6 +124,24 @@ public class SmsVerifyCodeController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送验证码
|
||||||
|
*/
|
||||||
|
@PostMapping("/batchSendContent")
|
||||||
|
@Operation(summary = "发送验证码")
|
||||||
|
public ResponseResult batchSendContent(@RequestBody SmsVerifyCodeRequest smsVerifyCodeRequest) {
|
||||||
|
|
||||||
|
List<String> phoneList = smsVerifyCodeRequest.getPhoneList();
|
||||||
|
if(phoneList==null){
|
||||||
|
return ResponseResult.error("手机号不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
smsVerifyCodeService.batchSendContent(phoneList, smsVerifyCodeRequest.getContent());
|
||||||
|
return ResponseResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册用户
|
* 注册用户
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -3,6 +3,8 @@ package com.yfd.platform.system.domain;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class SmsVerifyCodeRequest {
|
public class SmsVerifyCodeRequest {
|
||||||
|
|
||||||
@ -61,5 +63,9 @@ public class SmsVerifyCodeRequest {
|
|||||||
*/
|
*/
|
||||||
private String stationCode;
|
private String stationCode;
|
||||||
|
|
||||||
|
private List<String> phoneList;
|
||||||
|
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,8 @@ package com.yfd.platform.system.service;
|
|||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.yfd.platform.system.domain.SmsVerifyCode;
|
import com.yfd.platform.system.domain.SmsVerifyCode;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 短信验证码表 服务类
|
* 短信验证码表 服务类
|
||||||
@ -46,4 +48,6 @@ public interface ISmsVerifyCodeService extends IService<SmsVerifyCode> {
|
|||||||
* @return 是否发送成功
|
* @return 是否发送成功
|
||||||
*/
|
*/
|
||||||
boolean sendAuditNotify(String phone, String auditStatus, String reason);
|
boolean sendAuditNotify(String phone, String auditStatus, String reason);
|
||||||
|
|
||||||
|
void batchSendContent(List<String> phoneList, String content);
|
||||||
}
|
}
|
||||||
@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -120,4 +121,16 @@ public class SmsVerifyCodeServiceImpl extends ServiceImpl<SmsVerifyCodeMapper, S
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void batchSendContent(List<String> phoneList, String content) {
|
||||||
|
for (String phone : phoneList) {
|
||||||
|
try {
|
||||||
|
smsSender.send(phone, content);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.debug("批量发送短信失败"+phone);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user