mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 12:56:28 +08:00
5.0
This commit is contained in:
@@ -17,10 +17,10 @@ import java.nio.charset.StandardCharsets;
|
||||
public class SwaggerPlugin {
|
||||
|
||||
/**
|
||||
* 推送文档,前提:把<code>doc-plugin.json</code>文件复制到resources下
|
||||
* 推送文档,前提:把<code>doc.json</code>文件复制到resources下
|
||||
*/
|
||||
public static void pushDoc() {
|
||||
pushDoc("doc-plugin.json");
|
||||
pushDoc("doc.json");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -58,7 +58,6 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -352,12 +351,12 @@ public class SwaggerPluginService {
|
||||
if (apiOperation.hidden()) {
|
||||
throw new HiddenException("Hidden API(@ApiOperation.hidden=true):" + apiOperation.value());
|
||||
}
|
||||
if (existsApiIgnore) {
|
||||
ApiIgnore apiIgnore = method.getAnnotation(ApiIgnore.class);
|
||||
if (apiIgnore != null) {
|
||||
throw new IgnoreException("Ignore API(@ApiIgnore):" + apiOperation.value());
|
||||
}
|
||||
}
|
||||
// if (existsApiIgnore) {
|
||||
// ApiIgnore apiIgnore = method.getAnnotation(ApiIgnore.class);
|
||||
// if (apiIgnore != null) {
|
||||
// throw new IgnoreException("Ignore API(@ApiIgnore):" + apiOperation.value());
|
||||
// }
|
||||
// }
|
||||
return doBuildDocItem(requestInfoBuilder);
|
||||
}
|
||||
|
||||
@@ -918,12 +917,12 @@ public class SwaggerPluginService {
|
||||
if (api != null && api.hidden()) {
|
||||
throw new HiddenException("Hidden doc(@Api.hidden=true):" + api.value());
|
||||
}
|
||||
if (existsApiIgnore) {
|
||||
ApiIgnore apiIgnore = AnnotationUtils.findAnnotation(controllerClass, ApiIgnore.class);
|
||||
if (apiIgnore != null) {
|
||||
throw new IgnoreException("Ignore doc(@ApiIgnore):" + controllerClass.getName());
|
||||
}
|
||||
}
|
||||
// if (existsApiIgnore) {
|
||||
// ApiIgnore apiIgnore = AnnotationUtils.findAnnotation(controllerClass, ApiIgnore.class);
|
||||
// if (apiIgnore != null) {
|
||||
// throw new IgnoreException("Ignore doc(@ApiIgnore):" + controllerClass.getName());
|
||||
// }
|
||||
// }
|
||||
String name, description;
|
||||
int position = 0;
|
||||
if (api == null) {
|
||||
|
@@ -1,43 +0,0 @@
|
||||
package com.gitee.sop.support.constants;
|
||||
|
||||
/**
|
||||
* RPC附件name
|
||||
*
|
||||
* @author 六如
|
||||
*/
|
||||
public class AttachmentNames {
|
||||
|
||||
/**
|
||||
* 分配给开发者的应用ID
|
||||
*/
|
||||
public static final String APP_ID = "client.app_id";
|
||||
/**
|
||||
* 接口名称
|
||||
*/
|
||||
public static final String API_NAME = "client.method";
|
||||
/**
|
||||
* 调用的接口版本
|
||||
*/
|
||||
public static final String VERSION = "client.version";
|
||||
/**
|
||||
* 开放平台主动通知商户服务器里指定的页面http/https路径
|
||||
*/
|
||||
public static final String NOTIFY_URL = "client.notify_url";
|
||||
/**
|
||||
* OAuth 2.0授权token
|
||||
*/
|
||||
public static final String APP_AUTH_TOKEN = "client.app_auth_token";
|
||||
/**
|
||||
* 请求id
|
||||
*/
|
||||
public static final String CLIENT_IP = "client.ip";
|
||||
/**
|
||||
* 请求traceId
|
||||
*/
|
||||
public static final String TRACE_ID = "client.trace_id";
|
||||
/**
|
||||
* 请求locale
|
||||
*/
|
||||
public static final String LOCALE = "client.locale";
|
||||
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
package com.gitee.sop.support.dto;
|
||||
package com.gitee.sop.support.context;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.util.Locale;
|
||||
* @author 六如
|
||||
*/
|
||||
@Data
|
||||
public class DefaultOpenRequest implements OpenRequest, Serializable {
|
||||
public class DefaultOpenContext implements OpenContext, Serializable {
|
||||
private static final long serialVersionUID = -3218354527911979685L;
|
||||
|
||||
/**
|
@@ -1,77 +1,50 @@
|
||||
package com.gitee.sop.support.context;
|
||||
|
||||
import com.gitee.sop.support.constants.AttachmentNames;
|
||||
import org.apache.dubbo.rpc.RpcContext;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
public class OpenContext {
|
||||
|
||||
public interface OpenContext {
|
||||
|
||||
/**
|
||||
* 获取appId
|
||||
*/
|
||||
public static String getAppId() {
|
||||
return getAttachment(AttachmentNames.APP_ID);
|
||||
}
|
||||
String getAppId();
|
||||
|
||||
/**
|
||||
* 获取apiName
|
||||
*/
|
||||
public static String getApiName() {
|
||||
return getAttachment(AttachmentNames.API_NAME);
|
||||
}
|
||||
String getApiName();
|
||||
|
||||
/**
|
||||
* 获取version
|
||||
*/
|
||||
public static String getVersion() {
|
||||
return getAttachment(AttachmentNames.VERSION);
|
||||
}
|
||||
String getVersion();
|
||||
|
||||
/**
|
||||
* 获取token,没有返回null
|
||||
*/
|
||||
public static String getAppAuthToken() {
|
||||
return getAttachment(AttachmentNames.APP_AUTH_TOKEN);
|
||||
}
|
||||
String getAppAuthToken();
|
||||
|
||||
/**
|
||||
* 获取客户端ip
|
||||
*/
|
||||
public static String getClientIp() {
|
||||
return getAttachment(AttachmentNames.CLIENT_IP);
|
||||
}
|
||||
String getClientIp();
|
||||
|
||||
/**
|
||||
* 获取回调地址
|
||||
*/
|
||||
public static String getNotifyUrl() {
|
||||
return getAttachment(AttachmentNames.NOTIFY_URL);
|
||||
}
|
||||
String getNotifyUrl();
|
||||
|
||||
/**
|
||||
* 获取唯一请求id
|
||||
*/
|
||||
public static String getTraceId() {
|
||||
return getAttachment(AttachmentNames.TRACE_ID);
|
||||
}
|
||||
String getTraceId();
|
||||
|
||||
/**
|
||||
* 获取locale
|
||||
*/
|
||||
public static Locale getLocale() {
|
||||
String langTag = getAttachment(AttachmentNames.LOCALE);
|
||||
if (langTag == null) {
|
||||
return Locale.SIMPLIFIED_CHINESE;
|
||||
}
|
||||
return Locale.forLanguageTag(langTag);
|
||||
}
|
||||
Locale getLocale();
|
||||
|
||||
private static String getAttachment(String key) {
|
||||
return RpcContext.getServerAttachment().getAttachment(key);
|
||||
}
|
||||
}
|
||||
|
@@ -1,50 +0,0 @@
|
||||
package com.gitee.sop.support.dto;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
public interface OpenRequest {
|
||||
|
||||
/**
|
||||
* 获取appId
|
||||
*/
|
||||
String getAppId();
|
||||
|
||||
/**
|
||||
* 获取apiName
|
||||
*/
|
||||
String getApiName();
|
||||
|
||||
/**
|
||||
* 获取version
|
||||
*/
|
||||
String getVersion();
|
||||
|
||||
/**
|
||||
* 获取token,没有返回null
|
||||
*/
|
||||
String getAppAuthToken();
|
||||
|
||||
/**
|
||||
* 获取客户端ip
|
||||
*/
|
||||
String getClientIp();
|
||||
|
||||
/**
|
||||
* 获取回调地址
|
||||
*/
|
||||
String getNotifyUrl();
|
||||
|
||||
/**
|
||||
* 获取唯一请求id
|
||||
*/
|
||||
String getTraceId();
|
||||
|
||||
/**
|
||||
* 获取locale
|
||||
*/
|
||||
Locale getLocale();
|
||||
|
||||
}
|
@@ -1,6 +1,5 @@
|
||||
package com.gitee.sop.support.exception;
|
||||
|
||||
import com.gitee.sop.support.context.OpenContext;
|
||||
import com.gitee.sop.support.message.I18nMessage;
|
||||
import com.gitee.sop.support.message.OpenMessage;
|
||||
import com.gitee.sop.support.message.OpenMessageFactory;
|
||||
@@ -29,7 +28,7 @@ public class OpenException extends RuntimeException {
|
||||
}
|
||||
|
||||
public OpenException(I18nMessage openError, Object... params) {
|
||||
this(openError, OpenContext.getLocale(), params);
|
||||
this(openError, Locale.SIMPLIFIED_CHINESE, params);
|
||||
}
|
||||
|
||||
public OpenException(String subCode, String subMsg, String solution) {
|
||||
|
@@ -1,2 +1,2 @@
|
||||
com.gitee.sop.support.dto.CommonFileData
|
||||
com.gitee.sop.support.dto.DefaultOpenRequest
|
||||
com.gitee.sop.support.context.DefaultOpenContext
|
||||
|
@@ -29,7 +29,6 @@
|
||||
<groupId>com.gitee.sop</groupId>
|
||||
<artifactId>sop-doc-plugin</artifactId>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- dubbo依赖 -->
|
||||
<dependency>
|
||||
|
Reference in New Issue
Block a user