mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
5.0
This commit is contained in:
@@ -27,7 +27,7 @@ public @interface Open {
|
||||
String version() default "1.0";
|
||||
|
||||
/**
|
||||
* 指定接口是否需要授权才能访问,可在admin中进行修改
|
||||
* 指定接口是否需要授权才能访问,可在admin中进行授权
|
||||
*/
|
||||
boolean permission() default false;
|
||||
|
||||
@@ -36,4 +36,27 @@ public @interface Open {
|
||||
*/
|
||||
boolean needToken() default false;
|
||||
|
||||
/**
|
||||
* 是否有公共响应参数,默认true
|
||||
* <pre>
|
||||
* 如果设置true,返回结果如下
|
||||
* {
|
||||
* "code": "0",
|
||||
* "msg": "",
|
||||
* "sub_code": "",
|
||||
* "sub_msg": "",
|
||||
* "data": {
|
||||
* "id": 1,
|
||||
* "name": "Jim"
|
||||
* }
|
||||
* }
|
||||
* 如果设置false,只返回data部分:
|
||||
* {
|
||||
* "id": 1,
|
||||
* "name": "Jim"
|
||||
* }
|
||||
* </pre>
|
||||
*/
|
||||
boolean hasCommonResponse() default true;
|
||||
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@ import com.gitee.sop.support.annotation.Open;
|
||||
import com.gitee.sop.support.service.ApiRegisterService;
|
||||
import com.gitee.sop.support.service.dto.RegisterDTO;
|
||||
import com.gitee.sop.support.service.dto.RegisterResult;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -109,6 +110,11 @@ public class ApiRegister {
|
||||
registerDTO.setParamInfo(JSON.toJSONString(paramInfos));
|
||||
registerDTO.setIsPermission(parseBoolean(open.permission()));
|
||||
registerDTO.setIsNeedToken(parseBoolean(open.needToken()));
|
||||
registerDTO.setHasCommonResponse(parseBoolean(open.hasCommonResponse()));
|
||||
ApiOperation apiOperation = method.getAnnotation(ApiOperation.class);
|
||||
if (apiOperation != null) {
|
||||
registerDTO.setDescription(apiOperation.value());
|
||||
}
|
||||
LOG.info("注册开放接口, apiInfo=" + registerDTO);
|
||||
RegisterResult result = apiRegisterService.register(registerDTO);
|
||||
if (!result.getSuccess()) {
|
||||
|
@@ -61,5 +61,10 @@ public class RegisterDTO implements Serializable {
|
||||
*/
|
||||
private Integer isNeedToken;
|
||||
|
||||
/**
|
||||
* 是否有公共响应参数
|
||||
*/
|
||||
private Integer hasCommonResponse;
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user