优化获取接口选项的接口。
This commit is contained in:
parent
93cac14884
commit
4c1cdf3c55
@ -121,8 +121,8 @@ public class MagicWorkbenchController extends MagicController implements MagicEx
|
||||
@RequestMapping("/options")
|
||||
@ResponseBody
|
||||
@Valid(requireLogin = false)
|
||||
public JsonBean<List<Map<String, String>>> options() {
|
||||
return new JsonBean<>(Stream.of(Options.values()).map(item -> Collections.singletonMap(item.getValue(), item.getName())).collect(Collectors.toList()));
|
||||
public JsonBean<List<List<String>>> options() {
|
||||
return new JsonBean<>(Stream.of(Options.values()).map(item -> Arrays.asList(item.getValue(),item.getName(),item.getDefaultValue())).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/config-js")
|
||||
|
||||
@ -194,7 +194,7 @@ public class ApiInfo extends MagicEntity{
|
||||
}
|
||||
|
||||
public String getOptionValue(Options options){
|
||||
return getOptionValue(options.name());
|
||||
return getOptionValue(options.getValue());
|
||||
}
|
||||
|
||||
public String getOptionValue(String key) {
|
||||
|
||||
@ -3,15 +3,23 @@ package org.ssssssss.magicapi.model;
|
||||
public enum Options {
|
||||
|
||||
WRAP_REQUEST_PARAMETERS("包装请求参数到一个变量中", "wrap_request_parameter"),
|
||||
PERMISSION("允许拥有该权限的访问","permission"),
|
||||
ROLE("允许拥有该角色的访问","role");
|
||||
PERMISSION("允许拥有该权限的访问", "permission"),
|
||||
ROLE("允许拥有该角色的访问", "role"),
|
||||
REQUIRE_LOGIN("该接口需要登录才允许访问", "require_login", "true"),
|
||||
ANONYMOUS("该接口需要不登录也可访问", "anonymous", "true");
|
||||
|
||||
private final String name;
|
||||
private final String value;
|
||||
private final String defaultValue;
|
||||
|
||||
Options(String name, String value) {
|
||||
this(name, value, null);
|
||||
}
|
||||
|
||||
Options(String name, String value, String defaultValue) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@ -21,4 +29,8 @@ public enum Options {
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user