-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d9d78af
commit 288b8cc
Showing
18 changed files
with
637 additions
and
2 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
...server-domain-api/src/main/java/ai/chat2db/server/domain/api/service/FunctionService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package ai.chat2db.server.domain.api.service; | ||
|
||
import ai.chat2db.server.tools.base.wrapper.result.ListResult; | ||
import ai.chat2db.spi.model.Function; | ||
import jakarta.validation.constraints.NotEmpty; | ||
|
||
/** | ||
* author jipengfei | ||
* date 2021/9/23 15:22 | ||
*/ | ||
public interface FunctionService { | ||
|
||
/** | ||
* Querying all functions under a schema. | ||
* | ||
* @param databaseName | ||
* @return | ||
*/ | ||
ListResult<Function> functions(@NotEmpty String databaseName, String schemaName); | ||
|
||
|
||
} |
16 changes: 16 additions & 0 deletions
16
...erver-domain-api/src/main/java/ai/chat2db/server/domain/api/service/ProcedureService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package ai.chat2db.server.domain.api.service; | ||
|
||
import ai.chat2db.server.tools.base.wrapper.result.ListResult; | ||
import ai.chat2db.spi.model.Procedure; | ||
import jakarta.validation.constraints.NotEmpty; | ||
|
||
public interface ProcedureService { | ||
|
||
/** | ||
* Querying all procedures under a schema. | ||
* | ||
* @param databaseName | ||
* @return | ||
*/ | ||
ListResult<Procedure> procedures(@NotEmpty String databaseName, String schemaName); | ||
} |
17 changes: 17 additions & 0 deletions
17
...-server-domain-api/src/main/java/ai/chat2db/server/domain/api/service/TriggerService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package ai.chat2db.server.domain.api.service; | ||
|
||
import ai.chat2db.server.tools.base.wrapper.result.ListResult; | ||
import ai.chat2db.spi.model.Trigger; | ||
import jakarta.validation.constraints.NotEmpty; | ||
|
||
public interface TriggerService { | ||
|
||
/** | ||
* Querying all triggers under a schema. | ||
* | ||
* @param databaseName | ||
* @return | ||
*/ | ||
ListResult<Trigger> triggers(@NotEmpty String databaseName, String schemaName); | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
...2db-server-domain-api/src/main/java/ai/chat2db/server/domain/api/service/ViewService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package ai.chat2db.server.domain.api.service; | ||
|
||
import ai.chat2db.server.tools.base.wrapper.result.ListResult; | ||
import ai.chat2db.spi.model.Table; | ||
import jakarta.validation.constraints.NotEmpty; | ||
|
||
/** | ||
* author jipengfei | ||
* date 2021/9/23 15:22 | ||
*/ | ||
public interface ViewService { | ||
|
||
/** | ||
* Querying all views under a schema. | ||
* | ||
* @param databaseName | ||
* @return | ||
*/ | ||
ListResult<Table> views(@NotEmpty String databaseName, String schemaName); | ||
|
||
|
||
} |
15 changes: 15 additions & 0 deletions
15
...ver-domain-core/src/main/java/ai/chat2db/server/domain/core/impl/FunctionServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package ai.chat2db.server.domain.core.impl; | ||
|
||
import ai.chat2db.server.domain.api.service.FunctionService; | ||
import ai.chat2db.server.tools.base.wrapper.result.ListResult; | ||
import ai.chat2db.spi.model.Function; | ||
import ai.chat2db.spi.sql.Chat2DBContext; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class FunctionServiceImpl implements FunctionService { | ||
@Override | ||
public ListResult<Function> functions(String databaseName, String schemaName) { | ||
return ListResult.of(Chat2DBContext.getMetaData().functions(databaseName, schemaName)); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...er-domain-core/src/main/java/ai/chat2db/server/domain/core/impl/ProcedureServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package ai.chat2db.server.domain.core.impl; | ||
|
||
import ai.chat2db.server.domain.api.service.ProcedureService; | ||
import ai.chat2db.server.tools.base.wrapper.result.ListResult; | ||
import ai.chat2db.spi.model.Procedure; | ||
import ai.chat2db.spi.sql.Chat2DBContext; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class ProcedureServiceImpl implements ProcedureService { | ||
|
||
@Override | ||
public ListResult<Procedure> procedures(String databaseName, String schemaName) { | ||
return ListResult.of(Chat2DBContext.getMetaData().procedures(databaseName, schemaName)); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...rver-domain-core/src/main/java/ai/chat2db/server/domain/core/impl/TriggerServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package ai.chat2db.server.domain.core.impl; | ||
|
||
import ai.chat2db.server.domain.api.service.TriggerService; | ||
import ai.chat2db.server.tools.base.wrapper.result.ListResult; | ||
import ai.chat2db.spi.model.Trigger; | ||
import ai.chat2db.spi.sql.Chat2DBContext; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class TriggerServiceImpl implements TriggerService { | ||
@Override | ||
public ListResult<Trigger> triggers(String databaseName, String schemaName) { | ||
return ListResult.of(Chat2DBContext.getMetaData().triggers(databaseName, schemaName)); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...-server-domain-core/src/main/java/ai/chat2db/server/domain/core/impl/ViewServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package ai.chat2db.server.domain.core.impl; | ||
|
||
import ai.chat2db.server.domain.api.service.ViewService; | ||
import ai.chat2db.server.tools.base.wrapper.result.ListResult; | ||
import ai.chat2db.spi.model.Table; | ||
import ai.chat2db.spi.sql.Chat2DBContext; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class ViewServiceImpl implements ViewService { | ||
|
||
@Override | ||
public ListResult<Table> views(String databaseName, String schemaName) { | ||
return ListResult.of(Chat2DBContext.getMetaData().views(databaseName, schemaName)); | ||
} | ||
} |
93 changes: 93 additions & 0 deletions
93
...er-web-api/src/main/java/ai/chat2db/server/web/api/controller/rdb/DatabaseController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package ai.chat2db.server.web.api.controller.rdb; | ||
|
||
import ai.chat2db.server.domain.api.param.DatabaseOperationParam; | ||
import ai.chat2db.server.domain.api.param.MetaDataQueryParam; | ||
import ai.chat2db.server.domain.api.service.DatabaseService; | ||
import ai.chat2db.server.domain.api.service.DlTemplateService; | ||
import ai.chat2db.server.domain.api.service.TableService; | ||
import ai.chat2db.server.tools.base.wrapper.result.ActionResult; | ||
import ai.chat2db.server.tools.base.wrapper.result.DataResult; | ||
import ai.chat2db.server.web.api.aspect.ConnectionInfoAspect; | ||
import ai.chat2db.server.web.api.controller.data.source.request.DataSourceBaseRequest; | ||
import ai.chat2db.server.web.api.controller.rdb.converter.RdbWebConverter; | ||
import ai.chat2db.server.web.api.controller.rdb.request.UpdateDatabaseRequest; | ||
import ai.chat2db.server.web.api.controller.rdb.vo.MetaSchemaVO; | ||
import ai.chat2db.spi.model.MetaSchema; | ||
import jakarta.validation.Valid; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@ConnectionInfoAspect | ||
@RequestMapping("/api/rdb/datbase") | ||
@RestController | ||
public class DatabaseController { | ||
|
||
@Autowired | ||
private TableService tableService; | ||
|
||
@Autowired | ||
private DlTemplateService dlTemplateService; | ||
|
||
@Autowired | ||
private RdbWebConverter rdbWebConverter; | ||
|
||
@Autowired | ||
private DatabaseService databaseService; | ||
/** | ||
* 查询数据库里包含的database_schema_list | ||
* | ||
* @param request | ||
* @return | ||
*/ | ||
@GetMapping("/database_schema_list") | ||
public DataResult<MetaSchemaVO> databaseSchemaList(@Valid DataSourceBaseRequest request) { | ||
MetaDataQueryParam queryParam = MetaDataQueryParam.builder().dataSourceId(request.getDataSourceId()).refresh( | ||
request.isRefresh()).build(); | ||
DataResult<MetaSchema> result = databaseService.queryDatabaseSchema(queryParam); | ||
MetaSchemaVO schemaDto2vo = rdbWebConverter.metaSchemaDto2vo(result.getData()); | ||
return DataResult.of(schemaDto2vo); | ||
} | ||
|
||
|
||
/** | ||
* 删除数据库 | ||
* | ||
* @param request | ||
* @return | ||
*/ | ||
@PostMapping("/delete_database") | ||
public ActionResult deleteDatabase(@Valid @RequestBody DataSourceBaseRequest request) { | ||
DatabaseOperationParam param = DatabaseOperationParam.builder().databaseName(request.getDatabaseName()).build(); | ||
return databaseService.deleteDatabase(param); | ||
} | ||
|
||
/** | ||
* 创建database | ||
* | ||
* @param request | ||
* @return | ||
*/ | ||
@PostMapping("/create_database") | ||
public ActionResult createDatabase(@Valid @RequestBody DataSourceBaseRequest request) { | ||
DatabaseOperationParam param = DatabaseOperationParam.builder().databaseName(request.getDatabaseName()).build(); | ||
return databaseService.createDatabase(param); | ||
} | ||
|
||
|
||
/** | ||
* 修改database | ||
* | ||
* @param request | ||
* @return | ||
*/ | ||
@PostMapping("/modify_database") | ||
public ActionResult modifyDatabase(@Valid @RequestBody UpdateDatabaseRequest request) { | ||
DatabaseOperationParam param = DatabaseOperationParam.builder().databaseName(request.getDatabaseName()) | ||
.newDatabaseName(request.getNewDatabaseName()).build(); | ||
return databaseService.modifyDatabase(param); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...er-web-api/src/main/java/ai/chat2db/server/web/api/controller/rdb/FunctionController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package ai.chat2db.server.web.api.controller.rdb; | ||
|
||
import ai.chat2db.server.domain.api.service.FunctionService; | ||
import ai.chat2db.server.tools.base.wrapper.result.ListResult; | ||
import ai.chat2db.server.web.api.aspect.ConnectionInfoAspect; | ||
import ai.chat2db.server.web.api.controller.rdb.request.TableBriefQueryRequest; | ||
import ai.chat2db.spi.model.Function; | ||
import jakarta.validation.Valid; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@ConnectionInfoAspect | ||
@RequestMapping("/api/rdb/function") | ||
@RestController | ||
public class FunctionController { | ||
|
||
@Autowired | ||
private FunctionService functionService; | ||
|
||
|
||
@GetMapping("/list") | ||
public ListResult<Function> list(@Valid TableBriefQueryRequest request) { | ||
return functionService.functions(request.getDatabaseName(), request.getSchemaName()); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...r-web-api/src/main/java/ai/chat2db/server/web/api/controller/rdb/ProcedureController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package ai.chat2db.server.web.api.controller.rdb; | ||
|
||
import ai.chat2db.server.domain.api.service.ProcedureService; | ||
import ai.chat2db.server.tools.base.wrapper.result.ListResult; | ||
import ai.chat2db.server.web.api.aspect.ConnectionInfoAspect; | ||
import ai.chat2db.server.web.api.controller.rdb.request.TableBriefQueryRequest; | ||
import ai.chat2db.spi.model.Procedure; | ||
import jakarta.validation.Valid; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@ConnectionInfoAspect | ||
@RequestMapping("/api/rdb/procedure") | ||
@RestController | ||
public class ProcedureController { | ||
|
||
private ProcedureService procedureService; | ||
|
||
@GetMapping("/list") | ||
public ListResult<Procedure> list(@Valid TableBriefQueryRequest request) { | ||
return procedureService.procedures(request.getDatabaseName(), request.getSchemaName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.