优化获取接口选项的接口。

This commit is contained in:
mxd 2021-03-28 10:57:17 +08:00
parent 93cac14884
commit 4c1cdf3c55
3 changed files with 17 additions and 5 deletions

View File

@ -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")

View File

@ -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) {

View File

@ -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;
}
}