|
|
@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import com.huoran.iasf.common.exception.BusinessException; |
|
|
|
import com.huoran.iasf.common.exception.BusinessException; |
|
|
|
import com.huoran.iasf.common.exception.code.BaseResponseCode; |
|
|
|
import com.huoran.iasf.common.exception.code.BaseResponseCode; |
|
|
@ -51,6 +50,9 @@ public class UserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impleme |
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private HttpSessionService httpSessionService; |
|
|
|
private HttpSessionService httpSessionService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private RedisService redisService; |
|
|
|
|
|
|
|
|
|
|
|
@Value("${spring.redis.allowMultipleLogin}") |
|
|
|
@Value("${spring.redis.allowMultipleLogin}") |
|
|
|
private Boolean allowMultipleLogin; |
|
|
|
private Boolean allowMultipleLogin; |
|
|
|
@Value("${spring.profiles.active}") |
|
|
|
@Value("${spring.profiles.active}") |
|
|
@ -70,6 +72,8 @@ public class UserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impleme |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public LoginRespVO login(SysUser vo) { |
|
|
|
public LoginRespVO login(SysUser vo) { |
|
|
|
|
|
|
|
//验证码校验
|
|
|
|
|
|
|
|
check(vo.getRandom(), vo.getCaptcha()); |
|
|
|
SysUser sysUser = sysUserMapper.selectOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUsername, vo.getUsername())); |
|
|
|
SysUser sysUser = sysUserMapper.selectOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUsername, vo.getUsername())); |
|
|
|
if (null == sysUser) { |
|
|
|
if (null == sysUser) { |
|
|
|
throw new BusinessException(BaseResponseCode.NOT_ACCOUNT); |
|
|
|
throw new BusinessException(BaseResponseCode.NOT_ACCOUNT); |
|
|
@ -100,6 +104,26 @@ public class UserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impleme |
|
|
|
return respVO; |
|
|
|
return respVO; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 校验验证码 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param random 随机数 |
|
|
|
|
|
|
|
* @param code 验证码 |
|
|
|
|
|
|
|
* @return boolean |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void check(String random, String code) { |
|
|
|
|
|
|
|
String value = redisService.get(random); |
|
|
|
|
|
|
|
//验证码已过期
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(value)) { |
|
|
|
|
|
|
|
throw new BusinessException(10004, "验证码已过期"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//验证码错误
|
|
|
|
|
|
|
|
if (!code.equals(value)) { |
|
|
|
|
|
|
|
throw new BusinessException(10005, "验证码错误"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
redisService.del(random); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void updateUserInfo(SysUser vo) { |
|
|
|
public void updateUserInfo(SysUser vo) { |
|
|
|
|
|
|
|
|
|
|
@ -161,12 +185,12 @@ public class UserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impleme |
|
|
|
if (!StringUtils.isEmpty(vo.getUsername())) { |
|
|
|
if (!StringUtils.isEmpty(vo.getUsername())) { |
|
|
|
queryWrapper.like(SysUser::getUsername, vo.getUsername()); |
|
|
|
queryWrapper.like(SysUser::getUsername, vo.getUsername()); |
|
|
|
} |
|
|
|
} |
|
|
|
if (!StringUtils.isEmpty(vo.getStartTime())) { |
|
|
|
/* if (!StringUtils.isEmpty(vo.getStartTime())) { |
|
|
|
queryWrapper.gt(SysUser::getCreateTime, vo.getStartTime()); |
|
|
|
queryWrapper.gt(SysUser::getCreateTime, vo.getStartTime()); |
|
|
|
} |
|
|
|
} |
|
|
|
if (!StringUtils.isEmpty(vo.getEndTime())) { |
|
|
|
if (!StringUtils.isEmpty(vo.getEndTime())) { |
|
|
|
queryWrapper.lt(SysUser::getCreateTime, vo.getEndTime()); |
|
|
|
queryWrapper.lt(SysUser::getCreateTime, vo.getEndTime()); |
|
|
|
} |
|
|
|
}*/ |
|
|
|
if (!StringUtils.isEmpty(vo.getNickName())) { |
|
|
|
if (!StringUtils.isEmpty(vo.getNickName())) { |
|
|
|
queryWrapper.like(SysUser::getNickName, vo.getNickName()); |
|
|
|
queryWrapper.like(SysUser::getNickName, vo.getNickName()); |
|
|
|
} |
|
|
|
} |
|
|
@ -220,9 +244,9 @@ public class UserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impleme |
|
|
|
if (sysUser == null) { |
|
|
|
if (sysUser == null) { |
|
|
|
throw new BusinessException(BaseResponseCode.DATA_ERROR); |
|
|
|
throw new BusinessException(BaseResponseCode.DATA_ERROR); |
|
|
|
} |
|
|
|
} |
|
|
|
if ("test".equals(env) && "guest".equals(sysUser.getUsername())) { |
|
|
|
/* if ("test".equals(env) && "guest".equals(sysUser.getUsername())) { |
|
|
|
throw new BusinessException("演示环境禁止修改演示账号密码"); |
|
|
|
throw new BusinessException("演示环境禁止修改演示账号密码"); |
|
|
|
} |
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
|
|
if (!PasswordUtils.matches(sysUser.getSalt(), vo.getOldPwd(), sysUser.getPassword())) { |
|
|
|
if (!PasswordUtils.matches(sysUser.getSalt(), vo.getOldPwd(), sysUser.getPassword())) { |
|
|
|
throw new BusinessException(BaseResponseCode.OLD_PASSWORD_ERROR); |
|
|
|
throw new BusinessException(BaseResponseCode.OLD_PASSWORD_ERROR); |
|
|
|