按规范修改
This commit is contained in:
@@ -288,6 +288,9 @@ public class MgDocumentController {
|
|||||||
* @author 暮光:城中城
|
* @author 暮光:城中城
|
||||||
* @since 2018年8月21日
|
* @since 2018年8月21日
|
||||||
* @param resourcesUrl swagger-resources地址
|
* @param resourcesUrl swagger-resources地址
|
||||||
|
* @param oldUrl 老地址
|
||||||
|
* @param openVisit 是否开放展示
|
||||||
|
* @param rewriteDomainUrl 重写域名地址
|
||||||
* @return 添加结果
|
* @return 添加结果
|
||||||
*/
|
*/
|
||||||
@PostMapping(value = "/addSwaggerResources")
|
@PostMapping(value = "/addSwaggerResources")
|
||||||
@@ -388,6 +391,7 @@ public class MgDocumentController {
|
|||||||
*
|
*
|
||||||
* @author 暮光:城中城
|
* @author 暮光:城中城
|
||||||
* @since 2018年8月21日
|
* @since 2018年8月21日
|
||||||
|
* @return Location列表
|
||||||
*/
|
*/
|
||||||
@PostMapping(value = "/getLocationList")
|
@PostMapping(value = "/getLocationList")
|
||||||
public ResponseJson<List<LocationListVo>> getLocationList() {
|
public ResponseJson<List<LocationListVo>> getLocationList() {
|
||||||
|
|||||||
@@ -4,15 +4,16 @@ import cn.hutool.http.HttpRequest;
|
|||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.TypeReference;
|
import com.alibaba.fastjson.TypeReference;
|
||||||
import com.zyplayer.doc.core.json.DocResponseJson;
|
import com.zyplayer.doc.core.json.DocResponseJson;
|
||||||
import com.zyplayer.doc.core.json.ResponseJson;
|
|
||||||
import com.zyplayer.doc.swagger.controller.vo.LocationListVo;
|
import com.zyplayer.doc.swagger.controller.vo.LocationListVo;
|
||||||
import com.zyplayer.doc.swagger.controller.vo.SwaggerResourcesInfoVo;
|
|
||||||
import com.zyplayer.doc.swagger.framework.constant.StorageKeys;
|
import com.zyplayer.doc.swagger.framework.constant.StorageKeys;
|
||||||
import com.zyplayer.doc.swagger.framework.service.MgStorageService;
|
import com.zyplayer.doc.swagger.framework.service.MgStorageService;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
@@ -39,18 +40,6 @@ public class MgOpenDocController {
|
|||||||
return DocResponseJson.ok();
|
return DocResponseJson.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @author 暮光:城中城
|
|
||||||
* @since 2019年1月27日
|
|
||||||
*/
|
|
||||||
@ResponseBody
|
|
||||||
@PostMapping(value = "/{source}")
|
|
||||||
public ResponseJson<List<SwaggerResourcesInfoVo>> resourcesList(@PathVariable("source") String source) {
|
|
||||||
|
|
||||||
return DocResponseJson.ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取所有的文档
|
* 获取所有的文档
|
||||||
* @author 暮光:城中城
|
* @author 暮光:城中城
|
||||||
|
|||||||
@@ -1,89 +1,90 @@
|
|||||||
package com.zyplayer.doc.swagger.framework.configuration;
|
package com.zyplayer.doc.swagger.framework.configuration;
|
||||||
|
|
||||||
import org.springframework.aop.support.AopUtils;
|
import org.springframework.aop.support.AopUtils;
|
||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.ApplicationContextAware;
|
import org.springframework.context.ApplicationContextAware;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* context工具类
|
* context工具类
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class SpringContextUtil implements ApplicationContextAware {
|
public class SpringContextUtil implements ApplicationContextAware {
|
||||||
|
|
||||||
public static ApplicationContext context;
|
public static ApplicationContext context;
|
||||||
private static EnableSwaggerMgUi ENABLE_SWAGGER_MG_UI;
|
private static EnableSwaggerMgUi ENABLE_SWAGGER_MG_UI;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||||
context = applicationContext;
|
context = applicationContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ApplicationContext getApplicationContext() {
|
public static ApplicationContext getApplicationContext() {
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T getBean(Class<T> clz) {
|
public static <T> T getBean(Class<T> clz) {
|
||||||
return context.getBean(clz);
|
return context.getBean(clz);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object getBean(String string) {
|
public static Object getBean(String string) {
|
||||||
return getApplicationContext().getBean(string);
|
return getApplicationContext().getBean(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取类
|
* 获取类
|
||||||
* @param annotationType annotation
|
* @param annotationType annotation
|
||||||
* @return 类对象
|
* @return 类对象
|
||||||
*/
|
*/
|
||||||
public static Object getBeanWithAnnotation(Class<? extends Annotation> annotationType) {
|
public static Object getBeanWithAnnotation(Class<? extends Annotation> annotationType) {
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Map<String, Object> beansWithAnnotation = context.getBeansWithAnnotation(annotationType);
|
Map<String, Object> beansWithAnnotation = context.getBeansWithAnnotation(annotationType);
|
||||||
if(beansWithAnnotation != null && beansWithAnnotation.size() > 0) {
|
if(beansWithAnnotation != null && beansWithAnnotation.size() > 0) {
|
||||||
for (Object element : beansWithAnnotation.values()) {
|
for (Object element : beansWithAnnotation.values()) {
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取EnableSwaggerMgUi
|
* 获取EnableSwaggerMgUi
|
||||||
* @date 2019/1/29 12:58
|
* @since 2019/1/29 12:58
|
||||||
**/
|
* @return EnableSwaggerMgUi注解对象
|
||||||
public static EnableSwaggerMgUi getEnableSwaggerMgUi() {
|
**/
|
||||||
if (ENABLE_SWAGGER_MG_UI != null) {
|
public static EnableSwaggerMgUi getEnableSwaggerMgUi() {
|
||||||
return ENABLE_SWAGGER_MG_UI;
|
if (ENABLE_SWAGGER_MG_UI != null) {
|
||||||
}
|
return ENABLE_SWAGGER_MG_UI;
|
||||||
Object annotation = SpringContextUtil.getBeanWithAnnotation(EnableSwaggerMgUi.class);
|
}
|
||||||
if (annotation != null) {
|
Object annotation = SpringContextUtil.getBeanWithAnnotation(EnableSwaggerMgUi.class);
|
||||||
EnableSwaggerMgUi swaggerMgUi = annotation.getClass().getAnnotation(EnableSwaggerMgUi.class);
|
if (annotation != null) {
|
||||||
if (swaggerMgUi == null) {
|
EnableSwaggerMgUi swaggerMgUi = annotation.getClass().getAnnotation(EnableSwaggerMgUi.class);
|
||||||
// 直接通过superclass去找
|
if (swaggerMgUi == null) {
|
||||||
Class<?> superclass = annotation.getClass().getSuperclass();
|
// 直接通过superclass去找
|
||||||
if (superclass != null) {
|
Class<?> superclass = annotation.getClass().getSuperclass();
|
||||||
swaggerMgUi = superclass.getAnnotation(EnableSwaggerMgUi.class);
|
if (superclass != null) {
|
||||||
}
|
swaggerMgUi = superclass.getAnnotation(EnableSwaggerMgUi.class);
|
||||||
}
|
}
|
||||||
if (swaggerMgUi == null) {
|
}
|
||||||
// 再通过AopUtils去找
|
if (swaggerMgUi == null) {
|
||||||
Class<?> targetClass = AopUtils.getTargetClass(annotation);
|
// 再通过AopUtils去找
|
||||||
if (targetClass != null) {
|
Class<?> targetClass = AopUtils.getTargetClass(annotation);
|
||||||
swaggerMgUi = targetClass.getAnnotation(EnableSwaggerMgUi.class);
|
if (targetClass != null) {
|
||||||
}
|
swaggerMgUi = targetClass.getAnnotation(EnableSwaggerMgUi.class);
|
||||||
}
|
}
|
||||||
if (swaggerMgUi != null) {
|
}
|
||||||
ENABLE_SWAGGER_MG_UI = swaggerMgUi;
|
if (swaggerMgUi != null) {
|
||||||
}
|
ENABLE_SWAGGER_MG_UI = swaggerMgUi;
|
||||||
return swaggerMgUi;
|
}
|
||||||
}
|
return swaggerMgUi;
|
||||||
return null;
|
}
|
||||||
}
|
return null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,71 +1,73 @@
|
|||||||
package com.zyplayer.doc.swagger.framework.service;
|
package com.zyplayer.doc.swagger.framework.service;
|
||||||
|
|
||||||
import com.zyplayer.doc.swagger.framework.constant.StorageKeys;
|
import com.zyplayer.doc.swagger.framework.constant.StorageKeys;
|
||||||
import org.apache.commons.lang.math.NumberUtils;
|
import org.apache.commons.lang.math.NumberUtils;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 实现此类才能使用服务器端的存贮功能
|
* 实现此类才能使用服务器端的存贮功能
|
||||||
* @author 暮光:城中城
|
* @author 暮光:城中城
|
||||||
* @since 2018年8月19日
|
* @since 2018年8月19日
|
||||||
*/
|
*/
|
||||||
public interface MgStorageService {
|
public interface MgStorageService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取存储的值
|
* 获取存储的值
|
||||||
* @author 暮光:城中城
|
* @author 暮光:城中城
|
||||||
* @since 2018年8月19日
|
* @since 2018年8月19日
|
||||||
* @param key 参数
|
* @param key 参数
|
||||||
* @return 值
|
* @return 值
|
||||||
*/
|
*/
|
||||||
String get(String key);
|
String get(String key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 模糊获取存储的值
|
* 模糊获取存储的值
|
||||||
* @author 暮光:城中城
|
* @author 暮光:城中城
|
||||||
* @since 2018年8月19日
|
* @since 2018年8月19日
|
||||||
* @param key 参数
|
* @param key 参数
|
||||||
* @param value 值
|
* @param value 值
|
||||||
* @return 值
|
* @return 值
|
||||||
*/
|
*/
|
||||||
List<MgStorage> like(String key, String value);
|
List<MgStorage> like(String key, String value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 存储数据
|
* 存储数据
|
||||||
* @author 暮光:城中城
|
* @author 暮光:城中城
|
||||||
* @since 2018年8月19日
|
* @since 2018年8月19日
|
||||||
* @param key 参数
|
* @param key 参数
|
||||||
* @param value 值
|
* @param value 值
|
||||||
*/
|
*/
|
||||||
void put(String key, String value);
|
void put(String key, String value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除数据
|
* 删除数据
|
||||||
* @author 暮光:城中城
|
* @author 暮光:城中城
|
||||||
* @since 2018年8月19日
|
* @since 2018年8月19日
|
||||||
* @param key 参数
|
* @param key 参数
|
||||||
*/
|
*/
|
||||||
void remove(String key);
|
void remove(String key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取代理请求白名单
|
* 获取代理请求白名单
|
||||||
* @author 暮光:城中城
|
* @author 暮光:城中城
|
||||||
* @since 2018年8月19日
|
* @since 2018年8月19日
|
||||||
*/
|
* @return 白名单列表
|
||||||
List<String> getProxyRequestWhiteDomain();
|
*/
|
||||||
|
List<String> getProxyRequestWhiteDomain();
|
||||||
/**
|
|
||||||
* 获取一个自增的ID
|
/**
|
||||||
* @author 暮光:城中城
|
* 获取一个自增的ID
|
||||||
* @since 2019年1月27日
|
* @author 暮光:城中城
|
||||||
*/
|
* @since 2019年1月27日
|
||||||
default Integer getNextId() {
|
* @return 自增ID
|
||||||
synchronized (StorageKeys.SWAGGER_ID_WORKER) {
|
*/
|
||||||
String idWorker = this.get(StorageKeys.SWAGGER_ID_WORKER);
|
default Integer getNextId() {
|
||||||
Integer nextId = NumberUtils.toInt(idWorker, 1);
|
synchronized (StorageKeys.SWAGGER_ID_WORKER) {
|
||||||
this.put(StorageKeys.SWAGGER_ID_WORKER, String.valueOf(nextId + 1));
|
String idWorker = this.get(StorageKeys.SWAGGER_ID_WORKER);
|
||||||
return nextId;
|
Integer nextId = NumberUtils.toInt(idWorker, 1);
|
||||||
}
|
this.put(StorageKeys.SWAGGER_ID_WORKER, String.valueOf(nextId + 1));
|
||||||
}
|
return nextId;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user