mirror of
https://github.com/vran-dev/databasir.git
synced 2025-08-08 23:01:23 +08:00
feature: support database, schema config (#44)
* feat: add schema_name * feat: support database, schema config * feat: add more detail info in databaseTypes * feat: add permission control to databaseType api * feat: update frontend resources
This commit is contained in:
@@ -9,6 +9,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.web.PageableDefault;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -28,9 +29,8 @@ public class DatabaseTypeController {
|
||||
private final DatabaseTypeValidator databaseTypeValidator;
|
||||
|
||||
@GetMapping(Routes.DatabaseType.LIST_SIMPLE)
|
||||
public JsonData<List<String>> listSimpleDatabaseTypes() {
|
||||
List<String> types = databaseTypeService.listSimpleDatabaseTypes();
|
||||
return JsonData.ok(types);
|
||||
public JsonData<List<DatabaseTypeSimpleResponse>> listSimpleDatabaseTypes() {
|
||||
return JsonData.ok(databaseTypeService.listSimpleDatabaseTypes());
|
||||
}
|
||||
|
||||
@GetMapping(Routes.DatabaseType.LIST_PAGE)
|
||||
@@ -43,6 +43,7 @@ public class DatabaseTypeController {
|
||||
|
||||
@PostMapping(Routes.DatabaseType.CREATE)
|
||||
@Operation(module = Operation.Modules.DATABASE_TYPE, name = "创建数据库类型")
|
||||
@PreAuthorize("hasAnyAuthority('SYS_OWNER')")
|
||||
public JsonData<Integer> create(@RequestBody @Valid DatabaseTypeCreateRequest request) {
|
||||
databaseTypeValidator.isValidUrlPattern(request.getUrlPattern());
|
||||
Integer id = databaseTypeService.create(request);
|
||||
@@ -51,6 +52,7 @@ public class DatabaseTypeController {
|
||||
|
||||
@PatchMapping(Routes.DatabaseType.UPDATE)
|
||||
@Operation(module = Operation.Modules.DATABASE_TYPE, name = "更新数据库类型")
|
||||
@PreAuthorize("hasAnyAuthority('SYS_OWNER')")
|
||||
public JsonData<Void> update(@RequestBody @Valid DatabaseTypeUpdateRequest request) {
|
||||
databaseTypeValidator.isValidUrlPattern(request.getUrlPattern());
|
||||
databaseTypeService.update(request);
|
||||
@@ -59,6 +61,7 @@ public class DatabaseTypeController {
|
||||
|
||||
@DeleteMapping(Routes.DatabaseType.DELETE_ONE)
|
||||
@Operation(module = Operation.Modules.DATABASE_TYPE, name = "删除数据库类型")
|
||||
@PreAuthorize("hasAnyAuthority('SYS_OWNER')")
|
||||
public JsonData<Void> delete(@PathVariable Integer id) {
|
||||
databaseTypeService.deleteById(id);
|
||||
return JsonData.ok();
|
||||
|
@@ -1,23 +1,24 @@
|
||||
package com.databasir.api.validator;
|
||||
|
||||
import com.databasir.core.domain.DomainErrors;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import static com.databasir.core.domain.DomainErrors.INVALID_DATABASE_TYPE_URL_PATTERN;
|
||||
|
||||
@Component
|
||||
public class DatabaseTypeValidator {
|
||||
|
||||
public void isValidUrlPattern(String urlPattern) {
|
||||
if (urlPattern == null) {
|
||||
throw DomainErrors.INVALID_DATABASE_TYPE_URL_PATTERN.exception("url pattern 不能为空");
|
||||
throw INVALID_DATABASE_TYPE_URL_PATTERN.exception("url pattern 不能为空");
|
||||
}
|
||||
if (!urlPattern.contains("{{jdbc.protocol}}")) {
|
||||
throw DomainErrors.INVALID_DATABASE_TYPE_URL_PATTERN.exception("必须包含变量{{jdbc.protocol}}");
|
||||
throw INVALID_DATABASE_TYPE_URL_PATTERN.exception("必须包含变量{{jdbc.protocol}}");
|
||||
}
|
||||
if (!urlPattern.contains("{{db.url}}")) {
|
||||
throw DomainErrors.INVALID_DATABASE_TYPE_URL_PATTERN.exception("必须包含变量{{db.url}}不能为空");
|
||||
throw INVALID_DATABASE_TYPE_URL_PATTERN.exception("必须包含变量{{db.url}}不能为空");
|
||||
}
|
||||
if (!urlPattern.contains("{{db.name}}")) {
|
||||
throw DomainErrors.INVALID_DATABASE_TYPE_URL_PATTERN.exception("必须包含变量{{db.name}}不能为空");
|
||||
if (!urlPattern.contains("{{db.schema}}") && !urlPattern.contains("{{db.name}}")) {
|
||||
throw INVALID_DATABASE_TYPE_URL_PATTERN.exception("{{db.schema}} 和 {{db.name}} 至少设置一个");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1 +1 @@
|
||||
<!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>databasir-frontend</title><script defer="defer" type="module" src="/js/chunk-vendors.45746587.js"></script><script defer="defer" type="module" src="/js/app.21cfd672.js"></script><link href="/css/chunk-vendors.8e1003a6.css" rel="stylesheet"><link href="/css/app.757c1ef3.css" rel="stylesheet"><script defer="defer" src="/js/chunk-vendors-legacy.54c3660b.js" nomodule></script><script defer="defer" src="/js/app-legacy.f867641a.js" nomodule></script></head><body><noscript><strong>We're sorry but databasir-frontend doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>
|
||||
<!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>databasir-frontend</title><script defer="defer" type="module" src="/js/chunk-vendors.45746587.js"></script><script defer="defer" type="module" src="/js/app.a4b9bb20.js"></script><link href="/css/chunk-vendors.8e1003a6.css" rel="stylesheet"><link href="/css/app.757c1ef3.css" rel="stylesheet"><script defer="defer" src="/js/chunk-vendors-legacy.54c3660b.js" nomodule></script><script defer="defer" src="/js/app-legacy.2527a373.js" nomodule></script></head><body><noscript><strong>We're sorry but databasir-frontend doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
api/src/main/resources/static/js/269.fb28ff39.js.map
Normal file
1
api/src/main/resources/static/js/269.fb28ff39.js.map
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
api/src/main/resources/static/js/395.f7b88568.js.map
Normal file
1
api/src/main/resources/static/js/395.f7b88568.js.map
Normal file
File diff suppressed because one or more lines are too long
2
api/src/main/resources/static/js/459-legacy.5a5a02e8.js
Normal file
2
api/src/main/resources/static/js/459-legacy.5a5a02e8.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
api/src/main/resources/static/js/459.22e837b8.js
Normal file
2
api/src/main/resources/static/js/459.22e837b8.js
Normal file
File diff suppressed because one or more lines are too long
1
api/src/main/resources/static/js/459.22e837b8.js.map
Normal file
1
api/src/main/resources/static/js/459.22e837b8.js.map
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
api/src/main/resources/static/js/564.07fcac27.js.map
Normal file
1
api/src/main/resources/static/js/564.07fcac27.js.map
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user