xiatian 9 maanden geleden
bovenliggende
commit
d7aa264194

+ 15 - 17
src/main/java/cn/com/qmth/scancentral/bean/ScannerLoginInfo.java

@@ -1,31 +1,29 @@
 package cn.com.qmth.scancentral.bean;
 
-import cn.com.qmth.scancentral.support.JsonSerializable;
+import java.io.Serializable;
+
 import io.swagger.annotations.ApiModelProperty;
 
 /**
  * 登陆信息
  * 
  */
-public class ScannerLoginInfo implements JsonSerializable {
-
-	private static final long serialVersionUID = 1305354276321732681L;
-
+public class ScannerLoginInfo implements Serializable {
 
-	/**
-	 * 密码
-	 */
-	@ApiModelProperty(value = "密码")
-	private String password;
+    private static final long serialVersionUID = 1305354276321732681L;
 
+    /**
+     * 密码
+     */
+    @ApiModelProperty(value = "密码")
+    private String password;
 
-	public String getPassword() {
-		return password;
-	}
+    public String getPassword() {
+        return password;
+    }
 
-	public void setPassword(String password) {
-		this.password = password;
-	}
+    public void setPassword(String password) {
+        this.password = password;
+    }
 
-	
 }

+ 0 - 31
src/main/java/cn/com/qmth/scancentral/config/ScanResourceManager.java

@@ -1,31 +0,0 @@
-package cn.com.qmth.scancentral.config;
-
-import org.springframework.stereotype.Component;
-
-import cn.com.qmth.scancentral.support.ApiInfo;
-import cn.com.qmth.scancentral.support.ResourceManager;
-
-
-@Component
-public class ScanResourceManager implements ResourceManager {
-
-    @Override
-    public boolean isNaked(ApiInfo apiInfo, String mapping) {
-        if (null == apiInfo) {
-            return true;
-        }
-
-        if (mapping.matches(".*swagger.*")) {
-            return true;
-        }
-
-        if (null != apiInfo) {
-            if (apiInfo.isNaked()) {
-                return true;
-            }
-        }
-
-        return false;
-    }
-
-}

+ 0 - 6
src/main/java/cn/com/qmth/scancentral/config/ScanWebMvcConfigurer.java

@@ -1,7 +1,5 @@
 package cn.com.qmth.scancentral.config;
 
-import cn.com.qmth.scancentral.support.ResourceManager;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.web.servlet.config.annotation.CorsRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@@ -12,13 +10,9 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 @Configuration
 public class ScanWebMvcConfigurer implements WebMvcConfigurer {
 
-    @Autowired
-    ResourceManager resourceManager;
-
     @Override
     public void addCorsMappings(CorsRegistry registry) {
         registry.addMapping("/**").allowedOrigins("*").allowCredentials(false).allowedMethods("*").maxAge(3600);
     }
 
 }
-

+ 0 - 118
src/main/java/cn/com/qmth/scancentral/support/ApiInfo.java

@@ -1,118 +0,0 @@
-package cn.com.qmth.scancentral.support;
-
-import java.io.Serializable;
-
-/**
- * 接口
- *
- */
-
-public class ApiInfo implements Serializable {
-
-	private static final long serialVersionUID = 1553810211239843543L;
-
-	/**
-	 * ID
-	 */
-	private Integer id;
-
-	/**
-	 * 映射
-	 */
-	private String mapping;
-
-	/**
-	 * mapping路径
-	 */
-	private String requestPath;
-
-	/**
-	 * http方法
-	 */
-	private String httpMethod;
-
-	/**
-	 * 接口描述
-	 */
-	private String description;
-
-	/**
-	 * 请求处理类
-	 */
-	private transient Class<?> beanType;
-
-	/**
-	 * 接口日志忽略堆栈
-	 */
-	private boolean withoutStackTrace;
-
-	/**
-	 * 接口裸奔
-	 */
-	private boolean naked;
-
-	public Integer getId() {
-		return id;
-	}
-
-	public void setId(Integer id) {
-		this.id = id;
-	}
-
-	public String getMapping() {
-		return mapping;
-	}
-
-	public void setMapping(String mapping) {
-		this.mapping = mapping;
-	}
-
-	public String getRequestPath() {
-		return requestPath;
-	}
-
-	public void setRequestPath(String requestPath) {
-		this.requestPath = requestPath;
-	}
-
-	public String getHttpMethod() {
-		return httpMethod;
-	}
-
-	public void setHttpMethod(String httpMethod) {
-		this.httpMethod = httpMethod;
-	}
-
-	public String getDescription() {
-		return description;
-	}
-
-	public void setDescription(String description) {
-		this.description = description;
-	}
-
-	public Class<?> getBeanType() {
-		return beanType;
-	}
-
-	public void setBeanType(Class<?> beanType) {
-		this.beanType = beanType;
-	}
-
-	public boolean isWithoutStackTrace() {
-		return withoutStackTrace;
-	}
-
-	public void setWithoutStackTrace(boolean withoutStackTrace) {
-		this.withoutStackTrace = withoutStackTrace;
-	}
-
-	public boolean isNaked() {
-		return naked;
-	}
-
-	public void setNaked(boolean naked) {
-		this.naked = naked;
-	}
-
-}

+ 0 - 148
src/main/java/cn/com/qmth/scancentral/support/ApiInfoHolder.java

@@ -1,148 +0,0 @@
-package cn.com.qmth.scancentral.support;
-
-import java.lang.reflect.Method;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.ApplicationArguments;
-import org.springframework.boot.ApplicationRunner;
-import org.springframework.core.annotation.AnnotationUtils;
-import org.springframework.core.annotation.Order;
-import org.springframework.stereotype.Component;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.method.HandlerMethod;
-import org.springframework.web.servlet.mvc.condition.PatternsRequestCondition;
-import org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondition;
-import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
-import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
-
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-
-import io.swagger.annotations.ApiOperation;
-
-@Component
-@Order(100)
-public class ApiInfoHolder implements ApplicationRunner {
-
-	private static final Map<String, ApiInfo> INDEX_BY_MAPPING = Maps.newConcurrentMap();
-
-	private static final Map<Method, ApiInfo> INDEX_BY_METHOD = Maps.newConcurrentMap();
-
-	private static Set<ApiInfo> apiInfoSet = Sets.newHashSet();
-
-	@Autowired
-	private RequestMappingHandlerMapping requestMappingHandlerMapping;
-
-
-	/**
-	 * 通过方法获取ApiInfo
-	 *
-	 * @author 
-	 * @param method
-	 * @return
-	 */
-	public static ApiInfo getApiInfo(Method method) {
-		return INDEX_BY_METHOD.get(method);
-	}
-
-	/**
-	 * 通过mapping获取ApiInfo
-	 *
-	 * @author 
-	 * @param mapping
-	 * @return
-	 */
-	public static ApiInfo getApiInfo(String mapping) {
-		return INDEX_BY_MAPPING.get(mapping);
-	}
-
-	/**
-	 * 获取@ApiId注解的ApiInfo集合
-	 *
-	 * @author 
-	 * @return
-	 */
-	public static Set<ApiInfo> getApiInfoSet() {
-		return apiInfoSet;
-	}
-
-	@Override
-	public void run(ApplicationArguments args) throws Exception {
-
-		Map<RequestMappingInfo, HandlerMethod> map = requestMappingHandlerMapping
-				.getHandlerMethods();
-
-		for (Map.Entry<RequestMappingInfo, HandlerMethod> entry : map.entrySet()) {
-			RequestMappingInfo requestMappingInfo = entry.getKey();
-			HandlerMethod handlerMethod = entry.getValue();
-
-			Class<?> beanType = handlerMethod.getBeanType();
-
-			RequestMapping requestMappingAnnotationOfClass = AnnotationUtils
-					.findAnnotation(beanType, RequestMapping.class);
-
-			RequestMapping requestMappingAnnotationOfMethod = handlerMethod
-					.getMethodAnnotation(RequestMapping.class);
-
-			WithoutStackTrace withoutStackTrace = handlerMethod
-					.getMethodAnnotation(WithoutStackTrace.class);
-
-			ApiOperation apiOperation = handlerMethod.getMethodAnnotation(ApiOperation.class);
-
-			RequestMethodsRequestCondition requestMethodsRequestCondition = requestMappingInfo
-					.getMethodsCondition();
-			Set<RequestMethod> requestMethodSet = requestMethodsRequestCondition.getMethods();
-
-			String[] mappingURIsOfClass = null;
-			String[] mappingURIsOfMethod = null;
-
-			if (null != requestMappingAnnotationOfClass) {
-				mappingURIsOfClass = requestMappingAnnotationOfClass.path();
-			}
-			if (null != requestMappingAnnotationOfMethod) {
-				mappingURIsOfMethod = requestMappingAnnotationOfMethod.path();
-			}
-
-			String mappingIdentifyOfClass = null;
-			String mappingIdentifyOfMethod = null;
-
-			if (null != mappingURIsOfClass) {
-				mappingIdentifyOfClass = StringUtils.join(mappingURIsOfClass, ",");
-			}
-			if (null != mappingURIsOfMethod) {
-				mappingIdentifyOfMethod = StringUtils.join(mappingURIsOfMethod, ",");
-			}
-
-			String methods = StringUtils.join(requestMethodSet, ",");
-
-			String mapping = StringUtils.join("[", mappingIdentifyOfClass, "][",
-					mappingIdentifyOfMethod, "][", methods, "]");
-
-			PatternsRequestCondition patternsRequestCondition = requestMappingInfo
-					.getPatternsCondition();
-
-			String requestPath = StringUtils.join(patternsRequestCondition.getPatterns(), ",");
-
-			ApiInfo apiInfo = new ApiInfo();
-			if (null != apiOperation) {
-				apiInfo.setDescription(apiOperation.value());
-			}
-			apiInfo.setHttpMethod(methods);
-			apiInfo.setMapping(mapping);
-			apiInfo.setRequestPath(requestPath);
-			apiInfo.setBeanType(beanType);
-			if (null != withoutStackTrace) {
-				apiInfo.setWithoutStackTrace(withoutStackTrace.value());
-			}
-
-			INDEX_BY_METHOD.put(handlerMethod.getMethod(), apiInfo);
-
-			INDEX_BY_MAPPING.put(mapping, apiInfo);
-		}
-	}
-
-}

+ 0 - 29
src/main/java/cn/com/qmth/scancentral/support/BaseResponse.java

@@ -1,29 +0,0 @@
-package cn.com.qmth.scancentral.support;
-
-import io.swagger.annotations.ApiModelProperty;
-
-/**
- * 响应体基类
- * 
- * @author 
- *
- */
-public abstract class BaseResponse extends ExchangeBean {
-
-	private static final long serialVersionUID = 1755304211766414171L;
-
-	/**
-	 * 耗时(毫秒)
-	 */
-	@ApiModelProperty(value = "耗时(毫秒)", example = "500", required = true)
-	private Long cost;
-
-	public Long getCost() {
-		return cost;
-	}
-
-	public void setCost(Long cost) {
-		this.cost = cost;
-	}
-
-}

+ 0 - 13
src/main/java/cn/com/qmth/scancentral/support/ExchangeBean.java

@@ -1,13 +0,0 @@
-package cn.com.qmth.scancentral.support;
-
-/**
- * bean 基类
- * 
- * @author 
- *
- */
-public abstract class ExchangeBean implements JsonSerializable {
-
-	private static final long serialVersionUID = 3913250969569367810L;
-
-}

+ 0 - 40
src/main/java/cn/com/qmth/scancentral/support/HttpMethodProcessor.java

@@ -1,40 +0,0 @@
-package cn.com.qmth.scancentral.support;
-
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * spring mvc 方法前校验器
- *
- */
-public interface HttpMethodProcessor {
-
-	/**
-	 * 方法前处理
-	 *
-	 * @author 
-	 * @param request
-	 * @param args
-	 */
-	void beforeMethod(HttpServletRequest request, Object[] args);
-
-	/**
-	 * 方法执行未抛出异常时执行
-	 *
-	 * @author 
-	 * @param request
-	 * @param args
-	 * @param ret
-	 */
-	void onSuccess(HttpServletRequest request, Object[] args, Object ret);
-
-	/**
-	 * 方法执行抛出异常时执行
-	 *
-	 * @author 
-	 * @param request
-	 * @param args
-	 * @param e
-	 */
-	void onException(HttpServletRequest request, Object[] args, Throwable e);
-
-}

+ 0 - 23
src/main/java/cn/com/qmth/scancentral/support/HttpMethodProcessorImpl.java

@@ -1,23 +0,0 @@
-package cn.com.qmth.scancentral.support;
-
-import javax.servlet.http.HttpServletRequest;
-
-import org.springframework.stereotype.Component;
-
-@Component
-public class HttpMethodProcessorImpl implements HttpMethodProcessor {
-
-	@Override
-	public void beforeMethod(HttpServletRequest request, Object[] args) {
-
-	}
-
-	@Override
-	public void onSuccess(HttpServletRequest request, Object[] args, Object ret) {
-	}
-
-	@Override
-	public void onException(HttpServletRequest request, Object[] args, Throwable e) {
-	}
-
-}

+ 0 - 7
src/main/java/cn/com/qmth/scancentral/support/JsonSerializable.java

@@ -1,7 +0,0 @@
-package cn.com.qmth.scancentral.support;
-
-import java.io.Serializable;
-
-public interface JsonSerializable extends Serializable {
-
-}

+ 0 - 40
src/main/java/cn/com/qmth/scancentral/support/LogProperties.java

@@ -1,40 +0,0 @@
-package cn.com.qmth.scancentral.support;
-
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.stereotype.Component;
-
-/**
- * 日志属性
- *
- */
-@Component
-@ConfigurationProperties("scan.web.log")
-public class LogProperties {
-
-	/**
-	 * 是否记录正常相应信息
-	 */
-	private boolean normalResponseLogEnable = true;
-
-	/**
-	 * 正常响应信息json长度限制
-	 */
-	private int responseLogJsonMaxSize = 200;
-
-	public boolean isNormalResponseLogEnable() {
-		return normalResponseLogEnable;
-	}
-
-	public void setNormalResponseLogEnable(boolean normalResponseLogEnable) {
-		this.normalResponseLogEnable = normalResponseLogEnable;
-	}
-
-	public int getResponseLogJsonMaxSize() {
-		return responseLogJsonMaxSize;
-	}
-
-	public void setResponseLogJsonMaxSize(int responseLogJsonMaxSize) {
-		this.responseLogJsonMaxSize = responseLogJsonMaxSize;
-	}
-
-}

+ 0 - 19
src/main/java/cn/com/qmth/scancentral/support/ResourceManager.java

@@ -1,19 +0,0 @@
-package cn.com.qmth.scancentral.support;
-
-/**
- * 资源管理器
- */
-public interface ResourceManager {
-
-
-    /**
-     * 请求的接口是否裸奔
-     *
-     * @param apiInfo
-     * @param mapping
-     * @return
-     */
-    boolean isNaked(ApiInfo apiInfo, String mapping);
-
-
-}

+ 0 - 55
src/main/java/cn/com/qmth/scancentral/support/StatusResponse.java

@@ -1,55 +0,0 @@
-package cn.com.qmth.scancentral.support;
-
-import io.swagger.annotations.ApiModelProperty;
-
-/**
- * 状态响应实体
- *
- */
-public class StatusResponse implements JsonSerializable {
-
-	private static final long serialVersionUID = 8393074113722405560L;
-
-	@ApiModelProperty(value = "响应编码", example = "001001", required = true)
-	private Integer code;
-
-	@ApiModelProperty(value = "响应描述", example = "密码错误", required = true)
-	private String desc;
-
-	/**
-	 * 构造函数
-	 *
-	 */
-	public StatusResponse() {
-		super();
-	}
-
-	/**
-	 * 构造函数
-	 *
-	 * @param code
-	 * @param desc
-	 */
-	public StatusResponse(Integer code, String desc) {
-		super();
-		this.code = code;
-		this.desc = desc;
-	}
-
-	public Integer getCode() {
-		return code;
-	}
-
-	public void setCode(Integer code) {
-		this.code = code;
-	}
-
-	public String getDesc() {
-		return desc;
-	}
-
-	public void setDesc(String desc) {
-		this.desc = desc;
-	}
-
-}

+ 0 - 21
src/main/java/cn/com/qmth/scancentral/support/WithoutStackTrace.java

@@ -1,21 +0,0 @@
-package cn.com.qmth.scancentral.support;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * 接口注解 <br>
- * 忽略接口日志堆栈<br>
- *
- */
-@Target(ElementType.METHOD)
-@Retention(RetentionPolicy.RUNTIME)
-@Documented
-public @interface WithoutStackTrace {
-
-	boolean value() default true;
-
-}