|
|
@ -32,8 +32,10 @@ import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
|
|
|
import com.elink.esua.epdc.dao.VerificationFreeUserDao; |
|
|
|
import com.elink.esua.epdc.dto.VerificationFreeUserDTO; |
|
|
|
import com.elink.esua.epdc.entity.SysUserEntity; |
|
|
|
import com.elink.esua.epdc.entity.VerificationFreeUserEntity; |
|
|
|
import com.elink.esua.epdc.feign.MessageFeignClient; |
|
|
|
import com.elink.esua.epdc.service.SysUserService; |
|
|
|
import com.elink.esua.epdc.service.VerificationFreeUserService; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
@ -57,6 +59,8 @@ public class VerificationFreeUserServiceImpl extends BaseServiceImpl<Verificatio |
|
|
|
private RedisUtils redisUtils; |
|
|
|
@Autowired |
|
|
|
private MessageFeignClient messageFeignClient; |
|
|
|
@Autowired |
|
|
|
private SysUserService sysUserService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<VerificationFreeUserDTO> page(Map<String, Object> params) { |
|
|
@ -108,13 +112,32 @@ public class VerificationFreeUserServiceImpl extends BaseServiceImpl<Verificatio |
|
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result preCheckLoginUser() { |
|
|
|
// 如果当前登录账号,设置了免校验,则直接下载隐私数据
|
|
|
|
/** |
|
|
|
* 实时获取 UserDetail 信息 |
|
|
|
* @param |
|
|
|
* @return com.elink.esua.epdc.commons.tools.security.user.UserDetail |
|
|
|
* @Author zhangyong |
|
|
|
* @Date 15:23 2021-12-24 |
|
|
|
**/ |
|
|
|
private UserDetail getSysUserInfo() { |
|
|
|
UserDetail user = SecurityUser.getUser(); |
|
|
|
if (user == null) { |
|
|
|
throw new RenException("用户未登录"); |
|
|
|
} |
|
|
|
SysUserEntity userEntity = sysUserService.selectById(user.getId()); |
|
|
|
if (userEntity == null) { |
|
|
|
throw new RenException("用户不存在,请联系管理员"); |
|
|
|
} |
|
|
|
// 当在用户管理中修改手机号后,若用户不重新登录,此时token中的手机号还是之前的,
|
|
|
|
// 所有需要从数据库中查询最新的手机号。
|
|
|
|
user.setMobile(userEntity.getMobile()); |
|
|
|
return user; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result preCheckLoginUser() { |
|
|
|
// 如果当前登录账号,设置了免校验,则直接下载隐私数据
|
|
|
|
UserDetail user = getSysUserInfo(); |
|
|
|
// 免校验么?
|
|
|
|
Integer noVerification = baseDao.isVerificationBySysUserId(user.getId()); |
|
|
|
if (NumConstant.ZERO == noVerification) { |
|
|
@ -135,19 +158,13 @@ public class VerificationFreeUserServiceImpl extends BaseServiceImpl<Verificatio |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result sendSMS() { |
|
|
|
UserDetail user = SecurityUser.getUser(); |
|
|
|
if (user == null) { |
|
|
|
throw new RenException("用户未登录"); |
|
|
|
} |
|
|
|
UserDetail user = getSysUserInfo(); |
|
|
|
return messageFeignClient.sendCode(user.getMobile()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result postCheckSMSCode(String smsCode) { |
|
|
|
UserDetail user = SecurityUser.getUser(); |
|
|
|
if (user == null) { |
|
|
|
throw new RenException("用户未登录"); |
|
|
|
} |
|
|
|
UserDetail user = getSysUserInfo(); |
|
|
|
String phoneKey = RedisKeys.getPhoneSmsCodeKey(user.getMobile()); |
|
|
|
Object redisSmsCode = redisUtils.get(phoneKey); |
|
|
|
if (null == redisSmsCode || !redisSmsCode.toString().equals(smsCode)) { |
|
|
|