mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
新增OpenGroup注解
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package com.gitee.sop.support.annotation;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Inherited;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 分组
|
||||
*
|
||||
* @author 六如
|
||||
*/
|
||||
@Inherited
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface OpenGroup {
|
||||
|
||||
/**
|
||||
* 分组名称
|
||||
*/
|
||||
String value();
|
||||
|
||||
}
|
@@ -2,6 +2,7 @@ package com.gitee.sop.support.register;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.gitee.sop.support.annotation.Open;
|
||||
import com.gitee.sop.support.annotation.OpenGroup;
|
||||
import com.gitee.sop.support.message.OpenMessageFactory;
|
||||
import com.gitee.sop.support.service.ApiRegisterService;
|
||||
import com.gitee.sop.support.service.dto.RegisterDTO;
|
||||
@@ -114,7 +115,7 @@ public class ApiRegister {
|
||||
List<ParamInfo> paramInfos = buildParamInfo(method);
|
||||
RegisterDTO registerDTO = new RegisterDTO();
|
||||
registerDTO.setApplication(appName);
|
||||
registerDTO.setApiName(getApiName(open));
|
||||
registerDTO.setApiName(getApiName(interfaceClass, open));
|
||||
registerDTO.setApiVersion(open.version());
|
||||
registerDTO.setInterfaceClassName(interfaceClass.getName());
|
||||
registerDTO.setMethodName(method.getName());
|
||||
@@ -133,8 +134,13 @@ public class ApiRegister {
|
||||
}
|
||||
}
|
||||
|
||||
protected String getApiName(Open open) {
|
||||
return StringUtils.trimLeadingCharacter(open.value(), '/');
|
||||
protected String getApiName(Class<?> interfaceClass, Open open) {
|
||||
String apiName = StringUtils.trimLeadingCharacter(open.value(), '/');
|
||||
OpenGroup openGroup = interfaceClass.getAnnotation(OpenGroup.class);
|
||||
if (openGroup != null) {
|
||||
apiName = openGroup.value() + "/" + apiName;
|
||||
}
|
||||
return StringUtils.trimLeadingCharacter(apiName, '/');
|
||||
}
|
||||
|
||||
private List<ParamInfo> buildParamInfo(Method method) {
|
||||
|
Reference in New Issue
Block a user