增加权限验证
This commit is contained in:
@@ -13,6 +13,8 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.aop.support.AopUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -43,6 +45,8 @@ import springfox.documentation.swagger.web.SwaggerResource;
|
||||
@RequestMapping("/swagger-mg-ui/document")
|
||||
public class MgDocumentController {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(MgDocumentController.class);
|
||||
|
||||
@Autowired(required = false)
|
||||
private MgStorageService storageService;
|
||||
|
||||
@@ -144,7 +148,7 @@ public class MgDocumentController {
|
||||
String resourcesStr = HttpRequest.get(resourcesUrl).timeout(3000).execute().body();
|
||||
resourceList = JSON.parseArray(resourcesStr, SwaggerResource.class);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("获取文档失败:{},{}", resourcesUrl, e.getMessage());
|
||||
}
|
||||
if (resourceList == null || resourceList.isEmpty()) {
|
||||
continue;
|
||||
@@ -183,7 +187,7 @@ public class MgDocumentController {
|
||||
+ resourceStr;
|
||||
swaggerResourceStrList.add(resourceStr);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("获取文档失败:{},{}", location, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -245,7 +249,7 @@ public class MgDocumentController {
|
||||
}
|
||||
resourcesSet.add(resourcesUrl);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("获取文档失败:{},{}", resourcesUrl, e.getMessage());
|
||||
return MgUiResponseJson.warn("改地址查找文档失败");
|
||||
}
|
||||
storageService.put(StorageKeys.SWAGGER_RESOURCES_LIST, JSON.toJSONString(resourcesSet));
|
||||
|
||||
@@ -25,7 +25,7 @@ public class MgStorageController {
|
||||
|
||||
@PostMapping(value = "/checkConfig")
|
||||
public MgUiResponseJson checkConfig() {
|
||||
// 本接口能访问当而且实现了MgStorageService才算配置好了
|
||||
// 本接口能访问到而且实现了MgStorageService才算配置好了
|
||||
if (storageService == null) {
|
||||
return MgUiResponseJson.error("服务不可用");
|
||||
}
|
||||
@@ -43,6 +43,19 @@ public class MgStorageController {
|
||||
storageService.put(key, value);
|
||||
return MgUiResponseJson.ok();
|
||||
}
|
||||
|
||||
@PostMapping(value = "/delete")
|
||||
public MgUiResponseJson delete(String key) {
|
||||
if (storageService == null) {
|
||||
return MgUiResponseJson.warn(Toast.AUTOWIRED_ERROR);
|
||||
}
|
||||
if (key == null) {
|
||||
return MgUiResponseJson.warn("参数名不能为空");
|
||||
}
|
||||
String value = storageService.get(key);
|
||||
value = (value == null) ? "" : value;
|
||||
return MgUiResponseJson.ok(value);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/data")
|
||||
public MgUiResponseJson getData(String key) {
|
||||
|
||||
@@ -25,4 +25,12 @@ public interface MgStorageService {
|
||||
*/
|
||||
void put(String key, String value);
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
* @author 暮光:城中城
|
||||
* @since 2018年8月19日
|
||||
* @param key
|
||||
*/
|
||||
void remove(String key);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user