|
|
|
@ -1,6 +1,5 @@ |
|
|
|
|
package com.daqing.financial.hrauth.service.impl; |
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
import com.daqing.financial.hrauth.dao.UserLoginDao; |
|
|
|
|
import com.daqing.financial.hrauth.service.UserLoginService; |
|
|
|
@ -9,17 +8,10 @@ import com.daqing.framework.domain.hrms.request.UserLoginRequest; |
|
|
|
|
import com.daqing.framework.domain.hrms.response.HrmsCode; |
|
|
|
|
import com.daqing.framework.exception.ExceptionCast; |
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
import org.springframework.security.core.authority.SimpleGrantedAuthority; |
|
|
|
|
import org.springframework.security.core.userdetails.User; |
|
|
|
|
import org.springframework.security.core.userdetails.UserDetails; |
|
|
|
|
import org.springframework.security.core.userdetails.UserDetailsService; |
|
|
|
|
import org.springframework.security.core.userdetails.UsernameNotFoundException; |
|
|
|
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.regex.Matcher; |
|
|
|
|
import java.util.regex.Pattern; |
|
|
|
|
|
|
|
|
@ -28,12 +20,12 @@ import java.util.regex.Pattern; |
|
|
|
|
* @date 2020/9/22 15:01 |
|
|
|
|
*/ |
|
|
|
|
@Service("userLoginService") |
|
|
|
|
public class UserLoginServiceImpl extends ServiceImpl<UserLoginDao, UserEntity> implements UserLoginService, UserDetailsService { |
|
|
|
|
public class UserLoginServiceImpl extends ServiceImpl<UserLoginDao, UserEntity> implements UserLoginService { |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private UserLoginDao userLoginDao; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
/* @Override |
|
|
|
|
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { |
|
|
|
|
UserEntity user = userLoginDao.getUser(username); |
|
|
|
|
List<SimpleGrantedAuthority> authorities = new ArrayList<>(); |
|
|
|
@ -42,7 +34,7 @@ public class UserLoginServiceImpl extends ServiceImpl<UserLoginDao, UserEntity> |
|
|
|
|
UserDetails userDetails = new User(user.getAccount(),new BCryptPasswordEncoder().encode(user.getPassword()),authorities); |
|
|
|
|
|
|
|
|
|
return userDetails; |
|
|
|
|
} |
|
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 忘记密码 |
|
|
|
@ -51,21 +43,27 @@ public class UserLoginServiceImpl extends ServiceImpl<UserLoginDao, UserEntity> |
|
|
|
|
public Boolean getBackPwd(UserLoginRequest user){ |
|
|
|
|
//判断重置密码参数是否为空
|
|
|
|
|
if(StringUtils.isEmpty(user.getPhoneAccount())){ |
|
|
|
|
ExceptionCast.cast(HrmsCode.PHNOE_ACCOUNT_ILLEGAL); |
|
|
|
|
ExceptionCast.cast(HrmsCode.PHNOE_ACCOUNT_NOT_EMPTY); |
|
|
|
|
} |
|
|
|
|
if(StringUtils.isEmpty(user.getVerifyCode())){ |
|
|
|
|
ExceptionCast.cast(HrmsCode.VERIFY_CODE_ILLEGAL); |
|
|
|
|
ExceptionCast.cast(HrmsCode.VERIFY_CODE_NOT_EMPTY); |
|
|
|
|
} |
|
|
|
|
if(StringUtils.isEmpty(user.getNewPwd())){ |
|
|
|
|
ExceptionCast.cast(HrmsCode.NEW_PASSWORD_NOT_EMPTY); |
|
|
|
|
} |
|
|
|
|
//校验手机账号是否存在
|
|
|
|
|
int count = this.count(new QueryWrapper<UserEntity>() |
|
|
|
|
.eq("phone_account", user.getPhoneAccount())); |
|
|
|
|
String phoneAccount = user.getPhoneAccount(); |
|
|
|
|
/* int count = this.count(new QueryWrapper<UserEntity>() |
|
|
|
|
.eq("phone_account", phoneAccount));*/ |
|
|
|
|
int count = userLoginDao.selectCount(phoneAccount); |
|
|
|
|
if (count == 0) { |
|
|
|
|
ExceptionCast.cast(HrmsCode.PHNOE_ACCOUNT_ILLEGAL); |
|
|
|
|
ExceptionCast.cast(HrmsCode.PHNOE_ACCOUNT_NOT_EMPTY); |
|
|
|
|
} |
|
|
|
|
//判断验证码是否匹配,目前固定为123456
|
|
|
|
|
String verify = "123456"; |
|
|
|
|
if(!verify.equals(user.getVerifyCode())){ |
|
|
|
|
ExceptionCast.cast(HrmsCode.NEW_PASSWORD_NOT_EMPTY); |
|
|
|
|
} |
|
|
|
|
//判断验证码是否匹配
|
|
|
|
|
|
|
|
|
|
//密码格式校验
|
|
|
|
|
Pattern pattern = Pattern.compile("^[a-zA-Z0-9]{8,20}$"); |
|
|
|
|