修改短信的调用服务方式

This commit is contained in:
syruan 2023-12-13 10:29:03 +08:00
parent 248364786d
commit 287a30e3f5
5 changed files with 32 additions and 9 deletions

View File

@ -4,11 +4,7 @@ import com.bonus.sgzb.system.api.domain.SysUser;
import com.bonus.sgzb.system.api.factory.RemoteUserFallbackFactory;
import com.bonus.sgzb.system.api.model.LoginUser;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.*;
import com.bonus.sgzb.common.core.constant.SecurityConstants;
import com.bonus.sgzb.common.core.constant.ServiceNameConstants;
import com.bonus.sgzb.common.core.domain.R;
@ -43,7 +39,17 @@ public interface RemoteUserService
@GetMapping("/user/info/{phone}")
public R<LoginUser> getUserInfoByPhone(@PathVariable("phone") String phone, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
/**
* 发送短信
*/
@PostMapping("/sms/codeLogin")
public R<Boolean> codeLogin(@RequestBody String phone);
/**
* 验证码校验
*/
@PostMapping("/sms/checkCode")
public Boolean checkCode(@RequestParam("phone") String phone, @RequestParam("code") String code);
/**
* 注册用户信息

View File

@ -37,6 +37,16 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
return R.fail("获取用户失败:" + throwable.getMessage());
}
@Override
public R<Boolean> codeLogin(String phone) {
return R.fail("发送登录验证码失败:" + throwable.getMessage());
}
@Override
public Boolean checkCode(String phone, String code) {
return false;
}
@Override
public R<Boolean> registerUserInfo(SysUser sysUser, String source) {
return R.fail("注册用户失败:" + throwable.getMessage());

View File

@ -35,9 +35,6 @@ public class SysLoginService
@Autowired
private SysPasswordService passwordService;
@Resource
private ISysSmsService smsService;
@Autowired
private SysRecordLogService recordLogService;
@ -146,7 +143,7 @@ public class SysLoginService
recordLogService.recordLogininfor(phone, Constants.LOGIN_FAIL, "用户已停用,请联系管理员");
throw new ServiceException("对不起,您的账号:" + phone + " 已停用");
}
if (!smsService.checkCode(phone, code)) {
if (!remoteUserService.checkCode(phone, code)) {
throw new ServiceException("对不起,您输入的验证码:" + code + " 不存在");
} else {
recordLogService.recordLogininfor(phone, Constants.LOGIN_SUCCESS, "登录成功");

View File

@ -35,6 +35,15 @@ public class SysSmsController extends BaseController {
}
}
@PostMapping("checkCode")
public AjaxResult codeLogin(@RequestParam(value = "phone") String phone, @RequestParam(value = "code") String code){
try {
return toAjax(smsService.checkCode(phone, code));
} catch (Exception e) {
return error(e.getMessage());
}
}
@PostMapping("send")
public AjaxResult send(@RequestParam(value = "phone") String phone, @RequestParam(value = "msg",required = false) String msg){
try {

View File

@ -1,6 +1,7 @@
package com.bonus.sgzb.system.service;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import org.springframework.stereotype.Service;
/**
* Description: