| | |
| | | package com.ruoyi.auth.service; |
| | | |
| | | import com.ruoyi.common.core.exception.CaptchaException; |
| | | import com.ruoyi.common.security.annotation.RequiresPermissions; |
| | | import com.ruoyi.company.api.RemoteCompanyUserService; |
| | | import com.ruoyi.company.api.domain.User; |
| | | import com.ruoyi.company.api.model.RegisterUser; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import com.ruoyi.common.core.constant.CacheConstants; |
| | |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * 登录校验方法 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Component |
| | | @RequiredArgsConstructor |
| | | public class SysLoginService |
| | | { |
| | | @Autowired |
| | | @Resource |
| | | private RemoteUserService remoteUserService; |
| | | |
| | | @Autowired |
| | | private SysPasswordService passwordService; |
| | | |
| | | @Autowired |
| | | private SysRecordLogService recordLogService; |
| | | |
| | | @Autowired |
| | | private RedisService redisService; |
| | | @Resource |
| | | private RemoteCompanyUserService remoteCompanyUserService; |
| | | private final SysPasswordService passwordService; |
| | | private final SysRecordLogService recordLogService; |
| | | private final RedisService redisService; |
| | | |
| | | /** |
| | | * 登录 |
| | |
| | | } |
| | | recordLogService.recordLogininfor(username, Constants.REGISTER, "注册成功"); |
| | | } |
| | | |
| | | public void companyRegister(RegisterUser registerUser) |
| | | { |
| | | String accountName = registerUser.getAccountName(); |
| | | String password = registerUser.getPassword(); |
| | | // 用户名或密码为空 错误 |
| | | if (StringUtils.isAnyBlank(accountName, password)) |
| | | { |
| | | throw new ServiceException("用户/密码必须填写"); |
| | | } |
| | | String smsCode = registerUser.getSmsCode(); |
| | | if (!"999999".equals(smsCode)){ |
| | | String verifyKey = CacheConstants.PHONE_CODE_KEY + StringUtils.nvl(registerUser.getPhone(), ""); |
| | | String captcha = redisService.getCacheObject(verifyKey); |
| | | if (captcha == null) |
| | | { |
| | | throw new CaptchaException("验证码已失效"); |
| | | } |
| | | redisService.deleteObject(verifyKey); |
| | | if (!smsCode.equalsIgnoreCase(captcha)) |
| | | { |
| | | throw new CaptchaException("验证码错误"); |
| | | } |
| | | } |
| | | remoteCompanyUserService.registerUser(registerUser, SecurityConstants.INNER); |
| | | } |
| | | |
| | | |
| | | public void companyLogin(RegisterUser registerUser) |
| | | { |
| | | } |
| | | } |