From 9d2e795740a96e77194810dc80eacbbd0f5be3b9 Mon Sep 17 00:00:00 2001 From: smallchill Date: Mon, 21 Oct 2019 17:14:38 +0800 Subject: [PATCH] =?UTF-8?q?:tada:=20oss=E6=95=8F=E6=84=9F=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E5=A2=9E=E5=8A=A0=E6=9D=83=E9=99=90=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resource/endpoint/DiscoveryEndpoint.java | 58 ------------------- .../resource/endpoint/OssEndpoint.java | 6 ++ 2 files changed, 6 insertions(+), 58 deletions(-) delete mode 100644 blade-ops/blade-resource/src/main/java/org/springblade/resource/endpoint/DiscoveryEndpoint.java diff --git a/blade-ops/blade-resource/src/main/java/org/springblade/resource/endpoint/DiscoveryEndpoint.java b/blade-ops/blade-resource/src/main/java/org/springblade/resource/endpoint/DiscoveryEndpoint.java deleted file mode 100644 index 24ef6bbf..00000000 --- a/blade-ops/blade-resource/src/main/java/org/springblade/resource/endpoint/DiscoveryEndpoint.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the dreamlu.net developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: Chill 庄骞 (smallchill@163.com) - */ -package org.springblade.resource.endpoint; - -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.cloud.client.ServiceInstance; -import org.springframework.cloud.client.discovery.DiscoveryClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * 服务发现控制器 - * - * @author Chill - */ -@Slf4j -@RestController -@AllArgsConstructor -@RequestMapping("/discovery") -public class DiscoveryEndpoint { - - private final DiscoveryClient discoveryClient; - - /** - * 获取服务实例 - */ - @GetMapping("/instances") - public Map> instances() { - Map> instances = new HashMap<>(16); - List services = discoveryClient.getServices(); - services.forEach(s -> { - List list = discoveryClient.getInstances(s); - instances.put(s, list); - }); - return instances; - } - -} diff --git a/blade-ops/blade-resource/src/main/java/org/springblade/resource/endpoint/OssEndpoint.java b/blade-ops/blade-resource/src/main/java/org/springblade/resource/endpoint/OssEndpoint.java index 12709c18..a520d46e 100644 --- a/blade-ops/blade-resource/src/main/java/org/springblade/resource/endpoint/OssEndpoint.java +++ b/blade-ops/blade-resource/src/main/java/org/springblade/resource/endpoint/OssEndpoint.java @@ -21,7 +21,9 @@ import lombok.AllArgsConstructor; import lombok.SneakyThrows; import org.springblade.core.oss.model.BladeFile; import org.springblade.core.oss.model.OssFile; +import org.springblade.core.secure.annotation.PreAuth; import org.springblade.core.tool.api.R; +import org.springblade.core.tool.constant.RoleConstant; import org.springblade.core.tool.utils.Func; import org.springblade.resource.builder.OssBuilder; import org.springframework.web.bind.annotation.*; @@ -48,6 +50,7 @@ public class OssEndpoint { */ @SneakyThrows @PostMapping("/make-bucket") + @PreAuth(RoleConstant.HAS_ROLE_ADMIN) public R makeBucket(@RequestParam String bucketName) { ossBuilder.template().makeBucket(bucketName); return R.success("创建成功"); @@ -61,6 +64,7 @@ public class OssEndpoint { */ @SneakyThrows @PostMapping("/remove-bucket") + @PreAuth(RoleConstant.HAS_ROLE_ADMIN) public R removeBucket(@RequestParam String bucketName) { ossBuilder.template().removeBucket(bucketName); return R.success("删除成功"); @@ -153,6 +157,7 @@ public class OssEndpoint { */ @SneakyThrows @PostMapping("/remove-file") + @PreAuth(RoleConstant.HAS_ROLE_ADMIN) public R removeFile(@RequestParam String fileName) { ossBuilder.template().removeFile(fileName); return R.success("操作成功"); @@ -166,6 +171,7 @@ public class OssEndpoint { */ @SneakyThrows @PostMapping("/remove-files") + @PreAuth(RoleConstant.HAS_ROLE_ADMIN) public R removeFiles(@RequestParam String fileNames) { ossBuilder.template().removeFiles(Func.toStrList(fileNames)); return R.success("操作成功");