xiatian 1 هفته پیش
والد
کامیت
abce56ce82

+ 8 - 6
pom.xml

@@ -21,15 +21,17 @@
         <maven.compiler.target>1.8</maven.compiler.target>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
-        <qmth-boot-version>1.0.6</qmth-boot-version>
     </properties>
 
     <dependencies>
-      <dependency>
-        <groupId>com.qmth.boot</groupId>
-        <artifactId>starter-api</artifactId>
-        <version>${qmth-boot-version}</version>
-      </dependency>
+       <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-aop</artifactId>
+        </dependency>
             <dependency>
         <groupId>org.jsoup</groupId>
         <artifactId>jsoup</artifactId>

+ 10 - 0
src/main/java/cn/com/qmth/ac/bean/CodeNameException.java

@@ -0,0 +1,10 @@
+package cn.com.qmth.ac.bean;
+
+public interface CodeNameException {
+
+    Integer getCode();
+
+    String getName();
+
+    String getMessage();
+}

+ 63 - 0
src/main/java/cn/com/qmth/ac/bean/StatusException.java

@@ -0,0 +1,63 @@
+package cn.com.qmth.ac.bean;
+
+/**
+ * 有状态标识的运行时异常,在API层按500状态码处理
+ */
+public class StatusException extends RuntimeException implements CodeNameException {
+
+    private static final long serialVersionUID = -2411329525159341065L;
+
+    private Integer code;
+
+    private String name;
+
+    /**
+     * 有明确的文字提示
+     *
+     * @param message
+     */
+    public StatusException(String message) {
+        super(message);
+    }
+
+    /**
+     * 有明确的文字提示与触发来源
+     *
+     * @param message
+     * @param cause
+     */
+    public StatusException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    /**
+     * 带所有参数的构造方法
+     *
+     * @param code
+     *            - 数字标识,范围在100~999
+     * @param name
+     *            - 异常详细类型
+     * @param message
+     *            - 文字提示
+     * @param cause
+     *            - 触发来源
+     */
+    public StatusException(Integer code, String name, String message, Throwable cause) {
+        super(message, cause);
+        if (code != null) {
+            if (code < 100 || code > 999) {
+                throw new IllegalArgumentException("StatusException.code should between 100~999");
+            }
+        }
+        this.code = code;
+        this.name = name;
+    }
+
+    public Integer getCode() {
+        return code;
+    }
+
+    public String getName() {
+        return name;
+    }
+}

+ 1 - 6
src/main/java/cn/com/qmth/ac/controller/OpenApiController.java

@@ -9,9 +9,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
-import com.qmth.boot.api.annotation.Aac;
-import com.qmth.boot.api.constant.ApiConstant;
-
 import cn.com.qmth.ac.bean.RedirectParam;
 import cn.com.qmth.ac.bean.SystemConstant;
 import cn.com.qmth.ac.service.CommonService;
@@ -22,7 +19,7 @@ import io.swagger.annotations.ApiResponse;
 import io.swagger.annotations.ApiResponses;
 
 @RestController
-@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_OPEN)
+@RequestMapping("api" + SystemConstant.PREFIX_URL_OPEN)
 @Validated
 public class OpenApiController {
 
@@ -32,7 +29,6 @@ public class OpenApiController {
     @ApiOperation(value = "cas鉴权接口")
     @ApiResponses({ @ApiResponse(code = 200, message = "返回消息", response = Result.class) })
     @RequestMapping(value = "auth/login/{schoolCode}", method = RequestMethod.GET)
-    @Aac(auth = false)
     public void authentication(@ApiParam(value = "学校编码") @PathVariable("schoolCode") String schoolCode) {
         RedirectParam redirectParams = commonService.authentication(schoolCode);
         commonService.redirect(redirectParams);
@@ -41,7 +37,6 @@ public class OpenApiController {
     @ApiOperation(value = "cas鉴权退出接口")
     @RequestMapping(value = "auth/logout/{schoolCode}", method = RequestMethod.GET)
     @ApiResponses({ @ApiResponse(code = 200, message = "返回消息", response = Result.class) })
-    @Aac(auth = false)
     public void logout(@ApiParam(value = "学校编码") @PathVariable("schoolCode") String schoolCode,
             @ApiParam(value = "sessionId", required = false) @RequestParam(required = false) String gSessionId) {
         commonService.logout(schoolCode);

+ 1 - 2
src/main/java/cn/com/qmth/ac/service/impl/CommonServiceImpl.java

@@ -21,9 +21,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.env.Environment;
 import org.springframework.stereotype.Service;
 
-import com.qmth.boot.core.exception.StatusException;
-
 import cn.com.qmth.ac.bean.RedirectParam;
+import cn.com.qmth.ac.bean.StatusException;
 import cn.com.qmth.ac.bean.SystemConstant;
 import cn.com.qmth.ac.service.CommonService;
 import cn.com.qmth.ac.util.ByteUtil;

+ 2 - 2
src/main/resources/application.properties

@@ -3,8 +3,8 @@ server.servlet.session.timeout=PT2H
 server.servlet.context-path=/
 spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
 spring.jackson.time-zone=GMT+8
-com.qmth.logging.root-level=info
-com.qmth.logging.file-path=logs/auth-center.log
+logging.level.cn.com.qmth=info
+logging.file.name=logs/debug.log
 examcloud.auth.center.host=https://auth.exam-cloud.cn
 # guangkai cas configs
 examcloud.cas.authserver.gdrtvu=https://authserver.ougd.cn/authserver