wangliang 4 gadi atpakaļ
vecāks
revīzija
cd1cdcfe09

+ 24 - 20
teachcloud-report/src/main/java/com/qmth/teachcloud/report/api/SysController.java

@@ -7,6 +7,7 @@ import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.boot.api.exception.ApiException;
 import com.qmth.distributed.print.business.bean.params.LoginParam;
 import com.qmth.distributed.print.business.bean.result.EditResult;
+import com.qmth.distributed.print.business.entity.BasicVerifyCode;
 import com.qmth.distributed.print.business.service.BasicVerifyCodeService;
 import com.qmth.distributed.print.business.service.PrintCommonService;
 import com.qmth.teachcloud.common.bean.auth.AuthBean;
@@ -82,6 +83,9 @@ public class SysController {
     @Resource
     TeachcloudCommonService teachcloudCommonService;
 
+    @Resource
+    SysConfigService sysConfigService;
+
     /**
      * 登录
      *
@@ -135,26 +139,26 @@ public class SysController {
         if (Objects.nonNull(sysUser.getSchoolId()) && sysUser.getSchoolId().longValue() != basicSchool.getId().longValue()) {
             throw ExceptionResultEnum.ERROR.exception("用户学校不匹配");
         }
-//        校验验证码
-//        SysConfig value = sysConfigService.getByKey("sys.code.enable");
-//        if (Objects.nonNull(value) && value.getConfigValue().equals("true")) {
-//            String code = login.getCode();
-//            if (Objects.isNull(code)) {
-//                throw ExceptionResultEnum.ERROR.exception("验证码为空");
-//            }
-//            if (!dictionaryConfig.smsDomain().getSmsNormalCode().equals(code)) {
-//                QueryWrapper<BasicVerifyCode> codeWrapper = new QueryWrapper<>();
-//                codeWrapper.lambda().eq(BasicVerifyCode::getMobileNumber, sysUser.getMobileNumber()).eq(BasicVerifyCode::getUserId, sysUser.getId());
-//                BasicVerifyCode accessControl = basicVerifyCodeService.getOne(codeWrapper);
-//                if (accessControl == null || (accessControl != null && !accessControl.getVerifyCode().equals(code))) {
-//                    throw ExceptionResultEnum.ERROR.exception("短信验证码错误,请仔细核对后再次输入");
-//                }
-//
-//                if (new Date(accessControl.getExpireTime()).before(new Date())) {
-//                    throw ExceptionResultEnum.ERROR.exception("短信验证码已过期");
-//                }
-//            }
-//        }
+        //校验验证码
+        SysConfig value = sysConfigService.getByKey("sys.code.enable");
+        if (Objects.nonNull(value) && value.getConfigValue().equals("true")) {
+            String code = login.getCode();
+            if (Objects.isNull(code)) {
+                throw ExceptionResultEnum.ERROR.exception("验证码为空");
+            }
+            if (!dictionaryConfig.smsDomain().getSmsNormalCode().equals(code)) {
+                QueryWrapper<BasicVerifyCode> codeWrapper = new QueryWrapper<>();
+                codeWrapper.lambda().eq(BasicVerifyCode::getMobileNumber, sysUser.getMobileNumber()).eq(BasicVerifyCode::getUserId, sysUser.getId());
+                BasicVerifyCode accessControl = basicVerifyCodeService.getOne(codeWrapper);
+                if (accessControl == null || (accessControl != null && !accessControl.getVerifyCode().equals(code))) {
+                    throw ExceptionResultEnum.ERROR.exception("短信验证码错误,请仔细核对后再次输入");
+                }
+
+                if (new Date(accessControl.getExpireTime()).before(new Date())) {
+                    throw ExceptionResultEnum.ERROR.exception("短信验证码已过期");
+                }
+            }
+        }
         return ResultUtil.ok(teachcloudCommonService.login(login.getPassword(), sysUser));
     }