|
@@ -4,9 +4,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.qmth.boot.core.enums.Platform;
|
|
|
import com.qmth.sop.business.bean.auth.AuthBean;
|
|
|
import com.qmth.sop.business.bean.auth.ExpireTimeBean;
|
|
|
+import com.qmth.sop.business.bean.dto.VerifyCodeCheckDto;
|
|
|
import com.qmth.sop.business.bean.result.LoginResult;
|
|
|
import com.qmth.sop.business.bean.result.SysUserResult;
|
|
|
import com.qmth.sop.business.cache.CommonCacheService;
|
|
|
+import com.qmth.sop.business.entity.SysConfig;
|
|
|
import com.qmth.sop.business.entity.SysRole;
|
|
|
import com.qmth.sop.business.entity.SysUser;
|
|
|
import com.qmth.sop.business.entity.TBSession;
|
|
@@ -21,6 +23,7 @@ import com.qmth.sop.common.util.IpUtil;
|
|
|
import com.qmth.sop.common.util.ServletUtil;
|
|
|
import com.qmth.sop.common.util.SessionUtil;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.security.NoSuchAlgorithmException;
|
|
@@ -125,4 +128,49 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
|
public List<SysUserResult> findSysUserResultList(Long orgId) {
|
|
|
return this.baseMapper.findSysUserResultList(orgId);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 强行过期用户手机号验证码(过期时间改为验证码发送时间)
|
|
|
+ *
|
|
|
+ * @param userId 用户id
|
|
|
+ * @param mobileNumber 用户手机号
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void expiredVerifyCode(Long userId, String mobileNumber) {
|
|
|
+ SysConfig sysConfig = commonCacheService.addSysConfigCache(SystemConstant.SYS_CODE_ENABLE);
|
|
|
+ Optional.ofNullable(sysConfig).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未启用短信验证码"));
|
|
|
+ Boolean enable = Boolean.valueOf(sysConfig.getConfigValue());
|
|
|
+ if (enable) {
|
|
|
+ int count = this.baseMapper.updateVerifyCodeExpiredTime(userId, mobileNumber);
|
|
|
+ if (count != 1) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("验证码过期失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void checkSmsCode(Long userId, String mobileNumber, String code) {
|
|
|
+ SysConfig sysConfig = commonCacheService.addSysConfigCache(SystemConstant.SYS_CODE_ENABLE);
|
|
|
+ Optional.ofNullable(sysConfig).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未启用短信验证码"));
|
|
|
+ Boolean enable = Boolean.valueOf(sysConfig.getConfigValue());
|
|
|
+ if (enable) {
|
|
|
+ SysConfig sysConfigNormal = commonCacheService.addSysConfigCache(SystemConstant.SMS_NORMAL_CODE);
|
|
|
+ Optional.ofNullable(sysConfigNormal).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未配置万能短信验证码"));
|
|
|
+ if (!sysConfigNormal.getConfigValue().equals(code)) {
|
|
|
+ List<VerifyCodeCheckDto> verifyCodeCheckDtoList = this.baseMapper.findVerifyCodeByUser(userId, mobileNumber);
|
|
|
+ if (verifyCodeCheckDtoList.size() < 1) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("验证码错误");
|
|
|
+ }
|
|
|
+ VerifyCodeCheckDto accessControl = verifyCodeCheckDtoList.get(0);
|
|
|
+ if (accessControl == null || !accessControl.getVerifyCode().equals(code)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("验证码错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (new Date(accessControl.getExpireTime()).before(new Date())) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("验证码已过期");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|