mirror of
https://github.com/CodePhiliaX/Chat2DB.git
synced 2025-07-29 10:43:06 +08:00
feat(PostgreSQL): Get the PostgreSQL sequences
This commit is contained in:
@ -1,13 +1,17 @@
|
||||
package ai.chat2db.server.web.api.controller.rdb;
|
||||
|
||||
|
||||
import ai.chat2db.server.domain.api.param.SequencePageQueryParam;
|
||||
import ai.chat2db.server.domain.api.param.ShowCreateSequenceParam;
|
||||
import ai.chat2db.server.domain.api.service.DatabaseService;
|
||||
import ai.chat2db.server.domain.api.service.SequenceService;
|
||||
import ai.chat2db.server.tools.base.wrapper.result.DataResult;
|
||||
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.converter.RdbWebConverter;
|
||||
import ai.chat2db.server.web.api.controller.rdb.request.DdlExportRequest;
|
||||
import ai.chat2db.server.web.api.controller.rdb.request.SequenceBriefQueryRequest;
|
||||
import ai.chat2db.spi.model.SimpleSequence;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -28,6 +32,18 @@ public class SequenceController {
|
||||
private final DatabaseService databaseService;
|
||||
private final SequenceService sequenceService;
|
||||
|
||||
/**
|
||||
* Query the sequence list under the current DB
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public ListResult<SimpleSequence> list(@Valid SequenceBriefQueryRequest request) {
|
||||
SequencePageQueryParam queryParam = rdbWebConverter.sequencePageRequest2param(request);
|
||||
return sequenceService.pageQuery(queryParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* Export sequence creation statement
|
||||
*
|
||||
|
@ -5,22 +5,9 @@ import java.util.List;
|
||||
import ai.chat2db.server.domain.api.param.*;
|
||||
import ai.chat2db.server.web.api.controller.data.source.vo.DatabaseVO;
|
||||
import ai.chat2db.server.web.api.controller.rdb.request.*;
|
||||
import ai.chat2db.server.web.api.controller.rdb.vo.ColumnVO;
|
||||
import ai.chat2db.server.web.api.controller.rdb.vo.ExecuteResultVO;
|
||||
import ai.chat2db.server.web.api.controller.rdb.vo.IndexVO;
|
||||
import ai.chat2db.server.web.api.controller.rdb.vo.MetaSchemaVO;
|
||||
import ai.chat2db.server.web.api.controller.rdb.vo.SchemaVO;
|
||||
import ai.chat2db.server.web.api.controller.rdb.vo.SqlVO;
|
||||
import ai.chat2db.server.web.api.controller.rdb.vo.TableVO;
|
||||
import ai.chat2db.server.web.api.controller.rdb.vo.*;
|
||||
import ai.chat2db.server.web.api.http.request.EsTableSchemaRequest;
|
||||
import ai.chat2db.spi.model.Database;
|
||||
import ai.chat2db.spi.model.ExecuteResult;
|
||||
import ai.chat2db.spi.model.MetaSchema;
|
||||
import ai.chat2db.spi.model.Schema;
|
||||
import ai.chat2db.spi.model.Sql;
|
||||
import ai.chat2db.spi.model.Table;
|
||||
import ai.chat2db.spi.model.TableColumn;
|
||||
import ai.chat2db.spi.model.TableIndex;
|
||||
import ai.chat2db.spi.model.*;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.Mappings;
|
||||
@ -115,6 +102,13 @@ public abstract class RdbWebConverter {
|
||||
* @return
|
||||
*/
|
||||
public abstract TablePageQueryParam tablePageRequest2param(DataExportRequest request);
|
||||
/**
|
||||
* Parameter conversion
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public abstract SequencePageQueryParam sequencePageRequest2param(SequenceBriefQueryRequest request);
|
||||
/**
|
||||
* Parameter conversion
|
||||
*
|
||||
@ -220,7 +214,20 @@ public abstract class RdbWebConverter {
|
||||
* @return
|
||||
*/
|
||||
public abstract List<TableVO> tableDto2vo(List<Table> dtos);
|
||||
|
||||
/**
|
||||
* Model conversion
|
||||
*
|
||||
* @param dtos
|
||||
* @return
|
||||
*/
|
||||
public abstract SimpleSequence SequenceDto2vo(Sequence dtos);
|
||||
/**
|
||||
* Model conversion
|
||||
*
|
||||
* @param dtos
|
||||
* @return
|
||||
*/
|
||||
public abstract List<SimpleSequence> SequenceDto2vo(List<Sequence> dtos);
|
||||
/**
|
||||
* Model conversion
|
||||
* @param tableColumns
|
||||
|
@ -0,0 +1,47 @@
|
||||
package ai.chat2db.server.web.api.controller.rdb.request;
|
||||
|
||||
|
||||
import ai.chat2db.server.tools.base.wrapper.request.PageQueryRequest;
|
||||
import ai.chat2db.server.web.api.controller.data.source.request.DataSourceBaseRequestInfo;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* Query sequence brief request
|
||||
*
|
||||
* @author Sylphy
|
||||
*/
|
||||
@Data
|
||||
public class SequenceBriefQueryRequest extends PageQueryRequest implements DataSourceBaseRequestInfo {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = -1324577112324436332L;
|
||||
|
||||
/**
|
||||
* Data source id
|
||||
*/
|
||||
@NotNull
|
||||
private Long dataSourceId;
|
||||
|
||||
/**
|
||||
* DB name
|
||||
*/
|
||||
private String databaseName;
|
||||
|
||||
/**
|
||||
* The space where the sequence is located is required by pg and oracle, but not by mysql.
|
||||
*/
|
||||
private String schemaName;
|
||||
|
||||
/**
|
||||
* Fuzzy search terms
|
||||
*/
|
||||
private String searchKey;
|
||||
|
||||
/**
|
||||
* if true, refresh the cache
|
||||
*/
|
||||
private boolean refresh;
|
||||
}
|
Reference in New Issue
Block a user