Skip to content

Commit

Permalink
support using Huawei Cloud OBS to store custom define yml file (#1266)
Browse files Browse the repository at this point in the history
Co-authored-by: tomsun28 <[email protected]>
  • Loading branch information
gcdd1993 and tomsun28 authored Oct 8, 2023
1 parent 71163bd commit 42acda8
Show file tree
Hide file tree
Showing 24 changed files with 930 additions and 148 deletions.
6 changes: 6 additions & 0 deletions manager/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<warehouse.version>1.0</warehouse.version>
<easy-poi.version>4.3.0</easy-poi.version>
<huawei.sdk.version>3.1.37</huawei.sdk.version>
<huawei.obs.version>3.23.5</huawei.obs.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -149,6 +150,11 @@
<artifactId>huaweicloud-sdk-smn</artifactId>
<version>${huawei.sdk.version}</version>
</dependency>
<dependency>
<groupId>com.huaweicloud</groupId>
<artifactId>esdk-obs-java</artifactId>
<version>${huawei.obs.version}</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.dromara.hertzbeat.manager.pojo.dto;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.InputStream;

/**
* 文件存储
*
* @author <a href="mailto:[email protected]">gcdd1993</a>
* Created by gcdd1993 on 2023/9/13
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class FileDTO {
private String name;
private InputStream inputStream;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.dromara.hertzbeat.manager.pojo.dto;

import lombok.Getter;
import org.springframework.context.ApplicationEvent;

import java.util.UUID;

/**
* @author <a href="mailto:[email protected]">gcdd1993</a>
* Created by gcdd1993 on 2023/9/28
*/
@Getter
public class ObjectStoreConfigChangeEvent extends ApplicationEvent {
private final ObjectStoreDTO<?> config;

public ObjectStoreConfigChangeEvent(ObjectStoreDTO<?> config) {
super(UUID.randomUUID());
this.config = config;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package org.dromara.hertzbeat.manager.pojo.dto;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
* 文件存储容器
*
* @author <a href="mailto:[email protected]">gcdd1993</a>
* Created by gcdd1993 on 2023/9/13
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ObjectStoreDTO<T> {

/**
* 文件存储服务类型
*/
private Type type;

/**
* 配置项
*/
private T config;

/**
* 文件存储服务类型
*/
public enum Type {

/**
* 本地文件
*/
FILE,

/**
* <a href="https://support.huaweicloud.com/obs/index.html">华为云OBS</a>
*/
OBS
}

@Data
public static class ObsConfig {
private String accessKey;
private String secretKey;
private String bucketName;
private String endpoint;

/**
* 保存路径
*/
private String savePath = "hertzbeat";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class SystemConfig {
* 系统语言地区
*/
private String locale;

/**
* layout ui theme
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.dromara.hertzbeat.manager.service;

import org.dromara.hertzbeat.manager.pojo.dto.FileDTO;
import org.dromara.hertzbeat.manager.pojo.dto.ObjectStoreDTO;

import java.io.InputStream;
import java.util.List;

/**
* 文件存储服务
*
* @author <a href="mailto:[email protected]">gcdd1993</a>
* Created by gcdd1993 on 2023/9/13
*/
public interface ObjectStoreService {

/**
* 保存文件
*
* @param filePath 文件路径,例如:hertzbeat/111.json
* @param is 文件流
*/
boolean upload(String filePath, InputStream is);

/**
* 读取文件
*
* @param filePath 文件路径,例如:hertzbeat/111.json
* @return 文件
*/
FileDTO download(String filePath);

/**
* 列举文件
*
* @param dir 文件目录
* @return 文件列表
*/
List<FileDTO> list(String dir);

ObjectStoreDTO.Type type();

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* 提供通用配置Service的抽象实现,实现了增删查改等操作。
*
* <p>Abstract implementation of GeneralConfigService, providing CRUD operations for configurations.</p>
*
* @author zqr10159
*/
@Slf4j
Expand All @@ -26,7 +27,7 @@ abstract class AbstractGeneralConfigServiceImpl<T> implements GeneralConfigServi
* <p>Constructor, passing in GeneralConfigDao, ObjectMapper and type.</p>
*
* @param generalConfigDao 配置Dao对象
* @param objectMapper JSON工具类对象
* @param objectMapper JSON工具类对象
*/
protected AbstractGeneralConfigServiceImpl(GeneralConfigDao generalConfigDao, ObjectMapper objectMapper) {
this.generalConfigDao = generalConfigDao;
Expand Down
Loading

0 comments on commit 42acda8

Please sign in to comment.