mirror of
https://gitee.com/devlive-community/datacap.git
synced 2024-12-01 19:48:14 +08:00
feat(plugin): fix generics warnings
This commit is contained in:
parent
2ef0f46876
commit
c99ac561ee
@ -1,5 +1,8 @@
|
||||
package io.edurt.datacap.common.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum ServiceState
|
||||
{
|
||||
SOURCE_NOT_FOUND(1001, "Source does not exist"),
|
||||
@ -25,24 +28,15 @@ public enum ServiceState
|
||||
USER_PASSWORD_INCORRECT(4006, "The user password is incorrect"),
|
||||
USER_PASSWORD_DIFFERENT(4007, "Two passwords are different"),
|
||||
USER_NAME_EQUALS(4008, "Cannot be the same as the old user name"),
|
||||
REQUEST_EXCEPTION(5000, "The request is abnormal");
|
||||
REQUEST_EXCEPTION(5000, "The request is abnormal"),
|
||||
INVALID_PARAMETER(5001, "Invalid parameter");
|
||||
|
||||
private Integer code;
|
||||
private String value;
|
||||
private final Integer code;
|
||||
private final String value;
|
||||
|
||||
ServiceState(Integer code, String value)
|
||||
{
|
||||
this.code = code;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Integer getCode()
|
||||
{
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getValue()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
@ -27,9 +27,9 @@ public class CommonResponse<T>
|
||||
@JsonView(value = {EntityView.AdminView.class, EntityView.UserView.class})
|
||||
private T data;
|
||||
|
||||
public static CommonResponse success(Object data)
|
||||
public static <T> CommonResponse<T> success(T data)
|
||||
{
|
||||
CommonResponse commonResponse = new CommonResponse();
|
||||
CommonResponse<T> commonResponse = new CommonResponse<>();
|
||||
commonResponse.code = State.SUCCESS.getCode();
|
||||
commonResponse.message = State.SUCCESS.getValue();
|
||||
commonResponse.data = data;
|
||||
@ -37,27 +37,27 @@ public class CommonResponse<T>
|
||||
return commonResponse;
|
||||
}
|
||||
|
||||
public static CommonResponse failure(String message)
|
||||
public static <T> CommonResponse<T> failure(String message)
|
||||
{
|
||||
CommonResponse commonResponse = new CommonResponse();
|
||||
CommonResponse<T> commonResponse = new CommonResponse<>();
|
||||
commonResponse.code = State.FAILURE.getCode();
|
||||
commonResponse.message = message;
|
||||
commonResponse.status = false;
|
||||
return commonResponse;
|
||||
}
|
||||
|
||||
public static CommonResponse failure(ServiceState state)
|
||||
public static <T> CommonResponse<T> failure(ServiceState state)
|
||||
{
|
||||
CommonResponse commonResponse = new CommonResponse();
|
||||
CommonResponse<T> commonResponse = new CommonResponse<>();
|
||||
commonResponse.code = state.getCode();
|
||||
commonResponse.message = state.getValue();
|
||||
commonResponse.status = false;
|
||||
return commonResponse;
|
||||
}
|
||||
|
||||
public static CommonResponse failure(ServiceState state, Object message)
|
||||
public static <T> CommonResponse<T> failure(ServiceState state, Object message)
|
||||
{
|
||||
CommonResponse commonResponse = new CommonResponse();
|
||||
CommonResponse<T> commonResponse = new CommonResponse<>();
|
||||
commonResponse.code = state.getCode();
|
||||
commonResponse.message = message;
|
||||
commonResponse.status = false;
|
||||
|
@ -6,8 +6,11 @@ import io.edurt.datacap.service.body.FilterBody;
|
||||
import io.edurt.datacap.service.body.adhoc.Adhoc;
|
||||
import io.edurt.datacap.service.entity.DataSetColumnEntity;
|
||||
import io.edurt.datacap.service.entity.DataSetEntity;
|
||||
import io.edurt.datacap.service.entity.DatasetHistoryEntity;
|
||||
import io.edurt.datacap.service.entity.PageEntity;
|
||||
import io.edurt.datacap.service.repository.DataSetRepository;
|
||||
import io.edurt.datacap.service.service.DataSetService;
|
||||
import io.edurt.datacap.spi.model.Response;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@ -17,6 +20,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@RestController()
|
||||
@ -47,7 +51,7 @@ public class DataSetController
|
||||
}
|
||||
|
||||
@GetMapping(value = "columns/{code}")
|
||||
public CommonResponse<Set<DataSetColumnEntity>> getColumnsByCode(@PathVariable String code)
|
||||
public CommonResponse<List<DataSetColumnEntity>> getColumnsByCode(@PathVariable String code)
|
||||
{
|
||||
return service.getColumnsByCode(code);
|
||||
}
|
||||
@ -65,14 +69,14 @@ public class DataSetController
|
||||
}
|
||||
|
||||
@PostMapping(value = "adhoc/{code}")
|
||||
public CommonResponse<Object> adhoc(@PathVariable String code,
|
||||
public CommonResponse<Response> adhoc(@PathVariable String code,
|
||||
@RequestBody Adhoc configure)
|
||||
{
|
||||
return service.adhoc(code, configure);
|
||||
}
|
||||
|
||||
@PostMapping(value = "history/{code}")
|
||||
public CommonResponse<Object> history(@PathVariable String code,
|
||||
public CommonResponse<PageEntity<DatasetHistoryEntity>> history(@PathVariable String code,
|
||||
@RequestBody FilterBody filter)
|
||||
{
|
||||
return this.service.getHistory(code, filter);
|
||||
|
@ -9,6 +9,8 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController()
|
||||
@RequestMapping(value = "/api/v1/database")
|
||||
public class DatabaseController
|
||||
@ -25,7 +27,7 @@ public class DatabaseController
|
||||
}
|
||||
|
||||
@PostMapping(value = "source/{code}")
|
||||
public CommonResponse<Object> fetchBySource(@PathVariable String code)
|
||||
public CommonResponse<List<DatabaseEntity>> fetchBySource(@PathVariable String code)
|
||||
{
|
||||
return this.service.getAllBySource(code);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import io.edurt.datacap.common.response.CommonResponse;
|
||||
import io.edurt.datacap.service.entity.PluginAuditEntity;
|
||||
import io.edurt.datacap.service.repository.PluginAuditRepository;
|
||||
import io.edurt.datacap.service.service.PluginAuditService;
|
||||
import io.edurt.datacap.spi.model.Response;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@ -25,7 +26,7 @@ public class PluginAuditController
|
||||
}
|
||||
|
||||
@GetMapping(value = "data/{code}")
|
||||
public CommonResponse<Object> getData(@PathVariable String code)
|
||||
public CommonResponse<Response> getData(@PathVariable String code)
|
||||
{
|
||||
return service.getData(code);
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import io.edurt.datacap.service.body.TableFilter;
|
||||
import io.edurt.datacap.service.entity.TableEntity;
|
||||
import io.edurt.datacap.service.repository.metadata.TableRepository;
|
||||
import io.edurt.datacap.service.service.TableService;
|
||||
import io.edurt.datacap.spi.model.Response;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@ -57,7 +58,7 @@ public class TableController
|
||||
}
|
||||
|
||||
@PostMapping(value = "createTable/{id}")
|
||||
public CommonResponse<Object> createTable(@PathVariable Long id, @RequestBody TableBody configure)
|
||||
public CommonResponse<Response> createTable(@PathVariable Long id, @RequestBody TableBody configure)
|
||||
{
|
||||
return this.service.createTable(id, configure);
|
||||
}
|
||||
|
@ -117,6 +117,16 @@
|
||||
<artifactId>datacap-fs-spi</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.edurt.datacap</groupId>
|
||||
<artifactId>datacap-scheduler-spi</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.edurt.datacap</groupId>
|
||||
<artifactId>datacap-executor-spi</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<!-- Sql Parser -->
|
||||
<dependency>
|
||||
<groupId>io.edurt.datacap</groupId>
|
||||
@ -130,25 +140,5 @@
|
||||
<version>${project.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- Scheduler -->
|
||||
<dependency>
|
||||
<groupId>io.edurt.datacap</groupId>
|
||||
<artifactId>datacap-scheduler-local</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- Executor -->
|
||||
<dependency>
|
||||
<groupId>io.edurt.datacap</groupId>
|
||||
<artifactId>datacap-executor-local</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.edurt.datacap</groupId>
|
||||
<artifactId>datacap-executor-seatunnel</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@ -22,9 +22,9 @@ public class PageEntity<T>
|
||||
{
|
||||
}
|
||||
|
||||
public static PageEntity build(Page page)
|
||||
public static <T> PageEntity<T> build(Page<T> page)
|
||||
{
|
||||
PageEntity pageEntity = new PageEntity<>();
|
||||
PageEntity<T> pageEntity = new PageEntity<>();
|
||||
pageEntity.setPage(page.getNumber() + 1);
|
||||
pageEntity.setSize(page.getSize());
|
||||
pageEntity.setTotal(page.getTotalElements());
|
||||
|
@ -6,6 +6,8 @@ import com.fasterxml.jackson.annotation.JsonIncludeProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import io.edurt.datacap.common.utils.JsonUtils;
|
||||
import io.edurt.datacap.plugin.Plugin;
|
||||
import io.edurt.datacap.plugin.PluginManager;
|
||||
import io.edurt.datacap.service.configure.IConfigure;
|
||||
import io.edurt.datacap.service.configure.IConfigureExecutor;
|
||||
import io.edurt.datacap.spi.model.Configure;
|
||||
@ -114,6 +116,9 @@ public class SourceEntity
|
||||
@Transient
|
||||
private List<IConfigureExecutor> pipelines;
|
||||
|
||||
@Transient
|
||||
private String home;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "user_id")
|
||||
@JsonIncludeProperties(value = {"id", "username"})
|
||||
@ -143,23 +148,32 @@ public class SourceEntity
|
||||
return configures;
|
||||
}
|
||||
|
||||
public Configure toConfigure(PluginManager pluginManager, Plugin plugin)
|
||||
{
|
||||
return toConfigure("JsonConvert", pluginManager, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the current object to a Configure object.
|
||||
*
|
||||
* @return The Configure object created from the current object.
|
||||
*/
|
||||
public Configure toConfigure()
|
||||
public Configure toConfigure(String format, PluginManager pluginManager, Plugin plugin)
|
||||
{
|
||||
Configure configure = new Configure();
|
||||
configure.setHost(this.getHost());
|
||||
configure.setPort(this.getPort());
|
||||
configure.setUsername(Optional.ofNullable(this.getUsername()));
|
||||
configure.setPassword(Optional.ofNullable(this.getPassword()));
|
||||
Optional<String> database = StringUtils.isNotEmpty(this.getDatabase()) ? Optional.ofNullable(this.getDatabase()) : Optional.empty();
|
||||
configure.setDatabase(database);
|
||||
configure.setSsl(Optional.ofNullable(this.getSsl()));
|
||||
configure.setEnv(Optional.ofNullable(this.getConfigures()));
|
||||
configure.setFormat("JsonConvert");
|
||||
return configure;
|
||||
return Configure.builder()
|
||||
.host(this.getHost())
|
||||
.port(this.getPort())
|
||||
.username(Optional.ofNullable(this.getUsername()))
|
||||
.password(Optional.ofNullable(this.getPassword()))
|
||||
.database(StringUtils.isNotEmpty(this.getDatabase()) ? Optional.ofNullable(this.getDatabase()) : Optional.empty())
|
||||
.ssl(Optional.ofNullable(this.getSsl()))
|
||||
.env(Optional.ofNullable(this.getConfigures()))
|
||||
.format(format)
|
||||
.usedConfig(this.isUsedConfig())
|
||||
.pluginManager(pluginManager)
|
||||
.plugin(plugin)
|
||||
.id(String.valueOf(this.getId()))
|
||||
.home(this.getHome())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
@ -18,18 +18,20 @@ import org.springframework.data.domain.Pageable;
|
||||
|
||||
public interface BaseService<T extends BaseEntity>
|
||||
{
|
||||
default CommonResponse<PageEntity<T>> getAll(BaseRepository repository, FilterBody filter)
|
||||
default CommonResponse<PageEntity<T>> getAll(BaseRepository<T, Long> repository, FilterBody filter)
|
||||
{
|
||||
Pageable pageable = PageRequestAdapter.of(filter);
|
||||
return CommonResponse.success(PageEntity.build(repository.findAll(pageable)));
|
||||
}
|
||||
|
||||
default CommonResponse<T> getById(BaseRepository repository, Long id)
|
||||
default CommonResponse<T> getById(BaseRepository<T, Long> repository, Long id)
|
||||
{
|
||||
return CommonResponse.success(repository.findById(id));
|
||||
return repository.findById(id)
|
||||
.map(CommonResponse::success)
|
||||
.orElse(CommonResponse.failure(String.format("Resource [ %s ] not found", id)));
|
||||
}
|
||||
|
||||
default CommonResponse<T> saveOrUpdate(BaseRepository repository, T configure)
|
||||
default CommonResponse<T> saveOrUpdate(BaseRepository<T, Long> repository, T configure)
|
||||
{
|
||||
if (configure.getId() != null) {
|
||||
repository.findById(configure.getId())
|
||||
@ -44,25 +46,25 @@ public interface BaseService<T extends BaseEntity>
|
||||
return CommonResponse.success(repository.save(configure));
|
||||
}
|
||||
|
||||
default CommonResponse<Long> deleteById(BaseRepository repository, Long id)
|
||||
default CommonResponse<Long> deleteById(BaseRepository<T, Long> repository, Long id)
|
||||
{
|
||||
repository.deleteById(id);
|
||||
return CommonResponse.success(id);
|
||||
}
|
||||
|
||||
default CommonResponse<T> getByCode(BaseRepository repository, String code)
|
||||
default CommonResponse<T> getByCode(BaseRepository<T, Long> repository, String code)
|
||||
{
|
||||
return (CommonResponse<T>) repository.findByCode(code)
|
||||
.map(value -> validatorUser(value))
|
||||
return repository.findByCode(code)
|
||||
.map(this::validatorUser)
|
||||
.orElseGet(() -> CommonResponse.failure(String.format("Resource [ %s ] not found", code)));
|
||||
}
|
||||
|
||||
default CommonResponse<T> validatorUser(Object value)
|
||||
default <R> CommonResponse<R> validatorUser(R value)
|
||||
{
|
||||
if (ReflectionUtils.hasField(value, "user")) {
|
||||
UserEntity originalUser = (UserEntity) ReflectionUtils.getFieldValue(value, "user");
|
||||
UserEntity loginUser = UserDetailsService.getUser();
|
||||
if (!originalUser.getId().equals(loginUser.getId())) {
|
||||
if (originalUser != null && !originalUser.getId().equals(loginUser.getId())) {
|
||||
return CommonResponse.failure(ServiceState.USER_UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
@ -74,7 +76,7 @@ public interface BaseService<T extends BaseEntity>
|
||||
if (ReflectionUtils.hasField(value, "user")) {
|
||||
UserEntity originalUser = (UserEntity) ReflectionUtils.getFieldValue(value, "user");
|
||||
UserEntity loginUser = UserDetailsService.getUser();
|
||||
if (!originalUser.getId().equals(loginUser.getId())) {
|
||||
if (originalUser != null && !originalUser.getId().equals(loginUser.getId())) {
|
||||
throw new SelfException(String.format("Resource [ %s ] not found", value.getClass().getName()));
|
||||
}
|
||||
}
|
||||
|
@ -11,5 +11,5 @@ public interface DashboardService
|
||||
{
|
||||
CommonResponse<PageEntity<DashboardEntity>> getAll(FilterBody filter);
|
||||
|
||||
CommonResponse<DashboardEntity> saveOrUpdate(PagingAndSortingRepository repository, DashboardEntity configure);
|
||||
CommonResponse<DashboardEntity> saveOrUpdate(PagingAndSortingRepository<DashboardEntity, Long> repository, DashboardEntity configure);
|
||||
}
|
||||
|
@ -6,7 +6,11 @@ import io.edurt.datacap.service.body.FilterBody;
|
||||
import io.edurt.datacap.service.body.adhoc.Adhoc;
|
||||
import io.edurt.datacap.service.entity.DataSetColumnEntity;
|
||||
import io.edurt.datacap.service.entity.DataSetEntity;
|
||||
import io.edurt.datacap.service.entity.DatasetHistoryEntity;
|
||||
import io.edurt.datacap.service.entity.PageEntity;
|
||||
import io.edurt.datacap.spi.model.Response;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface DataSetService
|
||||
@ -16,17 +20,17 @@ public interface DataSetService
|
||||
|
||||
CommonResponse<DataSetEntity> rebuild(Long id);
|
||||
|
||||
CommonResponse<Set<DataSetColumnEntity>> getColumnsByCode(String code);
|
||||
CommonResponse<List<DataSetColumnEntity>> getColumnsByCode(String code);
|
||||
|
||||
CommonResponse<Boolean> syncData(Long id);
|
||||
|
||||
CommonResponse<Boolean> clearData(String code);
|
||||
|
||||
CommonResponse<Object> adhoc(String code, Adhoc configure);
|
||||
CommonResponse<Response> adhoc(String code, Adhoc configure);
|
||||
|
||||
CommonResponse<Set<PluginMetadata>> getActuators();
|
||||
|
||||
CommonResponse<DataSetEntity> getInfo(String code);
|
||||
|
||||
CommonResponse<Object> getHistory(String code, FilterBody filter);
|
||||
CommonResponse<PageEntity<DatasetHistoryEntity>> getHistory(String code, FilterBody filter);
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ package io.edurt.datacap.service.service;
|
||||
import io.edurt.datacap.common.response.CommonResponse;
|
||||
import io.edurt.datacap.service.entity.DatabaseEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface DatabaseService
|
||||
extends BaseService<DatabaseEntity>
|
||||
{
|
||||
@ -12,5 +14,5 @@ public interface DatabaseService
|
||||
* @param code the code used to filter the results
|
||||
* @return a list of DatabaseEntity objects that match the id
|
||||
*/
|
||||
CommonResponse<Object> getAllBySource(String code);
|
||||
CommonResponse<List<DatabaseEntity>> getAllBySource(String code);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import io.edurt.datacap.common.response.CommonResponse;
|
||||
import io.edurt.datacap.service.activity.HeatmapActivity;
|
||||
import io.edurt.datacap.service.entity.PluginAuditEntity;
|
||||
import io.edurt.datacap.service.itransient.ContributionRadar;
|
||||
import io.edurt.datacap.spi.model.Response;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -18,5 +19,5 @@ public interface PluginAuditService
|
||||
|
||||
CommonResponse<PluginAuditEntity> getById(Long id);
|
||||
|
||||
CommonResponse<Object> getData(String code);
|
||||
CommonResponse<Response> getData(String code);
|
||||
}
|
||||
|
@ -11,5 +11,5 @@ public interface ReportService
|
||||
{
|
||||
CommonResponse<PageEntity<ReportEntity>> getAll(FilterBody filter);
|
||||
|
||||
CommonResponse<ReportEntity> saveOrUpdate(PagingAndSortingRepository repository, ReportEntity configure);
|
||||
CommonResponse<ReportEntity> saveOrUpdate(PagingAndSortingRepository<ReportEntity, Long> repository, ReportEntity configure);
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import io.edurt.datacap.service.body.ExportBody;
|
||||
import io.edurt.datacap.service.body.TableBody;
|
||||
import io.edurt.datacap.service.body.TableFilter;
|
||||
import io.edurt.datacap.service.entity.TableEntity;
|
||||
import io.edurt.datacap.spi.model.Response;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -39,7 +40,7 @@ public interface TableService
|
||||
|
||||
Object dataDownload(String username, String filename);
|
||||
|
||||
CommonResponse<Object> createTable(Long databaseId, TableBody configure);
|
||||
CommonResponse<Response> createTable(Long databaseId, TableBody configure);
|
||||
|
||||
CommonResponse<Object> manageColumn(String code, TableBody configure);
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public class ChatServiceImpl
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResponse<ChatEntity> saveOrUpdate(BaseRepository repository, ChatEntity configure)
|
||||
public CommonResponse<ChatEntity> saveOrUpdate(BaseRepository<ChatEntity, Long> repository, ChatEntity configure)
|
||||
{
|
||||
configure.setUser(UserDetailsService.getUser());
|
||||
return CommonResponse.success(repository.save(configure));
|
||||
|
@ -31,7 +31,7 @@ public class DashboardServiceImpl
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResponse<DashboardEntity> saveOrUpdate(PagingAndSortingRepository repository, DashboardEntity configure)
|
||||
public CommonResponse<DashboardEntity> saveOrUpdate(PagingAndSortingRepository<DashboardEntity, Long> repository, DashboardEntity configure)
|
||||
{
|
||||
configure.setUser(UserDetailsService.getUser());
|
||||
return CommonResponse.success(repository.save(configure));
|
||||
|
@ -124,20 +124,20 @@ public class DataSetServiceImpl
|
||||
@Override
|
||||
public CommonResponse<DataSetEntity> rebuild(Long id)
|
||||
{
|
||||
Optional<DataSetEntity> entity = repository.findById(id);
|
||||
if (!entity.isPresent()) {
|
||||
return CommonResponse.failure(String.format("DataSet [ %s ] not found", id));
|
||||
}
|
||||
java.util.concurrent.ExecutorService service = Executors.newSingleThreadExecutor();
|
||||
service.submit(() -> startBuild(entity.get(), false));
|
||||
return CommonResponse.success(entity);
|
||||
return repository.findById(id)
|
||||
.map(entity -> {
|
||||
java.util.concurrent.ExecutorService service = Executors.newSingleThreadExecutor();
|
||||
service.submit(() -> startBuild(entity, false));
|
||||
return CommonResponse.success(entity);
|
||||
})
|
||||
.orElse(CommonResponse.failure(String.format("DataSet [ %s ] not found", id)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResponse<Set<DataSetColumnEntity>> getColumnsByCode(String code)
|
||||
public CommonResponse<List<DataSetColumnEntity>> getColumnsByCode(String code)
|
||||
{
|
||||
Optional<DataSetEntity> entity = repository.findByCode(code);
|
||||
return entity.map(item -> {
|
||||
return repository.findByCode(code)
|
||||
.map(item -> {
|
||||
isSelf(item);
|
||||
return CommonResponse.success(columnRepository.findAllByDatasetOrderByPositionAsc(item));
|
||||
})
|
||||
@ -170,7 +170,7 @@ public class DataSetServiceImpl
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResponse<Object> adhoc(String code, Adhoc configure)
|
||||
public CommonResponse<Response> adhoc(String code, Adhoc configure)
|
||||
{
|
||||
return repository.findByCode(code)
|
||||
.map(item -> {
|
||||
@ -244,16 +244,14 @@ public class DataSetServiceImpl
|
||||
return pluginManager.getPlugin(initializerConfigure.getDataSetConfigure().getType())
|
||||
.map(plugin -> {
|
||||
PluginService pluginService = plugin.getService(PluginService.class);
|
||||
Configure targetConfigure = new Configure();
|
||||
targetConfigure.setHost(initializerConfigure.getDataSetConfigure().getHost());
|
||||
targetConfigure.setPort(Integer.valueOf(initializerConfigure.getDataSetConfigure().getPort()));
|
||||
targetConfigure.setUsername(Optional.ofNullable(initializerConfigure.getDataSetConfigure().getUsername()));
|
||||
targetConfigure.setPassword(Optional.ofNullable(initializerConfigure.getDataSetConfigure().getPassword()));
|
||||
targetConfigure.setDatabase(Optional.ofNullable(database));
|
||||
targetConfigure.setPluginManager(pluginManager);
|
||||
targetConfigure.setClassLoader(plugin.getClassLoader());
|
||||
targetConfigure.setPlugin(plugin);
|
||||
Response response = pluginService.execute(targetConfigure, sql);
|
||||
SourceEntity entity = SourceEntity.builder()
|
||||
.host(initializerConfigure.getDataSetConfigure().getHost())
|
||||
.port(Integer.valueOf(initializerConfigure.getDataSetConfigure().getPort()))
|
||||
.username(initializerConfigure.getDataSetConfigure().getUsername())
|
||||
.password(initializerConfigure.getDataSetConfigure().getPassword())
|
||||
.database(database)
|
||||
.build();
|
||||
Response response = pluginService.execute(entity.toConfigure(pluginManager, plugin), sql);
|
||||
response.setContent(sql);
|
||||
return CommonResponse.success(response);
|
||||
})
|
||||
@ -282,18 +280,18 @@ public class DataSetServiceImpl
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResponse<Object> getHistory(String code, FilterBody filter)
|
||||
public CommonResponse<PageEntity<DatasetHistoryEntity>> getHistory(String code, FilterBody filter)
|
||||
{
|
||||
return repository.findByCode(code)
|
||||
.map(item -> {
|
||||
Pageable pageable = PageRequestAdapter.of(filter);
|
||||
return CommonResponse.success(PageEntity.build(historyRepository.findAllByDatasetOrderByCreateTimeDesc(item, pageable)));
|
||||
})
|
||||
.orElseGet(() -> CommonResponse.failure(String.format("DataSet [ %s ] not found", code)));
|
||||
.orElse(CommonResponse.failure(String.format("DataSet [ %s ] not found", code)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResponse<PageEntity<DataSetEntity>> getAll(BaseRepository pagingAndSortingRepository, FilterBody filter)
|
||||
public CommonResponse<PageEntity<DataSetEntity>> getAll(BaseRepository<DataSetEntity, Long> pagingAndSortingRepository, FilterBody filter)
|
||||
{
|
||||
Pageable pageable = PageRequestAdapter.of(filter);
|
||||
return CommonResponse.success(PageEntity.build(repository.findAllByUser(UserDetailsService.getUser(), pageable)));
|
||||
@ -492,7 +490,7 @@ public class DataSetServiceImpl
|
||||
String sql = ColumnBuilder.Companion.SQL();
|
||||
PluginService plugin = getOutputPlugin();
|
||||
SourceEntity source = getOutputSource();
|
||||
plugin.connect(source.toConfigure());
|
||||
// plugin.connect(source.toConfigure());
|
||||
Response response = plugin.execute(sql);
|
||||
Preconditions.checkArgument(response.getIsSuccessful(), response.getMessage());
|
||||
log.info("Create column sql \n {} \n on dataset [ {} ] id [ {} ]", sql, entity.getName(), entity.getId());
|
||||
@ -511,7 +509,7 @@ public class DataSetServiceImpl
|
||||
log.info("Modify column sql \n {} \n on dataset [ {} ] id [ {} ]", sql, entity.getName(), entity.getId());
|
||||
PluginService plugin = getOutputPlugin();
|
||||
SourceEntity source = getOutputSource();
|
||||
plugin.connect(source.toConfigure());
|
||||
// plugin.connect(source.toConfigure());
|
||||
Response response = plugin.execute(sql);
|
||||
Preconditions.checkArgument(response.getIsSuccessful(), response.getMessage());
|
||||
}
|
||||
@ -527,8 +525,8 @@ public class DataSetServiceImpl
|
||||
log.info("Modify lifecycle sql \n {} \n on dataset [ {} ] id [ {} ]", sql, entity.getName(), entity.getId());
|
||||
PluginService pluginService = getOutputPlugin();
|
||||
SourceEntity source = getOutputSource();
|
||||
Response response = pluginService.execute(source.toConfigure(), sql);
|
||||
Preconditions.checkArgument(response.getIsSuccessful(), response.getMessage());
|
||||
// Response response = pluginService.execute(source.toConfigure(), sql);
|
||||
// Preconditions.checkArgument(response.getIsSuccessful(), response.getMessage());
|
||||
});
|
||||
|
||||
completeState(entity, DataSetState.TABLE_SUCCESS);
|
||||
@ -585,7 +583,8 @@ public class DataSetServiceImpl
|
||||
Properties inputProperties = ConfigureUtils.convertProperties(source, environment,
|
||||
IConfigurePipelineType.INPUT, entity.getExecutor(), entity.getQuery(), inputFieldBody);
|
||||
Set<String> inputOptions = ConfigureUtils.convertOptions(source, environment, entity.getExecutor(), IConfigurePipelineType.INPUT);
|
||||
Configure inputConfigure = source.toConfigure();
|
||||
// Configure inputConfigure = source.toConfigure();
|
||||
Configure inputConfigure = new Configure();
|
||||
inputConfigure.setPluginManager(pluginManager);
|
||||
ExecutorConfigure input = new ExecutorConfigure(source.getType(), inputProperties, inputOptions, RunProtocol.valueOf(source.getProtocol()),
|
||||
inputPlugin, entity.getQuery(), database, entity.getTableName(), inputConfigure, originColumns);
|
||||
@ -620,10 +619,10 @@ public class DataSetServiceImpl
|
||||
ExecutorRequest request = new ExecutorRequest(taskName, entity.getUser().getUsername(), input, output,
|
||||
environment.getProperty(String.format("datacap.executor.%s.home", entity.getExecutor().toLowerCase())),
|
||||
workHome, this.pluginManager, 600,
|
||||
RunWay.valueOf(environment.getProperty("datacap.executor.way")),
|
||||
RunMode.valueOf(environment.getProperty("datacap.executor.mode")),
|
||||
RunWay.valueOf(requireNonNull(environment.getProperty("datacap.executor.way"))),
|
||||
RunMode.valueOf(requireNonNull(environment.getProperty("datacap.executor.mode"))),
|
||||
environment.getProperty("datacap.executor.startScript"),
|
||||
RunEngine.valueOf(environment.getProperty("datacap.executor.engine")));
|
||||
RunEngine.valueOf(requireNonNull(environment.getProperty("datacap.executor.engine"))));
|
||||
|
||||
history.setState(RunState.RUNNING);
|
||||
historyRepository.save(history);
|
||||
@ -702,14 +701,15 @@ public class DataSetServiceImpl
|
||||
try {
|
||||
pluginManager.getPlugin(initializerConfigure.getDataSetConfigure().getType())
|
||||
.ifPresent(plugin -> {
|
||||
SourceEntity source = new SourceEntity();
|
||||
source.setType(initializerConfigure.getDataSetConfigure().getType());
|
||||
source.setDatabase(initializerConfigure.getDataSetConfigure().getDatabase());
|
||||
source.setHost(initializerConfigure.getDataSetConfigure().getHost());
|
||||
source.setPort(Integer.valueOf(initializerConfigure.getDataSetConfigure().getPort()));
|
||||
source.setUsername(initializerConfigure.getDataSetConfigure().getUsername());
|
||||
source.setPassword(initializerConfigure.getDataSetConfigure().getPassword());
|
||||
source.setProtocol(PluginType.JDBC.name());
|
||||
SourceEntity source = SourceEntity.builder()
|
||||
.type(initializerConfigure.getDataSetConfigure().getType())
|
||||
.host(initializerConfigure.getDataSetConfigure().getHost())
|
||||
.port(Integer.valueOf(initializerConfigure.getDataSetConfigure().getPort()))
|
||||
.database(initializerConfigure.getDataSetConfigure().getDatabase())
|
||||
.username(initializerConfigure.getDataSetConfigure().getUsername())
|
||||
.password(initializerConfigure.getDataSetConfigure().getPassword())
|
||||
.protocol(PluginType.JDBC.name())
|
||||
.build();
|
||||
|
||||
PluginService pluginService = plugin.getService(PluginService.class);
|
||||
SqlBody body = SqlBody.builder()
|
||||
@ -719,9 +719,9 @@ public class DataSetServiceImpl
|
||||
.build();
|
||||
String sql = new SqlBuilder(body).getSql();
|
||||
log.info("Clear data for dataset [ {} ] id [ {} ] sql \n {}", entity.getName(), entity.getId(), sql);
|
||||
Response response = pluginService.execute(source.toConfigure(), sql);
|
||||
Response response = pluginService.execute(source.toConfigure(pluginManager, plugin), sql);
|
||||
Preconditions.checkArgument(response.getIsSuccessful(), response.getMessage());
|
||||
this.flushTableMetadata(entity, pluginService, initializerConfigure.getDataSetConfigure().getDatabase(), source.toConfigure());
|
||||
// this.flushTableMetadata(entity, pluginService, initializerConfigure.getDataSetConfigure().getDatabase(), source.toConfigure());
|
||||
});
|
||||
}
|
||||
catch (Exception e) {
|
||||
@ -844,7 +844,7 @@ public class DataSetServiceImpl
|
||||
try {
|
||||
PluginService pluginService = plugin.getService(PluginService.class);
|
||||
SourceEntity source = getOutputSource();
|
||||
Configure configure = source.toConfigure();
|
||||
Configure configure = source.toConfigure(pluginManager, plugin);
|
||||
configure.setPluginManager(pluginManager);
|
||||
String sql = String.format("SHOW CREATE TABLE `%s`.`%s`", initializerConfigure.getDataSetConfigure().getDatabase(), entity.getTableName());
|
||||
log.info("Check table exists for dataset [ {} ] id [ {} ] sql \n {}", entity.getName(), entity.getId(), sql);
|
||||
@ -867,15 +867,15 @@ public class DataSetServiceImpl
|
||||
*/
|
||||
private SourceEntity getOutputSource()
|
||||
{
|
||||
SourceEntity source = new SourceEntity();
|
||||
source.setType(initializerConfigure.getDataSetConfigure().getType());
|
||||
source.setDatabase(initializerConfigure.getDataSetConfigure().getDatabase());
|
||||
source.setHost(initializerConfigure.getDataSetConfigure().getHost());
|
||||
source.setPort(Integer.valueOf(initializerConfigure.getDataSetConfigure().getPort()));
|
||||
source.setUsername(initializerConfigure.getDataSetConfigure().getUsername());
|
||||
source.setPassword(initializerConfigure.getDataSetConfigure().getPassword());
|
||||
source.setProtocol(PluginType.JDBC.name());
|
||||
return source;
|
||||
return SourceEntity.builder()
|
||||
.type(initializerConfigure.getDataSetConfigure().getType())
|
||||
.database(initializerConfigure.getDataSetConfigure().getDatabase())
|
||||
.host(initializerConfigure.getDataSetConfigure().getHost())
|
||||
.port(Integer.valueOf(initializerConfigure.getDataSetConfigure().getPort()))
|
||||
.username(initializerConfigure.getDataSetConfigure().getUsername())
|
||||
.password(initializerConfigure.getDataSetConfigure().getPassword())
|
||||
.protocol(PluginType.JDBC.name())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,11 +1,14 @@
|
||||
package io.edurt.datacap.service.service.impl;
|
||||
|
||||
import io.edurt.datacap.common.response.CommonResponse;
|
||||
import io.edurt.datacap.service.entity.DatabaseEntity;
|
||||
import io.edurt.datacap.service.repository.SourceRepository;
|
||||
import io.edurt.datacap.service.repository.metadata.DatabaseRepository;
|
||||
import io.edurt.datacap.service.service.DatabaseService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class DatabaseServiceImpl
|
||||
implements DatabaseService
|
||||
@ -20,7 +23,7 @@ public class DatabaseServiceImpl
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResponse<Object> getAllBySource(String code)
|
||||
public CommonResponse<List<DatabaseEntity>> getAllBySource(String code)
|
||||
{
|
||||
return sourceRepository.findByCode(code)
|
||||
.map(value -> CommonResponse.success(this.repository.findAllBySource(value)))
|
||||
|
@ -5,21 +5,22 @@ import io.edurt.datacap.common.response.CommonResponse;
|
||||
import io.edurt.datacap.common.sql.SqlBuilder;
|
||||
import io.edurt.datacap.common.sql.configure.SqlBody;
|
||||
import io.edurt.datacap.common.sql.configure.SqlType;
|
||||
import io.edurt.datacap.plugin.Plugin;
|
||||
import io.edurt.datacap.plugin.PluginManager;
|
||||
import io.edurt.datacap.service.audit.AuditPlugin;
|
||||
import io.edurt.datacap.service.body.ExecuteDslBody;
|
||||
import io.edurt.datacap.service.entity.ExecuteEntity;
|
||||
import io.edurt.datacap.service.entity.SourceEntity;
|
||||
import io.edurt.datacap.service.repository.SourceRepository;
|
||||
import io.edurt.datacap.service.service.ExecuteService;
|
||||
import io.edurt.datacap.spi.PluginService;
|
||||
import io.edurt.datacap.spi.model.Configure;
|
||||
import io.edurt.datacap.spi.model.Response;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Optional;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@ -41,64 +42,110 @@ public class ExecuteServiceImpl
|
||||
@Override
|
||||
public CommonResponse<Object> execute(ExecuteEntity configure)
|
||||
{
|
||||
return this.sourceRepository.findById(Long.valueOf(configure.getName()))
|
||||
.map(entity -> {
|
||||
return pluginManager.getPlugin(entity.getType())
|
||||
.map(plugin -> {
|
||||
PluginService service = plugin.getService(PluginService.class);
|
||||
Configure _configure = Configure.builder()
|
||||
.host(entity.getHost())
|
||||
.port(entity.getPort())
|
||||
.username(Optional.ofNullable(entity.getUsername()))
|
||||
.password(Optional.ofNullable(entity.getPassword()))
|
||||
.database(StringUtils.isNotEmpty(entity.getDatabase()) ? Optional.ofNullable(entity.getDatabase()) : Optional.empty())
|
||||
.ssl(Optional.ofNullable(entity.getSsl()))
|
||||
.env(Optional.ofNullable(entity.getConfigures()))
|
||||
.format(configure.getFormat())
|
||||
.usedConfig(entity.isUsedConfig())
|
||||
.pluginManager(pluginManager)
|
||||
.classLoader(plugin.getClassLoader())
|
||||
.build();
|
||||
if (entity.isUsedConfig()) {
|
||||
_configure.setUsername(Optional.of(entity.getUser().getUsername()));
|
||||
String configHome = environment.getProperty("datacap.config.data");
|
||||
if (StringUtils.isEmpty(configHome)) {
|
||||
configHome = String.join(File.separator, System.getProperty("user.dir"), "config");
|
||||
}
|
||||
_configure.setHome(configHome);
|
||||
_configure.setId(String.valueOf(entity.getId()));
|
||||
}
|
||||
// if (configure.getMode().equals(QueryMode.ADHOC)) {
|
||||
// try {
|
||||
// if (initializerConfigure.getAutoLimit()) {
|
||||
// Optional<SqlParser> parserOptional = this.injector.getInstance(Key.get(new TypeLiteral<Set<SqlParser>>() {}))
|
||||
// .stream()
|
||||
// .filter(parser -> parser.name().equalsIgnoreCase(plugin.name()))
|
||||
// .findFirst();
|
||||
// ParserResponse response = parserOptional.orElse(injector.getInstance(Key.get(new TypeLiteral<Set<SqlParser>>() {}))
|
||||
// .stream()
|
||||
// .filter(parser -> parser.name().equalsIgnoreCase(initializerConfigure.getSqlParserDefaultEngine())).findFirst().get())
|
||||
// .parse(configure.getContent());
|
||||
//
|
||||
// if (response.isParser() && response.getType().equals(StatementType.SELECT) && response.getTable().getLimit() == null) {
|
||||
// configure.setContent(String.format("%s%nLIMIT %s", configure.getContent(), configure.getLimit()));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// catch (Exception exception) {
|
||||
// log.warn("Ignore auto limit", exception);
|
||||
// }
|
||||
// }
|
||||
io.edurt.datacap.spi.model.Response response = service.execute(_configure, configure.getContent());
|
||||
response.setContent(configure.getContent());
|
||||
if (response.getIsSuccessful()) {
|
||||
return CommonResponse.success(response);
|
||||
}
|
||||
return CommonResponse.failure(ServiceState.PLUGIN_EXECUTE_FAILED, response.getMessage());
|
||||
})
|
||||
.orElseGet(() -> CommonResponse.failure(ServiceState.PLUGIN_NOT_FOUND));
|
||||
})
|
||||
.orElse(CommonResponse.failure(ServiceState.SOURCE_NOT_FOUND));
|
||||
try {
|
||||
return sourceRepository.findById(Long.valueOf(configure.getName()))
|
||||
.map(entity -> handleSourceEntity(entity, configure.getContent()))
|
||||
.orElse(CommonResponse.failure(ServiceState.SOURCE_NOT_FOUND));
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
log.error("Invalid source id: {}", configure.getName(), e);
|
||||
return CommonResponse.failure(ServiceState.INVALID_PARAMETER, "Invalid source id");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理源实体
|
||||
* Handle source entity
|
||||
*
|
||||
* @param entity {@link SourceEntity} 源实体配置 / Source entity configuration
|
||||
* @param content SQL语句 / SQL statement
|
||||
* @return 插件执行结果 / Plugin execution result
|
||||
*/
|
||||
private CommonResponse<Object> handleSourceEntity(SourceEntity entity, String content)
|
||||
{
|
||||
return pluginManager.getPlugin(entity.getType())
|
||||
.map(plugin -> executeWithPlugin(entity, plugin, content))
|
||||
.orElse(CommonResponse.failure(ServiceState.PLUGIN_NOT_FOUND));
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行插件并获取响应
|
||||
* Execute the plugin and get the RESPONSE
|
||||
*
|
||||
* @param entity {@link SourceEntity} 源实体配置 / Source entity configuration
|
||||
* @param plugin {@link Plugin} 目标插件 / Target plugin
|
||||
* @param content SQL语句 / SQL statement
|
||||
* @return 插件执行结果 / Plugin execution result
|
||||
*/
|
||||
private CommonResponse<Object> executeWithPlugin(SourceEntity entity, Plugin plugin, String content)
|
||||
{
|
||||
try {
|
||||
PluginService service = plugin.getService(PluginService.class);
|
||||
configureEntity(entity);
|
||||
|
||||
// 执行插件并获取响应
|
||||
// Execute the plugin and get the response
|
||||
Response response = executePlugin(service, entity, plugin, content);
|
||||
|
||||
if (response.getIsSuccessful()) {
|
||||
return CommonResponse.success(response);
|
||||
}
|
||||
return CommonResponse.failure(ServiceState.PLUGIN_EXECUTE_FAILED, response.getMessage());
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("Failed to execute plugin for entity: {}", entity.getId(), e);
|
||||
return CommonResponse.failure(ServiceState.PLUGIN_EXECUTE_FAILED, "Plugin execution failed: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置用户自定义配置
|
||||
* Set user-defined configuration
|
||||
*
|
||||
* @param entity {@link SourceEntity} 源实体配置 / Source entity configuration
|
||||
*/
|
||||
private void configureEntity(SourceEntity entity)
|
||||
{
|
||||
if (entity.isUsedConfig()) {
|
||||
entity.setUsername(entity.getUser().getUsername());
|
||||
String configHome = getConfigHome();
|
||||
entity.setHome(configHome);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取配置目录
|
||||
* Get configuration directory
|
||||
*
|
||||
* @return 配置目录 / Configuration directory
|
||||
*/
|
||||
private String getConfigHome()
|
||||
{
|
||||
String configHome = environment.getProperty("datacap.config.data");
|
||||
if (StringUtils.isEmpty(configHome)) {
|
||||
configHome = String.join(File.separator, System.getProperty("user.dir"), "config");
|
||||
}
|
||||
return configHome;
|
||||
}
|
||||
|
||||
/**
|
||||
* 向插件发布任务并执行操作
|
||||
* Publish task to plugin and execute operation
|
||||
*
|
||||
* @param service {@link PluginService} 插件服务实例 / Plugin service instance
|
||||
* @param entity {@link SourceEntity} 源实体配置 / Source entity configuration
|
||||
* @param plugin {@link Plugin} 目标插件 / Target plugin
|
||||
* @param content {@link String} 执行内容 / Execution content
|
||||
* @return {@link Response} 插件执行结果 / Plugin execution result
|
||||
*/
|
||||
private Response executePlugin(PluginService service, SourceEntity entity, Plugin plugin, String content)
|
||||
{
|
||||
Response response = service.execute(
|
||||
entity.toConfigure(pluginManager, plugin),
|
||||
content
|
||||
);
|
||||
response.setContent(content);
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -42,7 +42,9 @@ public class FunctionServiceImpl
|
||||
@Override
|
||||
public CommonResponse<FunctionEntity> getById(Long id)
|
||||
{
|
||||
return CommonResponse.success(this.functionsRepository.findById(id));
|
||||
return this.functionsRepository.findById(id)
|
||||
.map(CommonResponse::success)
|
||||
.orElse(CommonResponse.failure(String.format("Function [ %s ] not found", id)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -95,11 +95,13 @@ public class PluginAuditServiceImpl
|
||||
@Override
|
||||
public CommonResponse<PluginAuditEntity> getById(Long id)
|
||||
{
|
||||
return CommonResponse.success(this.pluginAuditRepository.findById(id));
|
||||
return pluginAuditRepository.findById(id)
|
||||
.map(CommonResponse::success)
|
||||
.orElse(CommonResponse.failure(String.format("PluginAudit [ %s ] not found", id)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResponse<Object> getData(String code)
|
||||
public CommonResponse<Response> getData(String code)
|
||||
{
|
||||
return this.pluginAuditRepository.findByCode(code)
|
||||
.map(value -> {
|
||||
|
@ -31,7 +31,7 @@ public class ReportServiceImpl
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResponse<ReportEntity> saveOrUpdate(PagingAndSortingRepository repository, ReportEntity configure)
|
||||
public CommonResponse<ReportEntity> saveOrUpdate(PagingAndSortingRepository<ReportEntity, Long> repository, ReportEntity configure)
|
||||
{
|
||||
configure.setUser(UserDetailsService.getUser());
|
||||
return CommonResponse.success(repository.save(configure));
|
||||
|
@ -148,27 +148,28 @@ public class SourceServiceImpl
|
||||
@Override
|
||||
public CommonResponse<Object> testConnection(SourceEntity configure)
|
||||
{
|
||||
return pluginManager.getPlugin(configure.getType())
|
||||
.map(plugin -> {
|
||||
Configure _configure = new Configure();
|
||||
PluginService pluginService = plugin.getService(PluginService.class);
|
||||
_configure.setHost(configure.getHost());
|
||||
_configure.setPort(configure.getPort());
|
||||
_configure.setUsername(Optional.ofNullable(configure.getUsername()));
|
||||
_configure.setPassword(Optional.ofNullable(configure.getPassword()));
|
||||
Optional<String> _database = StringUtils.isNotEmpty(configure.getDatabase()) ? Optional.ofNullable(configure.getDatabase()) : Optional.empty();
|
||||
_configure.setDatabase(_database);
|
||||
_configure.setEnv(Optional.ofNullable(configure.getConfigures()));
|
||||
_configure.setSsl(Optional.ofNullable(configure.getSsl()));
|
||||
pluginService.connect(_configure);
|
||||
io.edurt.datacap.spi.model.Response response = pluginService.execute(pluginService.validator());
|
||||
pluginService.destroy();
|
||||
if (response.getIsSuccessful()) {
|
||||
return CommonResponse.success(response);
|
||||
}
|
||||
return CommonResponse.failure(ServiceState.PLUGIN_EXECUTE_FAILED, response.getMessage());
|
||||
})
|
||||
.orElseGet(() -> CommonResponse.failure(ServiceState.PLUGIN_NOT_FOUND));
|
||||
// return pluginManager.getPlugin(configure.getType())
|
||||
// .map(plugin -> {
|
||||
// Configure _configure = new Configure();
|
||||
// PluginService pluginService = plugin.getService(PluginService.class);
|
||||
// _configure.setHost(configure.getHost());
|
||||
// _configure.setPort(configure.getPort());
|
||||
// _configure.setUsername(Optional.ofNullable(configure.getUsername()));
|
||||
// _configure.setPassword(Optional.ofNullable(configure.getPassword()));
|
||||
// Optional<String> _database = StringUtils.isNotEmpty(configure.getDatabase()) ? Optional.ofNullable(configure.getDatabase()) : Optional.empty();
|
||||
// _configure.setDatabase(_database);
|
||||
// _configure.setEnv(Optional.ofNullable(configure.getConfigures()));
|
||||
// _configure.setSsl(Optional.ofNullable(configure.getSsl()));
|
||||
// pluginService.connect(_configure);
|
||||
// io.edurt.datacap.spi.model.Response response = pluginService.execute(pluginService.validator());
|
||||
// pluginService.destroy();
|
||||
// if (response.getIsSuccessful()) {
|
||||
// return CommonResponse.success(response);
|
||||
// }
|
||||
// return CommonResponse.failure(ServiceState.PLUGIN_EXECUTE_FAILED, response.getMessage());
|
||||
// })
|
||||
// .orElse( CommonResponse.failure(ServiceState.PLUGIN_NOT_FOUND));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -246,120 +247,122 @@ public class SourceServiceImpl
|
||||
@Override
|
||||
public CommonResponse<Object> testConnectionV2(SourceBody configure)
|
||||
{
|
||||
return pluginManager.getPlugin(configure.getName())
|
||||
.map(plugin -> {
|
||||
// Check configure
|
||||
IConfigure iConfigure = PluginUtils.loadYamlConfigure(configure.getType(), configure.getName(), configure.getName(), environment);
|
||||
if (ObjectUtils.isEmpty(iConfigure) || iConfigure.getConfigures().size() != configure.getConfigure().getConfigures().size()) {
|
||||
return CommonResponse.failure(ServiceState.PLUGIN_CONFIGURE_MISMATCH);
|
||||
}
|
||||
|
||||
// Filter required
|
||||
List<IConfigureField> requiredMismatchConfigures = configure.getConfigure().getConfigures().stream().filter(v -> v.isRequired()).filter(v -> ObjectUtils.isEmpty(v.getValue())).collect(Collectors.toList());
|
||||
if (requiredMismatchConfigures.size() > 0) {
|
||||
return CommonResponse.failure(ServiceState.PLUGIN_CONFIGURE_REQUIRED, ConfigureUtils.preparedMessage(requiredMismatchConfigures));
|
||||
}
|
||||
|
||||
PluginService pluginService = plugin.getService(PluginService.class);
|
||||
// The filter parameter value is null data
|
||||
List<IConfigureField> applyConfigures = ConfigureUtils.filterNotEmpty(configure.getConfigure().getConfigures());
|
||||
Configure _configure = ConfigureUtils.preparedConfigure(applyConfigures);
|
||||
// Adapter file configure
|
||||
if (_configure.isUsedConfig()) {
|
||||
String cacheHome = environment.getProperty("datacap.cache.data");
|
||||
if (StringUtils.isEmpty(cacheHome)) {
|
||||
cacheHome = String.join(File.separator, System.getProperty("user.dir"), "cache");
|
||||
}
|
||||
_configure.setHome(cacheHome);
|
||||
_configure.setUsername(Optional.of(UserDetailsService.getUser().getUsername()));
|
||||
}
|
||||
_configure.setPluginManager(pluginManager);
|
||||
pluginService.connect(_configure);
|
||||
Response response = pluginService.execute(pluginService.validator());
|
||||
if (response.getIsSuccessful()) {
|
||||
pluginService.destroy();
|
||||
return CommonResponse.success(response);
|
||||
}
|
||||
return CommonResponse.failure(ServiceState.PLUGIN_EXECUTE_FAILED, response.getMessage());
|
||||
})
|
||||
.orElseGet(() -> CommonResponse.failure(ServiceState.PLUGIN_NOT_FOUND));
|
||||
// return pluginManager.getPlugin(configure.getName())
|
||||
// .map(plugin -> {
|
||||
// // Check configure
|
||||
// IConfigure iConfigure = PluginUtils.loadYamlConfigure(configure.getType(), configure.getName(), configure.getName(), environment);
|
||||
// if (ObjectUtils.isEmpty(iConfigure) || iConfigure.getConfigures().size() != configure.getConfigure().getConfigures().size()) {
|
||||
// return CommonResponse.failure(ServiceState.PLUGIN_CONFIGURE_MISMATCH);
|
||||
// }
|
||||
//
|
||||
// // Filter required
|
||||
// List<IConfigureField> requiredMismatchConfigures = configure.getConfigure().getConfigures().stream().filter(v -> v.isRequired()).filter(v -> ObjectUtils.isEmpty(v.getValue())).collect(Collectors.toList());
|
||||
// if (requiredMismatchConfigures.size() > 0) {
|
||||
// return CommonResponse.failure(ServiceState.PLUGIN_CONFIGURE_REQUIRED, ConfigureUtils.preparedMessage(requiredMismatchConfigures));
|
||||
// }
|
||||
//
|
||||
// PluginService pluginService = plugin.getService(PluginService.class);
|
||||
// // The filter parameter value is null data
|
||||
// List<IConfigureField> applyConfigures = ConfigureUtils.filterNotEmpty(configure.getConfigure().getConfigures());
|
||||
// Configure _configure = ConfigureUtils.preparedConfigure(applyConfigures);
|
||||
// // Adapter file configure
|
||||
// if (_configure.isUsedConfig()) {
|
||||
// String cacheHome = environment.getProperty("datacap.cache.data");
|
||||
// if (StringUtils.isEmpty(cacheHome)) {
|
||||
// cacheHome = String.join(File.separator, System.getProperty("user.dir"), "cache");
|
||||
// }
|
||||
// _configure.setHome(cacheHome);
|
||||
// _configure.setUsername(Optional.of(UserDetailsService.getUser().getUsername()));
|
||||
// }
|
||||
// _configure.setPluginManager(pluginManager);
|
||||
// pluginService.connect(_configure);
|
||||
// Response response = pluginService.execute(pluginService.validator());
|
||||
// if (response.getIsSuccessful()) {
|
||||
// pluginService.destroy();
|
||||
// return CommonResponse.success(response);
|
||||
// }
|
||||
// return CommonResponse.failure(ServiceState.PLUGIN_EXECUTE_FAILED, response.getMessage());
|
||||
// })
|
||||
// .orElseGet(() -> CommonResponse.failure(ServiceState.PLUGIN_NOT_FOUND));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResponse<SourceEntity> saveOrUpdateV2(SourceBody configure)
|
||||
{
|
||||
return pluginManager.getPlugin(configure.getName())
|
||||
.map(plugin -> {
|
||||
// Check configure
|
||||
IConfigure iConfigure = PluginUtils.loadYamlConfigure(configure.getType(), configure.getName(), configure.getName(), environment);
|
||||
if (ObjectUtils.isEmpty(iConfigure) || iConfigure.getConfigures().size() != configure.getConfigure().getConfigures().size()) {
|
||||
return CommonResponse.failure(ServiceState.PLUGIN_CONFIGURE_MISMATCH);
|
||||
}
|
||||
|
||||
// Filter required
|
||||
List<IConfigureField> requiredMismatchConfigures = configure.getConfigure()
|
||||
.getConfigures()
|
||||
.stream()
|
||||
.filter(IConfigureField::isRequired)
|
||||
.filter(v -> ObjectUtils.isEmpty(v.getValue()))
|
||||
.collect(Collectors.toList());
|
||||
if (!requiredMismatchConfigures.isEmpty()) {
|
||||
return CommonResponse.failure(ServiceState.PLUGIN_CONFIGURE_REQUIRED, ConfigureUtils.preparedMessage(requiredMismatchConfigures));
|
||||
}
|
||||
|
||||
// The filter parameter value is null data
|
||||
List<IConfigureField> applyConfigures = ConfigureUtils.filterNotEmpty(configure.getConfigure().getConfigures());
|
||||
SourceEntity source = ConfigureUtils.preparedSourceEntity(applyConfigures);
|
||||
source.setProtocol(configure.getType());
|
||||
source.setType(configure.getName());
|
||||
source.setUser(UserDetailsService.getUser());
|
||||
if (configure.getId() == null) {
|
||||
source.setCode(UUID.randomUUID().toString().replace("-", ""));
|
||||
}
|
||||
if (ObjectUtils.isNotEmpty(configure.getId()) && configure.getId() > 0) {
|
||||
source.setId(configure.getId());
|
||||
sourceRepository.findById(configure.getId())
|
||||
.ifPresent(item -> source.setCode(item.getCode()));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(configure.getVersion())) {
|
||||
source.setVersion(configure.getVersion());
|
||||
source.setAvailable(true);
|
||||
}
|
||||
else {
|
||||
source.setAvailable(false);
|
||||
}
|
||||
this.sourceRepository.save(source);
|
||||
// Copy file to local data
|
||||
if (source.isUsedConfig()) {
|
||||
String cacheHome = environment.getProperty("datacap.cache.data");
|
||||
if (StringUtils.isEmpty(cacheHome)) {
|
||||
cacheHome = String.join(File.separator, System.getProperty("user.dir"), "cache");
|
||||
}
|
||||
String configHome = environment.getProperty("datacap.config.data");
|
||||
if (StringUtils.isEmpty(configHome)) {
|
||||
configHome = String.join(File.separator, System.getProperty("user.dir"), "config");
|
||||
}
|
||||
File sourceFile = new File(String.join(File.separator, cacheHome, source.getUser().getUsername(), source.getType()));
|
||||
String destination = String.join(File.separator, configHome, source.getUser().getUsername(), source.getType(), String.valueOf(source.getId()));
|
||||
File directory = new File(destination);
|
||||
try {
|
||||
if (!directory.exists()) {
|
||||
directory.mkdirs();
|
||||
}
|
||||
for (File file : sourceFile.listFiles()) {
|
||||
Files.copy(file, new File(String.join(File.separator, destination, file.getName())));
|
||||
}
|
||||
FileUtils.deleteDirectory(sourceFile);
|
||||
}
|
||||
catch (Exception e) {
|
||||
return CommonResponse.failure("Copy failed: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
// Start sync metadata
|
||||
this.syncMetadata(source.getId());
|
||||
return CommonResponse.success(source);
|
||||
})
|
||||
.orElseGet(() -> CommonResponse.failure(ServiceState.PLUGIN_NOT_FOUND));
|
||||
// return pluginManager.getPlugin(configure.getName())
|
||||
// .map(plugin -> {
|
||||
// // Check configure
|
||||
// IConfigure iConfigure = PluginUtils.loadYamlConfigure(configure.getType(), configure.getName(), configure.getName(), environment);
|
||||
// if (ObjectUtils.isEmpty(iConfigure) || iConfigure.getConfigures().size() != configure.getConfigure().getConfigures().size()) {
|
||||
// return CommonResponse.failure(ServiceState.PLUGIN_CONFIGURE_MISMATCH);
|
||||
// }
|
||||
//
|
||||
// // Filter required
|
||||
// List<IConfigureField> requiredMismatchConfigures = configure.getConfigure()
|
||||
// .getConfigures()
|
||||
// .stream()
|
||||
// .filter(IConfigureField::isRequired)
|
||||
// .filter(v -> ObjectUtils.isEmpty(v.getValue()))
|
||||
// .collect(Collectors.toList());
|
||||
// if (!requiredMismatchConfigures.isEmpty()) {
|
||||
// return CommonResponse.failure(ServiceState.PLUGIN_CONFIGURE_REQUIRED, ConfigureUtils.preparedMessage(requiredMismatchConfigures));
|
||||
// }
|
||||
//
|
||||
// // The filter parameter value is null data
|
||||
// List<IConfigureField> applyConfigures = ConfigureUtils.filterNotEmpty(configure.getConfigure().getConfigures());
|
||||
// SourceEntity source = ConfigureUtils.preparedSourceEntity(applyConfigures);
|
||||
// source.setProtocol(configure.getType());
|
||||
// source.setType(configure.getName());
|
||||
// source.setUser(UserDetailsService.getUser());
|
||||
// if (configure.getId() == null) {
|
||||
// source.setCode(UUID.randomUUID().toString().replace("-", ""));
|
||||
// }
|
||||
// if (ObjectUtils.isNotEmpty(configure.getId()) && configure.getId() > 0) {
|
||||
// source.setId(configure.getId());
|
||||
// sourceRepository.findById(configure.getId())
|
||||
// .ifPresent(item -> source.setCode(item.getCode()));
|
||||
// }
|
||||
// if (StringUtils.isNotEmpty(configure.getVersion())) {
|
||||
// source.setVersion(configure.getVersion());
|
||||
// source.setAvailable(true);
|
||||
// }
|
||||
// else {
|
||||
// source.setAvailable(false);
|
||||
// }
|
||||
// this.sourceRepository.save(source);
|
||||
// // Copy file to local data
|
||||
// if (source.isUsedConfig()) {
|
||||
// String cacheHome = environment.getProperty("datacap.cache.data");
|
||||
// if (StringUtils.isEmpty(cacheHome)) {
|
||||
// cacheHome = String.join(File.separator, System.getProperty("user.dir"), "cache");
|
||||
// }
|
||||
// String configHome = environment.getProperty("datacap.config.data");
|
||||
// if (StringUtils.isEmpty(configHome)) {
|
||||
// configHome = String.join(File.separator, System.getProperty("user.dir"), "config");
|
||||
// }
|
||||
// File sourceFile = new File(String.join(File.separator, cacheHome, source.getUser().getUsername(), source.getType()));
|
||||
// String destination = String.join(File.separator, configHome, source.getUser().getUsername(), source.getType(), String.valueOf(source.getId()));
|
||||
// File directory = new File(destination);
|
||||
// try {
|
||||
// if (!directory.exists()) {
|
||||
// directory.mkdirs();
|
||||
// }
|
||||
// for (File file : sourceFile.listFiles()) {
|
||||
// Files.copy(file, new File(String.join(File.separator, destination, file.getName())));
|
||||
// }
|
||||
// FileUtils.deleteDirectory(sourceFile);
|
||||
// }
|
||||
// catch (Exception e) {
|
||||
// return CommonResponse.failure("Copy failed: " + e.getMessage());
|
||||
// }
|
||||
// }
|
||||
// // Start sync metadata
|
||||
// this.syncMetadata(source.getId());
|
||||
// return CommonResponse.success(source);
|
||||
// })
|
||||
// .orElseGet(() -> CommonResponse.failure(ServiceState.PLUGIN_NOT_FOUND));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -404,7 +407,7 @@ public class SourceServiceImpl
|
||||
.ifPresent(plugin -> {
|
||||
try {
|
||||
PluginService pluginService = plugin.getService(PluginService.class);
|
||||
Configure pConfigure = entity.toConfigure();
|
||||
Configure pConfigure = entity.toConfigure(pluginManager, plugin);
|
||||
pConfigure.setPluginManager(pluginManager);
|
||||
Response response = pluginService.execute(pConfigure, pluginService.validator());
|
||||
if (!response.getIsSuccessful()) {
|
||||
@ -533,9 +536,9 @@ public class SourceServiceImpl
|
||||
log.warn("The source [ {} ] protocol [ {} ] template [ {} ] is not available, skip sync database", entity.getName(), entity.getProtocol(), templateName);
|
||||
}
|
||||
else {
|
||||
Configure pConfigure = entity.toConfigure();
|
||||
pConfigure.setPluginManager(pluginManager);
|
||||
plugin.connect(pConfigure);
|
||||
// Configure pConfigure = entity.toConfigure();
|
||||
// pConfigure.setPluginManager(pluginManager);
|
||||
// plugin.connect(pConfigure);
|
||||
Response response = plugin.execute(getSqlContext(template, null));
|
||||
if (!response.getIsSuccessful()) {
|
||||
log.error("The source [ {} ] protocol [ {} ] sync metadata [ {} ] failed", entity.getName(), entity.getProtocol(), response.getMessage());
|
||||
@ -605,9 +608,9 @@ public class SourceServiceImpl
|
||||
log.warn("The source [ {} ] protocol [ {} ] template [ {} ] is not available, skip sync table", entity.getName(), entity.getProtocol(), templateName);
|
||||
}
|
||||
else {
|
||||
Configure pConfigure = entity.toConfigure();
|
||||
pConfigure.setPluginManager(pluginManager);
|
||||
plugin.connect(pConfigure);
|
||||
// Configure pConfigure = entity.toConfigure();
|
||||
// pConfigure.setPluginManager(pluginManager);
|
||||
// plugin.connect(pConfigure);
|
||||
Response response = plugin.execute(getSqlContext(template, null));
|
||||
if (!response.getIsSuccessful()) {
|
||||
log.error("The source [ {} ] protocol [ {} ] sync metadata tables [ {} ] failed", entity.getName(), entity.getProtocol(), response.getMessage());
|
||||
@ -698,9 +701,9 @@ public class SourceServiceImpl
|
||||
log.warn("The source [ {} ] protocol [ {} ] template [ {} ] is not available, skip sync column", entity.getName(), entity.getProtocol(), templateName);
|
||||
}
|
||||
else {
|
||||
Configure pConfigure = entity.toConfigure();
|
||||
pConfigure.setPluginManager(pluginManager);
|
||||
plugin.connect(pConfigure);
|
||||
// Configure pConfigure = entity.toConfigure();
|
||||
// pConfigure.setPluginManager(pluginManager);
|
||||
// plugin.connect(pConfigure);
|
||||
Response response = plugin.execute(getSqlContext(template, null));
|
||||
if (!response.getIsSuccessful()) {
|
||||
log.error("The source [ {} ] protocol [ {} ] sync metadata columns [ {} ] failed", entity.getName(), entity.getProtocol(), response.getMessage());
|
||||
|
@ -13,6 +13,7 @@ import io.edurt.datacap.common.utils.CSVUtils;
|
||||
import io.edurt.datacap.fs.FsRequest;
|
||||
import io.edurt.datacap.fs.FsResponse;
|
||||
import io.edurt.datacap.fs.FsService;
|
||||
import io.edurt.datacap.plugin.Plugin;
|
||||
import io.edurt.datacap.plugin.PluginManager;
|
||||
import io.edurt.datacap.service.body.ExportBody;
|
||||
import io.edurt.datacap.service.body.TableBody;
|
||||
@ -102,28 +103,28 @@ public class TableServiceImpl
|
||||
.map(plugin -> {
|
||||
PluginService pluginService = plugin.getService(PluginService.class);
|
||||
if (configure.getType().equals(SqlType.SELECT)) {
|
||||
return this.fetchSelect(pluginService, table, source, configure);
|
||||
return this.fetchSelect(plugin, pluginService, table, source, configure);
|
||||
}
|
||||
else if (configure.getType().equals(SqlType.INSERT)) {
|
||||
return this.fetchInsert(pluginService, table, source, configure);
|
||||
return this.fetchInsert(plugin, pluginService, table, source, configure);
|
||||
}
|
||||
else if (configure.getType().equals(SqlType.UPDATE)) {
|
||||
return this.fetchUpdate(pluginService, table, source, configure);
|
||||
return this.fetchUpdate(plugin, pluginService, table, source, configure);
|
||||
}
|
||||
else if (configure.getType().equals(SqlType.DELETE)) {
|
||||
return this.fetchDelete(pluginService, table, source, configure);
|
||||
return this.fetchDelete(plugin, pluginService, table, source, configure);
|
||||
}
|
||||
else if (configure.getType().equals(SqlType.ALTER)) {
|
||||
return this.fetchAlter(pluginService, table, source, configure);
|
||||
return this.fetchAlter(plugin, pluginService, table, source, configure);
|
||||
}
|
||||
else if (configure.getType().equals(SqlType.SHOW)) {
|
||||
return this.fetchShowCreateTable(pluginService, table, source, configure);
|
||||
return this.fetchShowCreateTable(plugin, pluginService, table, source, configure);
|
||||
}
|
||||
else if (configure.getType().equals(SqlType.TRUNCATE)) {
|
||||
return this.fetchTruncateTable(pluginService, table, source, configure);
|
||||
return this.fetchTruncateTable(plugin, pluginService, table, source, configure);
|
||||
}
|
||||
else if (configure.getType().equals(SqlType.DROP)) {
|
||||
return this.fetchDropTable(pluginService, table, source, configure);
|
||||
return this.fetchDropTable(plugin, pluginService, table, source, configure);
|
||||
}
|
||||
return CommonResponse.failure(String.format("Not implemented yet [ %s ]", configure.getType()));
|
||||
})
|
||||
@ -163,7 +164,7 @@ public class TableServiceImpl
|
||||
.type(SqlType.SELECT)
|
||||
.pagination(pagination)
|
||||
.build();
|
||||
CommonResponse<Object> tempResponse = this.fetchSelect(pluginService, table, source, tableFilter);
|
||||
CommonResponse<Object> tempResponse = this.fetchSelect(plugin, pluginService, table, source, tableFilter);
|
||||
if (tempResponse.getStatus()) {
|
||||
Response pluginResponse = (Response) tempResponse.getData();
|
||||
try {
|
||||
@ -234,7 +235,7 @@ public class TableServiceImpl
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResponse<Object> createTable(Long databaseId, TableBody configure)
|
||||
public CommonResponse<Response> createTable(Long databaseId, TableBody configure)
|
||||
{
|
||||
Optional<DatabaseEntity> optionalDatabase = this.databaseRepository.findById(databaseId);
|
||||
if (!optionalDatabase.isPresent()) {
|
||||
@ -251,7 +252,7 @@ public class TableServiceImpl
|
||||
TableBuilder.Companion.COLUMNS(configure.getColumns().stream().map(item -> item.toColumnVar()).collect(Collectors.toList()));
|
||||
String sql = TableBuilder.Companion.SQL();
|
||||
log.info("Create table sql \n {} \n on database [ {} ]", sql, database.getName());
|
||||
Configure pConfigure = source.toConfigure();
|
||||
Configure pConfigure = source.toConfigure(pluginManager, plugin);
|
||||
pConfigure.setPluginManager(pluginManager);
|
||||
Response response = pluginService.execute(pConfigure, sql);
|
||||
response.setContent(sql);
|
||||
@ -305,7 +306,7 @@ public class TableServiceImpl
|
||||
.build();
|
||||
}
|
||||
else {
|
||||
Configure pConfigure = source.toConfigure();
|
||||
Configure pConfigure = source.toConfigure(pluginManager, plugin);
|
||||
pConfigure.setPluginManager(pluginManager);
|
||||
PluginService pluginService = plugin.getService(PluginService.class);
|
||||
response = pluginService.execute(pConfigure, atomicReference.get());
|
||||
@ -328,15 +329,13 @@ public class TableServiceImpl
|
||||
* @param configure the table filter configuration
|
||||
* @return the common response object containing the fetched data
|
||||
*/
|
||||
private CommonResponse<Object> fetchSelect(PluginService plugin, TableEntity table, SourceEntity source, TableFilter configure)
|
||||
private CommonResponse<Object> fetchSelect(Plugin plugin, PluginService pluginService, TableEntity table, SourceEntity source, TableFilter configure)
|
||||
{
|
||||
try {
|
||||
List<SqlColumn> columns = Lists.newArrayList();
|
||||
int totalRows = Integer.parseInt(table.getRows());
|
||||
Configure countConfigure = source.toConfigure();
|
||||
Configure countConfigure = source.toConfigure(pluginManager, plugin);
|
||||
countConfigure.setFormat("None");
|
||||
countConfigure.setPluginManager(pluginManager);
|
||||
plugin.connect(countConfigure);
|
||||
SqlBody countBody = SqlBody.builder()
|
||||
.type(SqlType.SELECT)
|
||||
.database(table.getDatabase().getName())
|
||||
@ -351,8 +350,10 @@ public class TableServiceImpl
|
||||
}
|
||||
SqlBuilder countBuilder = new SqlBuilder(countBody);
|
||||
String countSql = countBuilder.getSql();
|
||||
Response countResponse = plugin.execute(countSql);
|
||||
plugin.destroy();
|
||||
Response countResponse = pluginService.execute(
|
||||
countConfigure,
|
||||
countSql
|
||||
);
|
||||
if (countResponse.getIsSuccessful() && !countResponse.getColumns().isEmpty()) {
|
||||
List<Object> applyResponse = (ArrayList) countResponse.getColumns().get(0);
|
||||
int applyTotal = Integer.parseInt(String.valueOf(applyResponse.get(0)));
|
||||
@ -407,12 +408,11 @@ public class TableServiceImpl
|
||||
|
||||
SqlBuilder builder = new SqlBuilder(body);
|
||||
String sql = builder.getSql();
|
||||
Configure pConfigure = source.toConfigure();
|
||||
pConfigure.setPluginManager(pluginManager);
|
||||
plugin.connect(pConfigure);
|
||||
Response response = plugin.execute(sql);
|
||||
response.setContent(sql);
|
||||
plugin.destroy();
|
||||
Configure pConfigure = source.toConfigure(pluginManager, plugin);
|
||||
Response response = pluginService.execute(
|
||||
pConfigure,
|
||||
sql
|
||||
);
|
||||
Pagination pagination = Pagination.newInstance(configure.getPagination().getPageSize(), configure.getPagination().getCurrentPage(), totalRows);
|
||||
response.setPagination(pagination);
|
||||
return CommonResponse.success(response);
|
||||
@ -431,13 +431,11 @@ public class TableServiceImpl
|
||||
* @param configure the table filter object
|
||||
* @return the common response object containing the result of the operation
|
||||
*/
|
||||
private CommonResponse<Object> fetchInsert(PluginService plugin, TableEntity table, SourceEntity source, TableFilter configure)
|
||||
private CommonResponse<Object> fetchInsert(Plugin plugin, PluginService pluginService, TableEntity table, SourceEntity source, TableFilter configure)
|
||||
{
|
||||
try {
|
||||
Configure updateConfigure = source.toConfigure();
|
||||
Configure updateConfigure = source.toConfigure(pluginManager, plugin);
|
||||
updateConfigure.setFormat("None");
|
||||
updateConfigure.setPluginManager(pluginManager);
|
||||
plugin.connect(updateConfigure);
|
||||
List<String> allSql = Lists.newArrayList();
|
||||
// Gets the auto-increment column for the current row
|
||||
List<String> autoIncrementColumns = table.getColumns()
|
||||
@ -473,7 +471,7 @@ public class TableServiceImpl
|
||||
allSql.add(new SqlBuilder(body).getSql());
|
||||
});
|
||||
String sql = String.join("\n\n", allSql);
|
||||
return CommonResponse.success(getResponse(configure, plugin, sql));
|
||||
return CommonResponse.success(getResponse(configure, pluginService, sql, updateConfigure));
|
||||
}
|
||||
catch (Exception ex) {
|
||||
return CommonResponse.failure(ExceptionUtils.getMessage(ex));
|
||||
@ -489,13 +487,11 @@ public class TableServiceImpl
|
||||
* @param configure the table filter configuration for fetching and updating the data
|
||||
* @return the response containing the fetched and updated data
|
||||
*/
|
||||
private CommonResponse<Object> fetchUpdate(PluginService plugin, TableEntity table, SourceEntity source, TableFilter configure)
|
||||
private CommonResponse<Object> fetchUpdate(Plugin plugin, PluginService pluginService, TableEntity table, SourceEntity source, TableFilter configure)
|
||||
{
|
||||
try {
|
||||
Configure updateConfigure = source.toConfigure();
|
||||
Configure updateConfigure = source.toConfigure(pluginManager, plugin);
|
||||
updateConfigure.setFormat("None");
|
||||
updateConfigure.setPluginManager(pluginManager);
|
||||
plugin.connect(updateConfigure);
|
||||
List<String> allSql = Lists.newArrayList();
|
||||
configure.getColumns().forEach(v -> {
|
||||
SqlBody body = SqlBody.builder()
|
||||
@ -511,7 +507,7 @@ public class TableServiceImpl
|
||||
allSql.add(new SqlBuilder(body).getSql());
|
||||
});
|
||||
String sql = String.join("\n\n", allSql);
|
||||
return CommonResponse.success(getResponse(configure, plugin, sql));
|
||||
return CommonResponse.success(getResponse(configure, pluginService, sql, updateConfigure));
|
||||
}
|
||||
catch (Exception ex) {
|
||||
return CommonResponse.failure(ExceptionUtils.getMessage(ex));
|
||||
@ -527,13 +523,11 @@ public class TableServiceImpl
|
||||
* @param configure the table filter to use for filtering the data to be deleted
|
||||
* @return the response containing the result of the delete operation
|
||||
*/
|
||||
private CommonResponse<Object> fetchDelete(PluginService plugin, TableEntity table, SourceEntity source, TableFilter configure)
|
||||
private CommonResponse<Object> fetchDelete(Plugin plugin, PluginService pluginService, TableEntity table, SourceEntity source, TableFilter configure)
|
||||
{
|
||||
try {
|
||||
Configure updateConfigure = source.toConfigure();
|
||||
Configure updateConfigure = source.toConfigure(pluginManager, plugin);
|
||||
updateConfigure.setFormat("None");
|
||||
updateConfigure.setPluginManager(pluginManager);
|
||||
plugin.connect(updateConfigure);
|
||||
List<String> allSql = Lists.newArrayList();
|
||||
configure.getColumns().forEach(v -> {
|
||||
SqlBody body = SqlBody.builder()
|
||||
@ -545,7 +539,7 @@ public class TableServiceImpl
|
||||
allSql.add(new SqlBuilder(body).getSql());
|
||||
});
|
||||
String sql = String.join("\n\n", allSql);
|
||||
return CommonResponse.success(getResponse(configure, plugin, sql));
|
||||
return CommonResponse.success(getResponse(configure, pluginService, sql, updateConfigure));
|
||||
}
|
||||
catch (Exception ex) {
|
||||
return CommonResponse.failure(ExceptionUtils.getMessage(ex));
|
||||
@ -561,20 +555,18 @@ public class TableServiceImpl
|
||||
* @param configure the table filter to apply to the alter operation
|
||||
* @return a CommonResponse object containing the result of the alter operation
|
||||
*/
|
||||
private CommonResponse<Object> fetchAlter(PluginService plugin, TableEntity table, SourceEntity source, TableFilter configure)
|
||||
private CommonResponse<Object> fetchAlter(Plugin plugin, PluginService pluginService, TableEntity table, SourceEntity source, TableFilter configure)
|
||||
{
|
||||
try {
|
||||
Configure alterConfigure = source.toConfigure();
|
||||
Configure alterConfigure = source.toConfigure(pluginManager, plugin);
|
||||
alterConfigure.setFormat("None");
|
||||
alterConfigure.setPluginManager(pluginManager);
|
||||
plugin.connect(alterConfigure);
|
||||
SqlBody body = SqlBody.builder()
|
||||
.type(SqlType.ALTER)
|
||||
.database(table.getDatabase().getName())
|
||||
.table(table.getName())
|
||||
.value(configure.getValue())
|
||||
.build();
|
||||
return CommonResponse.success(getResponse(configure, plugin, new SqlBuilder(body).getSql()));
|
||||
return CommonResponse.success(getResponse(configure, pluginService, new SqlBuilder(body).getSql(), alterConfigure));
|
||||
}
|
||||
catch (Exception ex) {
|
||||
return CommonResponse.failure(ExceptionUtils.getMessage(ex));
|
||||
@ -590,19 +582,17 @@ public class TableServiceImpl
|
||||
* @param configure the table filter configuration
|
||||
* @return the common response object containing the result of the query
|
||||
*/
|
||||
private CommonResponse<Object> fetchShowCreateTable(PluginService plugin, TableEntity table, SourceEntity source, TableFilter configure)
|
||||
private CommonResponse<Object> fetchShowCreateTable(Plugin plugin, PluginService pluginService, TableEntity table, SourceEntity source, TableFilter configure)
|
||||
{
|
||||
try {
|
||||
Configure alterConfigure = source.toConfigure();
|
||||
Configure alterConfigure = source.toConfigure(pluginManager, plugin);
|
||||
alterConfigure.setFormat("None");
|
||||
alterConfigure.setPluginManager(pluginManager);
|
||||
plugin.connect(alterConfigure);
|
||||
SqlBody body = SqlBody.builder()
|
||||
.type(SqlType.SHOW)
|
||||
.database(table.getDatabase().getName())
|
||||
.table(table.getName())
|
||||
.build();
|
||||
return CommonResponse.success(getResponse(configure, plugin, new SqlBuilder(body).getSql()));
|
||||
return CommonResponse.success(getResponse(configure, pluginService, new SqlBuilder(body).getSql(), alterConfigure));
|
||||
}
|
||||
catch (Exception ex) {
|
||||
return CommonResponse.failure(ExceptionUtils.getMessage(ex));
|
||||
@ -618,19 +608,17 @@ public class TableServiceImpl
|
||||
* @param configure the table filter configuration
|
||||
* @return the common response object containing the fetch and truncate result
|
||||
*/
|
||||
private CommonResponse<Object> fetchTruncateTable(PluginService plugin, TableEntity table, SourceEntity source, TableFilter configure)
|
||||
private CommonResponse<Object> fetchTruncateTable(Plugin plugin, PluginService pluginService, TableEntity table, SourceEntity source, TableFilter configure)
|
||||
{
|
||||
try {
|
||||
Configure alterConfigure = source.toConfigure();
|
||||
Configure alterConfigure = source.toConfigure(pluginManager, plugin);
|
||||
alterConfigure.setFormat("None");
|
||||
alterConfigure.setPluginManager(pluginManager);
|
||||
plugin.connect(alterConfigure);
|
||||
SqlBody body = SqlBody.builder()
|
||||
.type(SqlType.TRUNCATE)
|
||||
.database(table.getDatabase().getName())
|
||||
.table(table.getName())
|
||||
.build();
|
||||
return CommonResponse.success(getResponse(configure, plugin, new SqlBuilder(body).getSql()));
|
||||
return CommonResponse.success(getResponse(configure, pluginService, new SqlBuilder(body).getSql(), alterConfigure));
|
||||
}
|
||||
catch (Exception ex) {
|
||||
return CommonResponse.failure(ExceptionUtils.getMessage(ex));
|
||||
@ -646,20 +634,18 @@ public class TableServiceImpl
|
||||
* @param configure the table filter configuration
|
||||
* @return the common response object containing the fetched result
|
||||
*/
|
||||
private CommonResponse<Object> fetchDropTable(PluginService plugin, TableEntity table, SourceEntity source, TableFilter configure)
|
||||
private CommonResponse<Object> fetchDropTable(Plugin plugin, PluginService pluginService, TableEntity table, SourceEntity source, TableFilter configure)
|
||||
{
|
||||
try {
|
||||
Configure alterConfigure = source.toConfigure();
|
||||
Configure alterConfigure = source.toConfigure(pluginManager, plugin);
|
||||
alterConfigure.setFormat("None");
|
||||
alterConfigure.setPluginManager(pluginManager);
|
||||
plugin.connect(alterConfigure);
|
||||
SqlBody body = SqlBody.builder()
|
||||
.type(SqlType.DROP)
|
||||
.database(table.getDatabase().getName())
|
||||
.table(table.getName())
|
||||
.value(configure.getValue())
|
||||
.build();
|
||||
Response response = getResponse(configure, plugin, new SqlBuilder(body).getSql());
|
||||
Response response = getResponse(configure, pluginService, new SqlBuilder(body).getSql(), alterConfigure);
|
||||
if (!configure.isPreview() && response.getIsSuccessful()) {
|
||||
repository.delete(table);
|
||||
}
|
||||
@ -713,10 +699,10 @@ public class TableServiceImpl
|
||||
* @param sql the SQL query to execute
|
||||
* @return the response containing the result of the SQL query
|
||||
*/
|
||||
private Response getResponse(TableFilter configure, PluginService plugin, String sql)
|
||||
private Response getResponse(TableFilter filter, PluginService plugin, String sql, Configure configure)
|
||||
{
|
||||
Response response;
|
||||
if (configure.isPreview()) {
|
||||
if (filter.isPreview()) {
|
||||
response = Response.builder()
|
||||
.isSuccessful(true)
|
||||
.isConnected(true)
|
||||
@ -727,8 +713,7 @@ public class TableServiceImpl
|
||||
.build();
|
||||
}
|
||||
else {
|
||||
response = plugin.execute(sql);
|
||||
plugin.destroy();
|
||||
response = plugin.execute(configure, sql);
|
||||
response.setContent(sql);
|
||||
}
|
||||
return response;
|
||||
|
@ -122,14 +122,16 @@ public class TemplateSqlServiceImpl
|
||||
@Override
|
||||
public CommonResponse<TemplateEntity> getById(Long id)
|
||||
{
|
||||
return CommonResponse.success(this.templateSqlRepository.findById(id));
|
||||
return templateSqlRepository.findById(id)
|
||||
.map(CommonResponse::success)
|
||||
.orElse(CommonResponse.failure(String.format("Template [ %s ] not found", id)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResponse<Object> execute(TemplateSqlBody configure)
|
||||
{
|
||||
Optional<SourceEntity> sourceEntity = this.sourceRepository.findById(configure.getSourceId());
|
||||
if (!sourceEntity.isPresent()) {
|
||||
if (sourceEntity.isEmpty()) {
|
||||
return CommonResponse.failure(ServiceState.SOURCE_NOT_FOUND);
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@ import io.edurt.datacap.common.utils.NullAwareBeanUtils;
|
||||
import io.edurt.datacap.fs.FsRequest;
|
||||
import io.edurt.datacap.fs.FsResponse;
|
||||
import io.edurt.datacap.fs.FsService;
|
||||
import io.edurt.datacap.plugin.Plugin;
|
||||
import io.edurt.datacap.plugin.PluginManager;
|
||||
import io.edurt.datacap.service.adapter.PageRequestAdapter;
|
||||
import io.edurt.datacap.service.audit.AuditUserLog;
|
||||
@ -304,45 +305,83 @@ public class UserServiceImpl
|
||||
@Override
|
||||
public CommonResponse<FsResponse> uploadAvatar(MultipartFile file)
|
||||
{
|
||||
if (file == null || file.isEmpty()) {
|
||||
return CommonResponse.failure("Upload file cannot be empty");
|
||||
}
|
||||
|
||||
return pluginManager.getPlugin(initializerConfigure.getFsConfigure().getType())
|
||||
.map(plugin -> {
|
||||
UserEntity user = UserDetailsService.getUser();
|
||||
try {
|
||||
String avatarPath = initializerConfigure.getAvatarPath();
|
||||
log.info("Upload avatar user [ {} ] home [ {} ]", user.getUsername(), avatarPath);
|
||||
.map(plugin -> processAvatarUpload(plugin, file))
|
||||
.map(response -> processUploadResult(response, file))
|
||||
.orElse(CommonResponse.failure(String.format("Not found Fs [%s]",
|
||||
initializerConfigure.getFsConfigure().getType())));
|
||||
}
|
||||
|
||||
FsRequest fsRequest = FsRequest.builder()
|
||||
.access(initializerConfigure.getFsConfigure().getAccess())
|
||||
.secret(initializerConfigure.getFsConfigure().getSecret())
|
||||
.endpoint(avatarPath)
|
||||
.bucket(initializerConfigure.getFsConfigure().getBucket())
|
||||
.stream(file.getInputStream())
|
||||
.fileName(String.format("%s.png", user.getId()))
|
||||
.build();
|
||||
private FsResponse processAvatarUpload(Plugin plugin, MultipartFile file)
|
||||
{
|
||||
UserEntity user = UserDetailsService.getUser();
|
||||
try {
|
||||
String avatarPath = initializerConfigure.getAvatarPath();
|
||||
log.info("Upload avatar user [{}] home [{}]", user.getUsername(), avatarPath);
|
||||
|
||||
FsService fsService = plugin.getService(FsService.class);
|
||||
FsResponse response = fsService.writer(fsRequest);
|
||||
UserEntity entity = userRepository.findById(user.getId()).get();
|
||||
Map<String, String> avatar = Maps.newConcurrentMap();
|
||||
avatar.put("fsType", initializerConfigure.getFsConfigure().getType());
|
||||
avatar.put("local", response.getRemote());
|
||||
if (initializerConfigure.getFsConfigure().getType().equals("Local")) {
|
||||
avatar.put("path", encodeImageToBase64(file.getInputStream()));
|
||||
}
|
||||
else {
|
||||
avatar.put("path", response.getRemote());
|
||||
}
|
||||
entity.setAvatarConfigure(avatar);
|
||||
userRepository.save(entity);
|
||||
return CommonResponse.success(response);
|
||||
}
|
||||
catch (IOException e) {
|
||||
log.warn("File upload exception on user [ {} ]", user.getUsername(), e);
|
||||
return CommonResponse.failure(e.getMessage());
|
||||
}
|
||||
})
|
||||
.orElseGet(() -> CommonResponse.failure(String.format("Not found Fs [ %s ]", initializerConfigure.getFsConfigure().getType())));
|
||||
FsRequest fsRequest = buildFsRequest(user, avatarPath, file);
|
||||
FsService fsService = plugin.getService(FsService.class);
|
||||
return fsService.writer(fsRequest);
|
||||
}
|
||||
catch (IOException e) {
|
||||
log.error("Failed to process avatar upload for user [{}]", user.getUsername(), e);
|
||||
throw new IllegalStateException("Failed to process avatar upload", e);
|
||||
}
|
||||
}
|
||||
|
||||
private FsRequest buildFsRequest(UserEntity user, String avatarPath, MultipartFile file)
|
||||
throws IOException
|
||||
{
|
||||
return FsRequest.builder()
|
||||
.access(initializerConfigure.getFsConfigure().getAccess())
|
||||
.secret(initializerConfigure.getFsConfigure().getSecret())
|
||||
.endpoint(avatarPath)
|
||||
.bucket(initializerConfigure.getFsConfigure().getBucket())
|
||||
.stream(file.getInputStream())
|
||||
.fileName(String.format("%s.png", user.getId()))
|
||||
.build();
|
||||
}
|
||||
|
||||
private CommonResponse<FsResponse> processUploadResult(FsResponse response, MultipartFile file)
|
||||
{
|
||||
try {
|
||||
UserEntity user = UserDetailsService.getUser();
|
||||
UserEntity entity = userRepository.findById(user.getId())
|
||||
.orElseThrow(() -> new IllegalStateException("User not found: " + user.getId()));
|
||||
|
||||
Map<String, String> avatar = createAvatarConfig(response, file);
|
||||
entity.setAvatarConfigure(avatar);
|
||||
userRepository.save(entity);
|
||||
|
||||
return CommonResponse.success(response);
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("Failed to process upload result", e);
|
||||
return CommonResponse.failure("Failed to process upload result: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, String> createAvatarConfig(FsResponse response, MultipartFile file)
|
||||
throws IOException
|
||||
{
|
||||
Map<String, String> avatar = Maps.newConcurrentMap();
|
||||
String fsType = initializerConfigure.getFsConfigure().getType();
|
||||
|
||||
avatar.put("fsType", fsType);
|
||||
avatar.put("local", response.getRemote());
|
||||
|
||||
if ("Local".equals(fsType)) {
|
||||
avatar.put("path", encodeImageToBase64(file.getInputStream()));
|
||||
}
|
||||
else {
|
||||
avatar.put("path", response.getRemote());
|
||||
}
|
||||
|
||||
return avatar;
|
||||
}
|
||||
|
||||
private String encodeImageToBase64(InputStream inputStream)
|
||||
|
@ -75,6 +75,7 @@ public interface PluginService
|
||||
{
|
||||
Connection connection = local.get();
|
||||
Response response = new Response();
|
||||
response.setContent(content);
|
||||
if (connection != null) {
|
||||
log.info("Execute [ {} ] plugin started", this.name());
|
||||
Adapter adapter;
|
||||
|
@ -39,5 +39,4 @@ public class Configure
|
||||
private String home;
|
||||
private boolean usedConfig;
|
||||
private String id;
|
||||
private String classLoader;
|
||||
}
|
||||
|
@ -7,6 +7,10 @@
|
||||
<ShadcnAlert type="error" :title="localConfiguration.message"/>
|
||||
</div>
|
||||
|
||||
<div v-else-if="hasError && message" class="flex items-center justify-center absolute inset-0">
|
||||
<ShadcnAlert type="error" show-icon :title="message"/>
|
||||
</div>
|
||||
|
||||
<div v-else>
|
||||
<VisualTable v-if="configuration?.type === Type.TABLE"
|
||||
:configuration="localConfiguration as any"
|
||||
@ -146,6 +150,8 @@ export default defineComponent({
|
||||
{
|
||||
return {
|
||||
loading: false,
|
||||
hasError: false,
|
||||
message: null as string | null,
|
||||
localConfiguration: null as Configuration | null
|
||||
}
|
||||
},
|
||||
@ -163,15 +169,13 @@ export default defineComponent({
|
||||
const configure: ExecuteModel = { name: this.original as any, content: this.query as any, mode: 'REPORT', format: 'JsonConvert' }
|
||||
ExecuteService.execute(configure, null)
|
||||
.then(response => {
|
||||
if (response.data.isSuccessful) {
|
||||
if (response.status && response.data.isSuccessful) {
|
||||
this.formatRaw(response)
|
||||
this.message = null
|
||||
}
|
||||
else {
|
||||
// @ts-ignore
|
||||
this.$Message.error({
|
||||
content: response.data.message,
|
||||
showIcon: true
|
||||
})
|
||||
this.hasError = response.message
|
||||
this.message = response.message
|
||||
}
|
||||
})
|
||||
.finally(() => this.loading = false)
|
||||
|
Loading…
Reference in New Issue
Block a user