新增 aws 区域数据接口

This commit is contained in:
besscroft
2023-03-12 16:40:30 +08:00
parent 4bfcfb2fa8
commit 031d1d5990
3 changed files with 22 additions and 0 deletions

View File

@@ -162,4 +162,11 @@ public class StorageController {
return CommonResult.success(storageService.getEnableStorage());
}
@SaIgnore
@Operation(summary = "获取 AWS Region 列表")
@GetMapping("/getAwsRegions")
public CommonResult<List<String>> getAwsRegions() {
return CommonResult.success(storageService.getAwsRegions());
}
}

View File

@@ -108,4 +108,10 @@ public interface StorageService extends IService<Storage> {
*/
void saveStorageInfoVoList(List<StorageInfoVo> storageInfoVoList);
/**
* 获取 aws 存储区域列表
* @return 存储区域列表
*/
List<String> getAwsRegions();
}

View File

@@ -22,20 +22,24 @@ import com.besscroft.diyfile.service.StorageService;
import com.besscroft.diyfile.storage.context.StorageApplicationContext;
import com.github.pagehelper.PageHelper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import software.amazon.awssdk.regions.Region;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* @Description 存储服务实现类
* @Author Bess Croft
* @Date 2022/12/18 21:13
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class StorageServiceImpl extends ServiceImpl<StorageMapper, Storage> implements StorageService {
@@ -238,4 +242,9 @@ public class StorageServiceImpl extends ServiceImpl<StorageMapper, Storage> impl
}
}
@Override
public List<String> getAwsRegions() {
return Region.regions().stream().map(Region::id).collect(Collectors.toList());
}
}