修改手机号(一半)

This commit is contained in:
墨大叔 2024-10-11 17:06:41 +08:00
parent a1204272be
commit 7550ad1ac7
20 changed files with 365 additions and 65 deletions

View File

@ -16,6 +16,27 @@
</description>
<dependencies>
<!--阿里云短信发送start-->
<!--阿里云发送短信-->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>alibabacloud-dysmsapi20170525</artifactId>
<version>2.0.22</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>4.0.6</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
<version>1.1.0</version>
</dependency>
<!--阿里云短信发送 end-->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-typehandlers-jsr310</artifactId>

View File

@ -0,0 +1,169 @@
package com.ruoyi.common.sms;
import com.alibaba.fastjson2.JSONObject;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.dysmsapi.model.v20170525.QuerySendDetailsRequest;
import com.aliyuncs.dysmsapi.model.v20170525.QuerySendDetailsResponse;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.profile.IClientProfile;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@Service
public class AliSmsService {
// 产品名称:云通信短信API产品,开发者无需替换
static final String product = "Dysmsapi";
// 产品域名,开发者无需替换
static final String domain = "dysmsapi.aliyuncs.com";
@Value("${sms.ali.accessKeyId}")
private String accessKeyId;
@Value("${sms.ali.accessKeySecret}")
private String accessKeySecret;
//发送短信失败错误码对应的原因
public static Map<String,String> errorMags;
static {
Map<String,String> jsonObject = new HashMap<>();
jsonObject.put("isp.RAM_PERMISSION_DENY","RAM权限不足");
jsonObject.put("isv.OUT_OF_SERVICE","业务停机");
jsonObject.put("isv.PRODUCT_UN_SUBSCRIPT","未开通云通信产品的阿里云客户");
jsonObject.put("isv.PRODUCT_UNSUBSCRIBE","产品未开通");
jsonObject.put("isv.ACCOUNT_NOT_EXISTS","账户不存在");
jsonObject.put("isv.ACCOUNT_ABNORMAL","账户异常");
jsonObject.put("isv.SMS_TEMPLATE_ILLEGAL","该账号下找不到对应模板");
jsonObject.put("isv.SMS_TEST_SIGN_TEMPLATE_LIMIT","测试模板和签名限制");
jsonObject.put("isv.SMS_SIGNATURE_SCENE_ILLEGAL","签名和模板类型不一致");
jsonObject.put("isv.SMS_SIGN_ILLEGAL","签名禁止使用");
jsonObject.put("isv.SMS_SIGNATURE_ILLEGAL","该账号下找不到对应签名");
jsonObject.put("isp.SYSTEM_ERROR","系统出现错误,请重新调用");
jsonObject.put("isv.MOBILE_NUMBER_ILLEGAL","手机号码格式错误");
jsonObject.put("isv.MOBILE_COUNT_OVER_LIMIT","手机号码数量超过限制最多支持1000条");
jsonObject.put("isv.TEMPLATE_MISSING_PARAMETERS","模板变量中存在未赋值变量");
jsonObject.put("isv.TEMPLATE_PARAMS_ILLEGAL","传入的变量内容和实际申请模板时变量所选择的属性类型不配");
jsonObject.put("isv.TEMPLATE_COUNT_OVER_LIMIT","超过单自然日模板申请数量上限");
jsonObject.put("isv.TEMPLATE_OVER_LIMIT","模板字符数量超过限制");
jsonObject.put("isv.BUSINESS_LIMIT_CONTROL","触发云通信流控限制");
jsonObject.put("isv.INVALID_JSON_PARAM","参数格式错误,请修改为字符串值");
jsonObject.put("isv.INVALID_PARAMETERS","参数格式不正确");
jsonObject.put("isv.BLACK_KEY_CONTROL_LIMIT","变量中传入疑似违规信息");
jsonObject.put("isv.PARAM_LENGTH_LIMIT","参数超过长度限制");
jsonObject.put("isv.PARAM_NOT_SUPPORT_URL","变量不支持传入URL");
jsonObject.put("isv.AMOUNT_NOT_ENOUGH","账户余额不足");
jsonObject.put("FILTER","关键字拦截");
jsonObject.put("VALVE:M_MC","重复过滤");
jsonObject.put("VALVE:H_MC","重复过滤");
jsonObject.put("VALVE:D_MC","重复过滤");
jsonObject.put("MOBILE_SEND_LIMIT","单个号码日或月发送上限,流控超限,频繁发送超限");
jsonObject.put("isv.TEMPLATE_PARAMS_ILLEGAL","传入的变量内容和实际申请模板时变量所选择的属性类型不配");
jsonObject.put("MOBILE_IN_BLACK","手机号在黑名单(平台或运营商)");
jsonObject.put("MOBILE_IN_BLACK","手机号在黑名单(平台或运营商)");
jsonObject.put("MOBILE_TERMINAL_ERROR","手机终端问题、内存满、SIM卡满、非法设备等");
jsonObject.put("SP_NOT_BY_INTER_SMS","未开通国际短信");
jsonObject.put("USER_REJECT","用户手机退订此业务、产品未开通");
jsonObject.put("SP_UNKNOWN_ERROR","运营商未知错误");
jsonObject.put("MOBILE_ACCOUNT_ABNORMAL","用户账户异常、携号转网、欠费等");
jsonObject.put("DELIVERED","消息发送成功");
jsonObject.put("MOBILE_ACCOUNT_ABNORMAL","用户账户异常、携号转网、欠费等");
jsonObject.put("CONTENT_KEYWORD","内容关键字拦截");
jsonObject.put("SIGNATURE_BLACKLIST","签名黑名单");
jsonObject.put("INVALID_NUMBER","号码不合法");
jsonObject.put("NO_ROUTE","无路由器");
jsonObject.put("CONTENT_ERROR","模板内容无退订");
errorMags = Collections.unmodifiableMap(jsonObject);
}
/**
* 发送短信验证码
* @param dto 短信发送api第三方参数实体类
* @return
* @throws ClientException
*/
public SendSmsResponse send(SendSmsDto dto) throws ClientException {
// 可自助调整超时时间
System.setProperty("sun.net.client.defaultConnectTimeout", "10000");
System.setProperty("sun.net.client.defaultReadTimeout", "10000");
// 初始化acsClient,暂不支持region化
IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, accessKeySecret);
DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", product, domain);
IAcsClient acsClient = new DefaultAcsClient(profile);
// 组装请求对象-具体描述见控制台-文档部分内容
SendSmsRequest request = new SendSmsRequest();
// 必填:待发送手机号
request.setPhoneNumbers(dto.getMobile());
// 必填:短信签名-可在短信控制台中找到
request.setSignName(dto.getType().getSignName());
// 必填:短信模板-可在短信控制台中找到
request.setTemplateCode(dto.getType().getTemplateCode());
// 可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}",此处的值为
request.setTemplateParam(dto.getParam().toJSONString());
// hint 此处可能会抛出异常注意catch
SendSmsResponse sendSmsResponse = acsClient.getAcsResponse(request);
return sendSmsResponse;
}
/**
* 查询消息的发送状态
* @param phoneNum
* @param bizId 发送回执id,调用发送短信api时,会返回
* @return
* @throws ClientException
*/
public QuerySendDetailsResponse querySendDetails(String phoneNum, String bizId) throws ClientException {
// 可自助调整超时时间
System.setProperty("sun.net.client.defaultConnectTimeout", "10000");
System.setProperty("sun.net.client.defaultReadTimeout", "10000");
// 初始化acsClient,暂不支持region化
IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, accessKeySecret);
DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", product, domain);
IAcsClient acsClient = new DefaultAcsClient(profile);
// 组装请求对象
QuerySendDetailsRequest request = new QuerySendDetailsRequest();
// 必填-号码
request.setPhoneNumber(phoneNum);
// 可选-流水号
request.setBizId(bizId);
// 必填-发送日期 支持30天内记录查询格式yyyyMMdd
SimpleDateFormat ft = new SimpleDateFormat("yyyyMMdd");
request.setSendDate(ft.format(new Date()));
// 必填-页大小
request.setPageSize(10L);
// 必填-当前页码从1开始计数
request.setCurrentPage(1L);
// hint 此处可能会抛出异常注意catch
QuerySendDetailsResponse querySendDetailsResponse = acsClient.getAcsResponse(request);
return querySendDetailsResponse;
}
//获取错误码对应的原因
public static String getSmsSendError(String errCode){
String mags = null;
if(StringUtils.isNotBlank(errorMags.get(errCode))){
mags = errorMags.get(errCode);
}
return mags;
}
}

