deason 5 سال پیش
والد
کامیت
0388c50981

+ 6 - 9
src/main/java/cn/com/qmth/examcloud/app/ApiApplication.java

@@ -9,12 +9,12 @@ package cn.com.qmth.examcloud.app;
 
 import cn.com.qmth.examcloud.web.bootstrap.AppBootstrap;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.builder.SpringApplicationBuilder;
-import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
+import org.springframework.boot.autoconfigure.domain.EntityScan;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
 import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
 import org.springframework.scheduling.annotation.EnableAsync;
 
 @EnableAsync
@@ -22,8 +22,10 @@ import org.springframework.scheduling.annotation.EnableAsync;
 @EnableEurekaClient
 @EnableDiscoveryClient
 @SpringBootApplication
-@ComponentScan(basePackages = {"cn.com.qmth"})
-public class ApiApplication extends SpringBootServletInitializer {
+@ComponentScan(basePackages = {"cn.com.qmth.examcloud"})
+@EntityScan(basePackages = {"cn.com.qmth.examcloud"})
+@EnableJpaRepositories(basePackages = {"cn.com.qmth.examcloud"})
+public class ApiApplication {
 
     static {
         String runtimeLevel = System.getProperty("log.commonLevel");
@@ -38,9 +40,4 @@ public class ApiApplication extends SpringBootServletInitializer {
         AppBootstrap.run(ApiApplication.class, args);
     }
 
-    @Override
-    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
-        return application.sources(ApiApplication.class);
-    }
-
 }

+ 7 - 6
src/main/java/cn/com/qmth/examcloud/app/service/impl/CoreAuthServiceImpl.java

@@ -16,7 +16,6 @@ import cn.com.qmth.examcloud.app.core.utils.ThreadUtils;
 import cn.com.qmth.examcloud.app.model.*;
 import cn.com.qmth.examcloud.app.service.CoreAuthService;
 import cn.com.qmth.examcloud.app.service.RedisService;
-import cn.com.qmth.examcloud.commons.exception.StatusException;
 import okhttp3.*;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
@@ -49,12 +48,13 @@ public class CoreAuthServiceImpl implements CoreAuthService {
 
     @Override
     public boolean isDoingExam(Long rootOrgId, String accountType, String account) {
-        log.warn(String.format("[Check Doing Exam] rootOrgId=%s, account=%s, accountType=%s", rootOrgId, account, accountType));
-
         if (rootOrgId == null) {
-            throw new StatusException("400", "学校ID为不能空!");
+            log.warn("[Check Doing Exam] rootOrgId is null");
+            return false;
         }
 
+        log.info(String.format("[Check Doing Exam] rootOrgId=%s, account=%s, accountType=%s", rootOrgId, account, accountType));
+
         Map<String, String> params = new HashMap<>();
         params.put("rootOrgId", rootOrgId.toString());
         if (LoginType.STUDENT_CODE.name().equals(accountType)) {
@@ -91,7 +91,8 @@ public class CoreAuthServiceImpl implements CoreAuthService {
             log.error(e.getMessage(), e);
         }
 
-        throw new StatusException("500", "考试状态检查异常!");
+        log.warn("[Check Doing Exam] fail");
+        return false;
     }
 
     @Override
@@ -138,7 +139,7 @@ public class CoreAuthServiceImpl implements CoreAuthService {
             }
         } catch (Exception e) {
             log.error(e.getMessage(), e);
-            throw new StatusException("500", "登录异常!");
+            return new Result().error("登录异常!");
         }
     }