diff --git a/pom.xml b/pom.xml
index 53a9200..900747a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -139,11 +139,12 @@
- org.mariadb.jdbc
- mariadb-java-client
- 2.5.4
-
+ org.mariadb.jdbc
+ mariadb-java-client
+ 2.5.4
+
+
com.h2database
h2
@@ -163,6 +164,19 @@
3.2.0
+
+
+ io.springfox
+ springfox-swagger2
+ 2.9.2
+
+
+
+ io.springfox
+ springfox-swagger-ui
+ 2.9.2
+
+
diff --git a/src/main/java/com/codesdream/ase/component/datamanager/QuickJSONRespond.java b/src/main/java/com/codesdream/ase/component/api/QuickJSONRespond.java
similarity index 85%
rename from src/main/java/com/codesdream/ase/component/datamanager/QuickJSONRespond.java
rename to src/main/java/com/codesdream/ase/component/api/QuickJSONRespond.java
index 0838a41..dfe654d 100644
--- a/src/main/java/com/codesdream/ase/component/datamanager/QuickJSONRespond.java
+++ b/src/main/java/com/codesdream/ase/component/api/QuickJSONRespond.java
@@ -1,5 +1,6 @@
-package com.codesdream.ase.component.datamanager;
+package com.codesdream.ase.component.api;
+import com.codesdream.ase.component.datamanager.JSONParameter;
import com.codesdream.ase.component.json.respond.EmptyDataObjectRespond;
import com.codesdream.ase.component.json.respond.JSONBaseRespondObject;
import org.springframework.stereotype.Component;
@@ -36,6 +37,11 @@ public class QuickJSONRespond {
return getJSONStandardRespond(404, "Not Found", info);
}
+ // 获得标准的JSON响应字符串返回(404状态)
+ public String getRespond404(String info, Object object){
+ return getJSONStandardRespond(404, "Not Found", info, object);
+ }
+
// 获得标准的JSON响应字符串返回(500状态)
public String getRespond500(String info){
return getJSONStandardRespond(500, "Internal Server Error", info);
@@ -76,6 +82,11 @@ public class QuickJSONRespond {
return getJSONStandardRespond(400, "Bad Request", info);
}
+ // 获得标准的JSON响应字符串返回(404状态)
+ public String getRespond400(String info, Object object){
+ return getJSONStandardRespond(400, "Bad Request", info, object);
+ }
+
// 获得标准的JSON响应字符串返回(400状态)
public String getRespond409(String info){
return getJSONStandardRespond(409, "Conflict", info);
diff --git a/src/main/java/com/codesdream/ase/component/auth/ASEAccessDeniedHandler.java b/src/main/java/com/codesdream/ase/component/auth/ASEAccessDeniedHandler.java
index 3ab64a1..0c3350e 100644
--- a/src/main/java/com/codesdream/ase/component/auth/ASEAccessDeniedHandler.java
+++ b/src/main/java/com/codesdream/ase/component/auth/ASEAccessDeniedHandler.java
@@ -1,8 +1,6 @@
package com.codesdream.ase.component.auth;
-import com.codesdream.ase.component.datamanager.JSONParameter;
-import com.codesdream.ase.component.datamanager.QuickJSONRespond;
-import com.codesdream.ase.component.json.respond.UserLoginCheckerJSONRespond;
+import com.codesdream.ase.component.api.QuickJSONRespond;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;
diff --git a/src/main/java/com/codesdream/ase/component/auth/ASEAuthenticationEntryPoint.java b/src/main/java/com/codesdream/ase/component/auth/ASEAuthenticationEntryPoint.java
index a72840e..296cc2b 100644
--- a/src/main/java/com/codesdream/ase/component/auth/ASEAuthenticationEntryPoint.java
+++ b/src/main/java/com/codesdream/ase/component/auth/ASEAuthenticationEntryPoint.java
@@ -1,16 +1,12 @@
package com.codesdream.ase.component.auth;
-import com.codesdream.ase.component.datamanager.JSONParameter;
-import com.codesdream.ase.component.datamanager.QuickJSONRespond;
-import com.codesdream.ase.component.json.respond.JSONBaseRespondObject;
-import com.codesdream.ase.component.json.respond.UserLoginCheckerJSONRespond;
+import com.codesdream.ase.component.api.QuickJSONRespond;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
-import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
diff --git a/src/main/java/com/codesdream/ase/component/auth/ASEAuthenticationFailureHandler.java b/src/main/java/com/codesdream/ase/component/auth/ASEAuthenticationFailureHandler.java
index b3a9dae..d90a784 100644
--- a/src/main/java/com/codesdream/ase/component/auth/ASEAuthenticationFailureHandler.java
+++ b/src/main/java/com/codesdream/ase/component/auth/ASEAuthenticationFailureHandler.java
@@ -1,16 +1,13 @@
package com.codesdream.ase.component.auth;
-import com.codesdream.ase.component.datamanager.JSONParameter;
-import com.codesdream.ase.component.datamanager.QuickJSONRespond;
+import com.codesdream.ase.component.api.QuickJSONRespond;
import com.codesdream.ase.component.json.respond.ErrorInfoJSONRespond;
-import com.codesdream.ase.component.json.respond.UserLoginCheckerJSONRespond;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
-import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
diff --git a/src/main/java/com/codesdream/ase/component/auth/ASEAuthenticationSuccessHandler.java b/src/main/java/com/codesdream/ase/component/auth/ASEAuthenticationSuccessHandler.java
index fcd62e3..f73d445 100644
--- a/src/main/java/com/codesdream/ase/component/auth/ASEAuthenticationSuccessHandler.java
+++ b/src/main/java/com/codesdream/ase/component/auth/ASEAuthenticationSuccessHandler.java
@@ -1,8 +1,6 @@
package com.codesdream.ase.component.auth;
-import com.codesdream.ase.component.auth.JSONTokenAuthenticationToken;
-import com.codesdream.ase.component.datamanager.JSONParameter;
-import com.codesdream.ase.component.datamanager.QuickJSONRespond;
+import com.codesdream.ase.component.api.QuickJSONRespond;
import com.codesdream.ase.component.json.respond.UserLoginCheckerJSONRespond;
import com.codesdream.ase.model.permission.User;
@@ -19,7 +17,6 @@ import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.Optional;
diff --git a/src/main/java/com/codesdream/ase/component/datamanager/DataExcelGenerator.java b/src/main/java/com/codesdream/ase/component/datamanager/DataExcelGenerator.java
index 1ca17b2..83c1948 100644
--- a/src/main/java/com/codesdream/ase/component/datamanager/DataExcelGenerator.java
+++ b/src/main/java/com/codesdream/ase/component/datamanager/DataExcelGenerator.java
@@ -1,6 +1,6 @@
package com.codesdream.ase.component.datamanager;
-import com.codesdream.ase.exception.DataFileNotFoundException;
+import com.codesdream.ase.exception.notfound.DataFileNotFoundException;
import com.codesdream.ase.exception.DataIOException;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
diff --git a/src/main/java/com/codesdream/ase/component/datamanager/DataExcelReader.java b/src/main/java/com/codesdream/ase/component/datamanager/DataExcelReader.java
index ae2e2e6..f5471f2 100644
--- a/src/main/java/com/codesdream/ase/component/datamanager/DataExcelReader.java
+++ b/src/main/java/com/codesdream/ase/component/datamanager/DataExcelReader.java
@@ -2,6 +2,7 @@ package com.codesdream.ase.component.datamanager;
import com.codesdream.ase.exception.*;
+import com.codesdream.ase.exception.notfound.DataFileNotFoundException;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.*;
diff --git a/src/main/java/com/codesdream/ase/component/json/model/JsonableTag.java b/src/main/java/com/codesdream/ase/component/json/model/JsonableTag.java
new file mode 100644
index 0000000..b5397cd
--- /dev/null
+++ b/src/main/java/com/codesdream/ase/component/json/model/JsonableTag.java
@@ -0,0 +1,41 @@
+package com.codesdream.ase.component.json.model;
+
+import com.codesdream.ase.model.permission.Tag;
+import com.codesdream.ase.model.permission.User;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import net.bytebuddy.implementation.bind.annotation.DefaultMethod;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+@Data
+@ApiModel("标签")
+public class JsonableTag {
+ @ApiModelProperty(value = "标签id")
+ private Integer id = null;
+ @ApiModelProperty(value = "标签名", example = "系统管理员")
+ private String name;
+ @ApiModelProperty(value = "标签说明", example = "该系统的管理员")
+ private String description;
+ @ApiModelProperty(value = "用户列表", hidden = true)
+ private Set users = new HashSet<>();
+
+ public JsonableTag(){
+
+ }
+
+ public JsonableTag(Tag tag){
+ this.id = tag.getId();
+ this.name = tag.getName();
+ this.description = tag.getDescription();
+ // 构建用户的ID列表
+ for(User user : tag.getUsers()) {
+ users.add(user.getId());
+ }
+ }
+
+}
diff --git a/src/main/java/com/codesdream/ase/component/json/model/JsonableUidGetter.java b/src/main/java/com/codesdream/ase/component/json/model/JsonableUidGetter.java
new file mode 100644
index 0000000..9eee677
--- /dev/null
+++ b/src/main/java/com/codesdream/ase/component/json/model/JsonableUidGetter.java
@@ -0,0 +1,6 @@
+package com.codesdream.ase.component.json.model;
+
+public class JsonableUidGetter {
+ private String checkType;
+ private String username;
+}
diff --git a/src/main/java/com/codesdream/ase/configure/ASESwaggerConfigure.java b/src/main/java/com/codesdream/ase/configure/ASESwaggerConfigure.java
new file mode 100644
index 0000000..1e2061e
--- /dev/null
+++ b/src/main/java/com/codesdream/ase/configure/ASESwaggerConfigure.java
@@ -0,0 +1,57 @@
+package com.codesdream.ase.configure;
+
+import com.google.common.collect.Sets;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.core.parameters.P;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.ParameterBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.schema.ModelRef;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.service.Parameter;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+@Configuration
+@EnableSwagger2
+public class ASESwaggerConfigure {
+ @Bean
+ public Docket createRestApi() {
+
+ List pars = new ArrayList();
+
+ pars.add(new ParameterBuilder().name("username").description("真实用户名").hidden(true).order(1)
+ .modelRef(new ModelRef("string")).parameterType("header")
+ .required(false).defaultValue("u_id_88883b9e023c8824310760d8bb8b6542e5a3f16a0d67253214e01ee7ab0e96a1").build());
+ pars.add(new ParameterBuilder().name("signed").description("客户端签名").hidden(true).order(2)
+ .modelRef(new ModelRef("string")).parameterType("header")
+ .required(false).defaultValue("6d4923fca4dcb51f67b85e54a23a8d763d9e02af").build());
+ pars.add(new ParameterBuilder().name("timestamp").description("时间戳").hidden(true).order(3)
+ .modelRef(new ModelRef("string")).parameterType("header")
+ .required(false).defaultValue(Long.toString(new Date().getTime())).build());
+
+ return new Docket(DocumentationType.SWAGGER_2)
+ .protocols(Sets.newHashSet("http"))
+ .apiInfo(apiInfo())
+ .select()
+ .apis(RequestHandlerSelectors.basePackage("com.codesdream.ase.controller"))
+ .paths(PathSelectors.any())
+ .build()
+ .globalOperationParameters(pars);
+ }
+
+ private ApiInfo apiInfo() {
+ return new ApiInfoBuilder()
+ .title("全员育人管理系统后端接口定义")
+ .version("0.0.1")
+ .description("用于对后端接口进行说明")
+ .build();
+ }
+}
diff --git a/src/main/java/com/codesdream/ase/configure/CustomWebSecurityConfig.java b/src/main/java/com/codesdream/ase/configure/CustomWebSecurityConfig.java
index 96d414a..b2d3413 100644
--- a/src/main/java/com/codesdream/ase/configure/CustomWebSecurityConfig.java
+++ b/src/main/java/com/codesdream/ase/configure/CustomWebSecurityConfig.java
@@ -87,7 +87,13 @@ public class CustomWebSecurityConfig extends WebSecurityConfigurerAdapter {
"/forget/**",
"/not_found/**",
"/error/**",
- "/login/**");
+ "/login/**",
+ "/swagger-ui.html",
+ "/webjars/**",
+ "/swagger-resources/**",
+ "/v2/api-docs",
+ "/configuration/ui",
+ "/configuration/security");
}
//注册自定义的UsernamePasswordAuthenticationFilter
diff --git a/src/main/java/com/codesdream/ase/controller/ASEControllerAdvice.java b/src/main/java/com/codesdream/ase/controller/ASEControllerAdvice.java
index 332f5ba..755d930 100644
--- a/src/main/java/com/codesdream/ase/controller/ASEControllerAdvice.java
+++ b/src/main/java/com/codesdream/ase/controller/ASEControllerAdvice.java
@@ -1,7 +1,11 @@
package com.codesdream.ase.controller;
+import com.codesdream.ase.component.api.QuickJSONRespond;
import com.codesdream.ase.component.error.ErrorResponse;
import com.codesdream.ase.component.json.respond.ErrorInfoJSONRespond;
+import com.codesdream.ase.exception.notfound.NotFoundException;
+import com.sun.xml.bind.v2.model.annotation.Quick;
+import org.apache.poi.openxml4j.opc.internal.ContentType;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.authentication.AuthenticationServiceException;
@@ -11,21 +15,39 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.context.request.WebRequest;
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@RestControllerAdvice
public class ASEControllerAdvice {
- @ExceptionHandler(value = {RuntimeException.class})
- public final Object handleRuntimeException(RuntimeException e, WebRequest webRequest){
+
+ @Resource
+ private QuickJSONRespond quickJSONRespond;
+
+ @ExceptionHandler(value = {NullPointerException.class})
+ public ResponseEntity