View File

@ -0,0 +1,22 @@
package com.ruoyi.common.sms;
import com.alibaba.fastjson2.JSONObject;
import lombok.Data;
/**
* 短信发送api第三方参数实体类
*/
@Data
public class SendSmsDto {
// 待发送短信手机号
private String mobile;
// 发送参数
private JSONObject param;
// 短信类型
private SmsType type;
}

View File

@ -14,19 +14,9 @@ import lombok.Getter;
@Getter
public enum SmsType {
CODE("code", "短信验证码", "sms:code:", 600L);
// 验证码
VERIFICATION_CODE("创想物联", "SMS_001");
private final String type;
private final String name;
private final String redisKey; // redis
private final Long expireTime; // 过期时间
public static SmsType parse(String type) {
for (SmsType obj : SmsType.values()) {
if (Objects.equals(obj.getType(), type)) {
return obj;
}
}
throw new RuntimeException("不存在值为" + type + "的短信类型");
}
}
private final String signName; // 签名
private final String templateCode; // 模板Code
}

View File

@ -1,17 +0,0 @@
package com.ruoyi.common.sms;
/**
* 短信工具类
* @author wjh
* 2024/3/26
*/
public class SmsUtil {
/**
* TODO 发送短信验证码
*/
public static boolean sendCode(String mobile, String code) {
return true;
}
}

