按规范修改

pull/19/head
暮光:城中城 6 years ago
parent e96418e346
commit fb0d78ea7a

@ -288,6 +288,9 @@ public class MgDocumentController {
* @author
* @since 2018821
* @param resourcesUrl swagger-resources
* @param oldUrl
* @param openVisit
* @param rewriteDomainUrl
* @return
*/
@PostMapping(value = "/addSwaggerResources")
@ -388,6 +391,7 @@ public class MgDocumentController {
*
* @author
* @since 2018821
* @return Location
*/
@PostMapping(value = "/getLocationList")
public ResponseJson<List<LocationListVo>> getLocationList() {

@ -4,15 +4,16 @@ import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
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.SwaggerResourcesInfoVo;
import com.zyplayer.doc.swagger.framework.constant.StorageKeys;
import com.zyplayer.doc.swagger.framework.service.MgStorageService;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
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.servlet.http.HttpServletRequest;
@ -39,18 +40,6 @@ public class MgOpenDocController {
return DocResponseJson.ok();
}
/**
* @author
* @since 2019127
*/
@ResponseBody
@PostMapping(value = "/{source}")
public ResponseJson<List<SwaggerResourcesInfoVo>> resourcesList(@PathVariable("source") String source) {
return DocResponseJson.ok();
}
/**
*
* @author

@ -1,89 +1,90 @@
package com.zyplayer.doc.swagger.framework.configuration;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
import java.lang.annotation.Annotation;
import java.util.Map;
/**
* context
*/
@Component
public class SpringContextUtil implements ApplicationContextAware {
public static ApplicationContext context;
private static EnableSwaggerMgUi ENABLE_SWAGGER_MG_UI;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
context = applicationContext;
}
public static ApplicationContext getApplicationContext() {
return context;
}
public static <T> T getBean(Class<T> clz) {
return context.getBean(clz);
}
public static Object getBean(String string) {
return getApplicationContext().getBean(string);
}
/**
*
* @param annotationType annotation
* @return
*/
public static Object getBeanWithAnnotation(Class<? extends Annotation> annotationType) {
if (context == null) {
return null;
}
Map<String, Object> beansWithAnnotation = context.getBeansWithAnnotation(annotationType);
if(beansWithAnnotation != null && beansWithAnnotation.size() > 0) {
for (Object element : beansWithAnnotation.values()) {
return element;
}
}
return null;
}
/**
* EnableSwaggerMgUi
* @date 2019/1/29 12:58
**/
public static EnableSwaggerMgUi getEnableSwaggerMgUi() {
if (ENABLE_SWAGGER_MG_UI != null) {
return ENABLE_SWAGGER_MG_UI;
}
Object annotation = SpringContextUtil.getBeanWithAnnotation(EnableSwaggerMgUi.class);
if (annotation != null) {
EnableSwaggerMgUi swaggerMgUi = annotation.getClass().getAnnotation(EnableSwaggerMgUi.class);
if (swaggerMgUi == null) {
// 直接通过superclass去找
Class<?> superclass = annotation.getClass().getSuperclass();
if (superclass != null) {
swaggerMgUi = superclass.getAnnotation(EnableSwaggerMgUi.class);
}
}
if (swaggerMgUi == null) {
// 再通过AopUtils去找
Class<?> targetClass = AopUtils.getTargetClass(annotation);
if (targetClass != null) {
swaggerMgUi = targetClass.getAnnotation(EnableSwaggerMgUi.class);
}
}
if (swaggerMgUi != null) {
ENABLE_SWAGGER_MG_UI = swaggerMgUi;
}
return swaggerMgUi;
}
return null;
}
}
package com.zyplayer.doc.swagger.framework.configuration;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
import java.lang.annotation.Annotation;
import java.util.Map;
/**
* context
*/
@Component
public class SpringContextUtil implements ApplicationContextAware {
public static ApplicationContext context;
private static EnableSwaggerMgUi ENABLE_SWAGGER_MG_UI;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
context = applicationContext;
}
public static ApplicationContext getApplicationContext() {
return context;
}
public static <T> T getBean(Class<T> clz) {
return context.getBean(clz);
}
public static Object getBean(String string) {
return getApplicationContext().getBean(string);
}
/**
*
* @param annotationType annotation
* @return
*/
public static Object getBeanWithAnnotation(Class<? extends Annotation> annotationType) {
if (context == null) {
return null;
}
Map<String, Object> beansWithAnnotation = context.getBeansWithAnnotation(annotationType);
if(beansWithAnnotation != null && beansWithAnnotation.size() > 0) {
for (Object element : beansWithAnnotation.values()) {
return element;
}
}
return null;
}
/**
* EnableSwaggerMgUi
* @since 2019/1/29 12:58
* @return EnableSwaggerMgUi
**/
public static EnableSwaggerMgUi getEnableSwaggerMgUi() {
if (ENABLE_SWAGGER_MG_UI != null) {
return ENABLE_SWAGGER_MG_UI;
}
Object annotation = SpringContextUtil.getBeanWithAnnotation(EnableSwaggerMgUi.class);
if (annotation != null) {
EnableSwaggerMgUi swaggerMgUi = annotation.getClass().getAnnotation(EnableSwaggerMgUi.class);
if (swaggerMgUi == null) {
// 直接通过superclass去找
Class<?> superclass = annotation.getClass().getSuperclass();
if (superclass != null) {
swaggerMgUi = superclass.getAnnotation(EnableSwaggerMgUi.class);
}
}
if (swaggerMgUi == null) {
// 再通过AopUtils去找
Class<?> targetClass = AopUtils.getTargetClass(annotation);
if (targetClass != null) {
swaggerMgUi = targetClass.getAnnotation(EnableSwaggerMgUi.class);
}
}
if (swaggerMgUi != null) {
ENABLE_SWAGGER_MG_UI = swaggerMgUi;
}
return swaggerMgUi;
}
return null;
}
}

@ -1,71 +1,73 @@
package com.zyplayer.doc.swagger.framework.service;
import com.zyplayer.doc.swagger.framework.constant.StorageKeys;
import org.apache.commons.lang.math.NumberUtils;
import java.util.List;
/**
* 使
* @author
* @since 2018819
*/
public interface MgStorageService {
/**
*
* @author
* @since 2018819
* @param key
* @return
*/
String get(String key);
/**
*
* @author
* @since 2018819
* @param key
* @param value
* @return
*/
List<MgStorage> like(String key, String value);
/**
*
* @author
* @since 2018819
* @param key
* @param value
*/
void put(String key, String value);
/**
*
* @author
* @since 2018819
* @param key
*/
void remove(String key);
/**
*
* @author
* @since 2018819
*/
List<String> getProxyRequestWhiteDomain();
/**
* ID
* @author
* @since 2019127
*/
default Integer getNextId() {
synchronized (StorageKeys.SWAGGER_ID_WORKER) {
String idWorker = this.get(StorageKeys.SWAGGER_ID_WORKER);
Integer nextId = NumberUtils.toInt(idWorker, 1);
this.put(StorageKeys.SWAGGER_ID_WORKER, String.valueOf(nextId + 1));
return nextId;
}
}
}
package com.zyplayer.doc.swagger.framework.service;
import com.zyplayer.doc.swagger.framework.constant.StorageKeys;
import org.apache.commons.lang.math.NumberUtils;
import java.util.List;
/**
* 使
* @author
* @since 2018819
*/
public interface MgStorageService {
/**
*
* @author
* @since 2018819
* @param key
* @return
*/
String get(String key);
/**
*
* @author
* @since 2018819
* @param key
* @param value
* @return
*/
List<MgStorage> like(String key, String value);
/**
*
* @author
* @since 2018819
* @param key
* @param value
*/
void put(String key, String value);
/**
*
* @author
* @since 2018819
* @param key
*/
void remove(String key);
/**
*
* @author
* @since 2018819
* @return
*/
List<String> getProxyRequestWhiteDomain();
/**
* ID
* @author
* @since 2019127
* @return ID
*/
default Integer getNextId() {
synchronized (StorageKeys.SWAGGER_ID_WORKER) {
String idWorker = this.get(StorageKeys.SWAGGER_ID_WORKER);
Integer nextId = NumberUtils.toInt(idWorker, 1);
this.put(StorageKeys.SWAGGER_ID_WORKER, String.valueOf(nextId + 1));
return nextId;
}
}
}

Loading…
Cancel
Save