View File

@ -255,14 +255,9 @@ public class SysLoginService
* 微信登录
*/
@Transactional
public String wxLogin(WxLoginBody body) {
// 通过登录授权码获取到用户信息
WxMaJscode2SessionResult wxMaJscode2SessionResult = wxAuthService.wxJsCode2Session(body.getLoginCode());
ServiceUtil.assertion(wxMaJscode2SessionResult == null, "获取微信openId失败");
public String wxLogin(String openId) {
// 通过openId查询用户判断是否微信用户
String openId = wxMaJscode2SessionResult.getOpenid();
SmUser user = smUserService.selectSmUserByWxOpenId(openId);
// 不是微信用户则使用openId进行注册
@ -362,4 +357,11 @@ public class SysLoginService
// 登录
return this.appLogin(username, password);
}
public String getWxOpenId(String loginCode) {
// 通过登录授权码获取到用户信息
WxMaJscode2SessionResult wxMaJscode2SessionResult = wxAuthService.wxJsCode2Session(loginCode);
ServiceUtil.assertion(wxMaJscode2SessionResult == null, "获取微信openId失败");
return wxMaJscode2SessionResult.getOpenid();
}
}

View File

@ -2,12 +2,9 @@ package com.ruoyi.system.domain.bo;
import com.ruoyi.common.core.domain.ValidGroup;
import com.ruoyi.common.utils.RegexpUtils;
import com.ruoyi.common.valid.EnumValid;
import com.ruoyi.system.domain.enums.verificationCode.CodeBusinessType;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
/**
@ -16,12 +13,12 @@ import javax.validation.constraints.Pattern;
* 2024/3/27
*/
@Data
public class VerificationCodeBO {
public class VerificationCodeDTO {
@ApiModelProperty("手机号")
@Pattern(regexp = RegexpUtils.MOBILE_PHONE_REGEXP, message = "手机号格式错误", groups = {ValidGroup.FrontCreate.class})
private String mobile;
@ApiModelProperty("验证码业务类型")
@ApiModelProperty("验证码类型")
private String type;
}

View File

@ -18,7 +18,9 @@ import lombok.Getter;
public enum CodeBusinessType {
UPDATE_PASSWORD("updatePassword", "修改密码", 6, 300, 60),
MCH_APPLY("mchApply", "商家合作申请", 6, 300, 60),
UNBIND_MOBILE("unbindMobile", "解绑手机号", 6, 300, 60),
CHANGE_MOBILE_OLD("changeMobileOld", "更换手机号:验证旧手机号", 6, 300, 60),
CHANGE_MOBILE_NEW("changeMobileNew", "更换手机号:验证新手机号", 6, 300, 60),
;
private final String type;

View File

@ -35,5 +35,4 @@ public interface IVerificationCodeService {
*/
boolean checkCode(String key, String code, CodeBusinessType type);
}

View File

@ -1,7 +1,13 @@
package com.ruoyi.system.service.impl;
import com.alibaba.fastjson2.JSONObject;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.sms.SmsUtil;
import com.ruoyi.common.core.redis.RedisLock;
import com.ruoyi.common.core.redis.enums.RedisLockKey;
import com.ruoyi.common.sms.AliSmsService;
import com.ruoyi.common.sms.SendSmsDto;
import com.ruoyi.common.sms.SmsType;
import com.ruoyi.common.utils.ServiceUtil;
import com.ruoyi.system.domain.enums.verificationCode.CodeBusinessType;
import com.ruoyi.system.service.IVerificationCodeService;
@ -31,6 +37,11 @@ public class VerificationCodeServiceImpl implements IVerificationCodeService {
@Value("${debug}")
private Boolean debug;
@Autowired
private AliSmsService aliSmsService;
@Autowired
private RedisLock redisLock;
/**
* 发送手机验证码
* @param mobile 手机号
@ -40,15 +51,30 @@ public class VerificationCodeServiceImpl implements IVerificationCodeService {
@Override
public boolean sendMobileCode(String mobile, CodeBusinessType type) {
ServiceUtil.assertion(mobile == null || type == null, "参数错误:null");
ServiceUtil.assertion(mobile.matches(":"), "非法的手机号");
ServiceUtil.assertion(getLock(mobile, type) != null, "请勿频繁获取验证码");
// 生成验证码并缓存
String code = generateCode(type.getLength());
saveToRedis(mobile, type, code);
// TODO 发送短信验证码
return SmsUtil.sendCode(mobile, code);
// 发送短信验证码
JSONObject param = new JSONObject();
// TODO 模板参数
SendSmsDto dto = new SendSmsDto();
dto.setMobile(mobile);
dto.setType(SmsType.VERIFICATION_CODE);
dto.setParam(param);
try {
// SendSmsResponse send = aliSmsService.send(dto);
} catch (Exception e) {
return false;
}
return true;
}
/**

View File

@ -54,14 +54,13 @@ public class Suit extends BaseEntity
/** 价格(元) */
@Excel(name = "价格")
@JsonView({DeviceView.SuitList.class, JsonViewProfile.AppMch.class})
@NotNull(message = "价格不允许为空", groups = {ValidGroup.Create.class, ValidGroup.FrontCreate.class})
@Min(value = 0, message = "价格不允许小于0元")
private BigDecimal price;
@Excel(name = "押金", readConverterExp = "元=")
@ApiModelProperty("押金")
@Min(value = 0, message = "押金不允许小于0元")
@JsonView(DeviceView.SuitList.class)
@JsonView({DeviceView.SuitList.class, JsonViewProfile.App.class})
private BigDecimal deposit;
/** 详细说明 */

View File

@ -308,6 +308,7 @@ public class TransactionBill extends BaseEntity implements Payable
@Excel(name = "套餐押金", readConverterExp = "元=")
@ApiModelProperty("套餐押金")
@JsonView(JsonViewProfile.App.class)
private BigDecimal suitDeposit;
/**

View File

@ -3,6 +3,7 @@ package com.ruoyi.ss.transactionBill.domain.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
@ -18,4 +19,7 @@ public class BillPayDTO {
@ApiModelProperty("渠道ID")
@NotNull(message = "渠道ID不允许为空")
private Long channelId;
@ApiModelProperty("支付账户微信OpenId")
private String account;
}

View File

@ -244,4 +244,9 @@ public interface ISmUserService
* 根据用户ID列表查询
*/
List<SmUserVo> selectByUserIds(List<Long> userIds);
/**
* 获取用户修改手机号的旧手机短信验证码
*/
boolean getChangeMobileCodeOld(Long userId);
}

View File

@ -38,9 +38,10 @@ import com.ruoyi.ss.user.domain.dto.UserRealNameDTO;
import com.ruoyi.ss.user.domain.vo.UserRealNameVO;
import com.ruoyi.ss.user.mapper.SmUserMapper;
import com.ruoyi.ss.user.service.ISmUserService;
import com.ruoyi.system.domain.SysConfig;
import com.ruoyi.system.domain.enums.config.ConfigKey;
import com.ruoyi.system.domain.enums.verificationCode.CodeBusinessType;
import com.ruoyi.system.service.ISysConfigService;
import com.ruoyi.system.service.IVerificationCodeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -90,6 +91,9 @@ public class SmUserServiceImpl implements ISmUserService
@Autowired
private ISysConfigService sysConfigService;
@Autowired
private IVerificationCodeService verificationCodeService;
// 活体检测返回地址
public static final String LIVENESS_RETURN_URL = SpringUtils.getRequiredProperty("liveness.returnUrl");
@ -464,6 +468,15 @@ public class SmUserServiceImpl implements ISmUserService
return smUserMapper.selectSmUserList(query);
}
@Override
public boolean getChangeMobileCodeOld(Long userId) {
SmUserVo user = selectSmUserByUserId(userId);
ServiceUtil.assertion(user == null, "用户不存在");
ServiceUtil.assertion(StringUtils.isBlank(user.getPhonenumber()), "用户没有手机号,无法获取验证码");
return verificationCodeService.sendMobileCode(user.getPhonenumber(), CodeBusinessType.CHANGE_MOBILE_OLD);
}
/**
* 逻辑删除前校验
* @param userIds

View File

@ -52,9 +52,12 @@ public class AppAuthController extends BaseController {
public AjaxResult wxLogin(@RequestBody @Validated WxLoginBody body)
{
AjaxResult ajax = AjaxResult.success();
// 获取微信openId
String wxOpenId = loginService.getWxOpenId(body.getLoginCode());
// 生成令牌
String token = loginService.wxLogin(body);
String token = loginService.wxLogin(wxOpenId);
ajax.put(Constants.TOKEN, token);
ajax.put("wxOpenId", wxOpenId);
return ajax;
}
}

View File

@ -6,14 +6,11 @@ import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.JsonViewProfile;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.enums.UserType;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.ServiceUtil;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.web.service.SysPasswordService;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.ss.user.domain.bo.SmUserBO;
import com.ruoyi.ss.user.domain.SmUserVo;
import com.ruoyi.ss.user.domain.dto.UserRealNameDTO;
import com.ruoyi.ss.user.domain.dto.UserUpdatePasswordDTO;
@ -22,6 +19,7 @@ import com.ruoyi.ss.user.service.UserAssembler;
import com.ruoyi.system.domain.enums.verificationCode.CodeBusinessType;
import com.ruoyi.system.service.IVerificationCodeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
@ -113,4 +111,22 @@ public class AppUserController extends BaseController {
return toAjax(userService.readMchLicence(getUserId()));
}
@ApiOperation("获取用户修改手机号的旧手机验证码")
@GetMapping("/changeMobileCodeOld")
public AjaxResult getChangeMobileCodeOld() {
return success(userService.getChangeMobileCodeOld(getUserId()));
}
@ApiOperation("获取用户修改手机号的新手机验证码")
@GetMapping("/changeMobileNewCode")
public AjaxResult getChangeMobileNewCode(@RequestParam String mobile) {
return success(verificationCodeService.sendMobileCode(mobile, CodeBusinessType.CHANGE_MOBILE_NEW));
}
@ApiOperation("修改手机号")
@PutMapping("/changeMobile")
public AjaxResult changeMobile() {
return success();
}
}

View File

@ -4,14 +4,12 @@ import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.websocket.server.PathParam;
import cn.binarywang.wx.miniapp.api.WxMaJsapiService;
import cn.binarywang.wx.miniapp.api.WxMaService;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.domain.ValidGroup;
import com.ruoyi.common.utils.qiniu.QiNiuUtils;
import com.ruoyi.system.domain.bo.VerificationCodeBO;
import com.ruoyi.system.domain.bo.VerificationCodeDTO;
import com.ruoyi.system.domain.enums.verificationCode.CodeBusinessType;
import com.ruoyi.system.service.IVerificationCodeService;
import io.swagger.annotations.ApiOperation;
@ -189,12 +187,6 @@ public class CommonController
return ajax;
}
@ApiOperation("获取短信验证码")
@GetMapping("/verificationCode/mobile")
@Anonymous
public AjaxResult getVerificationMobileCode(@Validated({ValidGroup.FrontCreate.class}) VerificationCodeBO bo) {
return success(verificationCodeService.sendMobileCode(bo.getMobile(), CodeBusinessType.parse(bo.getType())));
}
@ApiOperation("获取微信jssdk签名")
@GetMapping("/wx/js/sdk")

View File

@ -0,0 +1,49 @@
package com.ruoyi.web.controller.common;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.ValidGroup;
import com.ruoyi.system.domain.bo.VerificationCodeDTO;
import com.ruoyi.system.domain.enums.verificationCode.CodeBusinessType;
import com.ruoyi.system.service.IVerificationCodeService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import static com.ruoyi.common.core.domain.AjaxResult.success;
/**
* @author wjh
* 2024/10/11
*/
@RestController
@RequestMapping("/verification")
public class VerificationController extends BaseController {
@Autowired
private IVerificationCodeService verificationCodeService;
@ApiOperation("获取短信验证码")
@GetMapping("/mobile")
@Anonymous
public AjaxResult getVerificationMobileCode(@Validated({ValidGroup.FrontCreate.class}) VerificationCodeDTO bo) {
return success(verificationCodeService.sendMobileCode(bo.getMobile(), CodeBusinessType.parse(bo.getType())));
}
@ApiOperation("判断验证码是否正确")
@GetMapping("/check")
@Anonymous
public AjaxResult checkCode(@RequestParam @ApiParam("手机号或邮箱") String key,
@RequestParam @ApiParam("验证码") String code,
@RequestParam @ApiParam("验证码类型") String type
) {
return success(verificationCodeService.checkCode(key, code, CodeBusinessType.parse(type), false));
}
}

View File

@ -198,3 +198,10 @@ sm:
access:
# 用户最大密钥对数量
maxCount: 1
# 短信
sms:
# 阿里云
ali:
accessKeyId: '123'
accessKeySecret: '123'