mirror of
https://github.com/vran-dev/databasir.git
synced 2025-08-23 05:16:26 +08:00
feat: add batch query table api
This commit is contained in:
@@ -6,6 +6,7 @@ import org.jooq.DSLContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static com.databasir.dao.Tables.TABLE_COLUMN_DOCUMENT;
|
||||
@@ -28,10 +29,15 @@ public class TableColumnDocumentDao extends BaseDao<TableColumnDocumentPojo> {
|
||||
.fetchInto(TableColumnDocumentPojo.class);
|
||||
}
|
||||
|
||||
public void deleteByDatabaseDocumentId(Integer schemaDocumentId) {
|
||||
getDslContext()
|
||||
.deleteFrom(TABLE_COLUMN_DOCUMENT)
|
||||
.where(TABLE_COLUMN_DOCUMENT.DATABASE_DOCUMENT_ID.eq(schemaDocumentId))
|
||||
.execute();
|
||||
public List<TableColumnDocumentPojo> selectByDatabaseDocumentIdAndTableIdIn(Integer schemaDocumentId,
|
||||
List<Integer> tableIdIn) {
|
||||
if (tableIdIn == null || tableIdIn.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return getDslContext()
|
||||
.select(TABLE_COLUMN_DOCUMENT.fields()).from(TABLE_COLUMN_DOCUMENT)
|
||||
.where(TABLE_COLUMN_DOCUMENT.DATABASE_DOCUMENT_ID.eq(schemaDocumentId)
|
||||
.and(TABLE_COLUMN_DOCUMENT.TABLE_DOCUMENT_ID.in(tableIdIn)))
|
||||
.fetchInto(TableColumnDocumentPojo.class);
|
||||
}
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@ import org.jooq.DSLContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static com.databasir.dao.Tables.TABLE_DOCUMENT;
|
||||
@@ -33,4 +34,16 @@ public class TableDocumentDao extends BaseDao<TableDocumentPojo> {
|
||||
.deleteFrom(TABLE_DOCUMENT).where(TABLE_DOCUMENT.DATABASE_DOCUMENT_ID.eq(schemaDocumentId))
|
||||
.execute();
|
||||
}
|
||||
|
||||
public List<TableDocumentPojo> selectByDatabaseDocumentIdAndIdIn(Integer databaseDocumentId,
|
||||
List<Integer> idList) {
|
||||
if (idList == null || idList.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return getDslContext()
|
||||
.selectFrom(TABLE_DOCUMENT)
|
||||
.where(TABLE_DOCUMENT.DATABASE_DOCUMENT_ID.eq(databaseDocumentId)
|
||||
.and(TABLE_DOCUMENT.ID.in(idList)))
|
||||
.fetchInto(TableDocumentPojo.class);
|
||||
}
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@ import org.jooq.DSLContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static com.databasir.dao.Tables.TABLE_INDEX_DOCUMENT;
|
||||
@@ -21,16 +22,22 @@ public class TableIndexDocumentDao extends BaseDao<TableIndexDocumentPojo> {
|
||||
super(TABLE_INDEX_DOCUMENT, TableIndexDocumentPojo.class);
|
||||
}
|
||||
|
||||
public List<TableIndexDocumentPojo> selectByDatabaseMetaId(Integer schemaMetaId) {
|
||||
public List<TableIndexDocumentPojo> selectByDatabaseMetaId(Integer documentId) {
|
||||
return getDslContext()
|
||||
.select(TABLE_INDEX_DOCUMENT.fields()).from(TABLE_INDEX_DOCUMENT)
|
||||
.where(TABLE_INDEX_DOCUMENT.DATABASE_DOCUMENT_ID.eq(schemaMetaId))
|
||||
.where(TABLE_INDEX_DOCUMENT.DATABASE_DOCUMENT_ID.eq(documentId))
|
||||
.fetchInto(TableIndexDocumentPojo.class);
|
||||
}
|
||||
|
||||
public void deleteByDatabaseMetaId(Integer schemaMetaId) {
|
||||
getDslContext()
|
||||
.deleteFrom(TABLE_INDEX_DOCUMENT).where(TABLE_INDEX_DOCUMENT.DATABASE_DOCUMENT_ID.eq(schemaMetaId))
|
||||
.execute();
|
||||
public List<TableIndexDocumentPojo> selectByDatabaseDocumentIdAndIdIn(Integer documentId,
|
||||
List<Integer> tableIdIn) {
|
||||
if (tableIdIn == null || tableIdIn.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return getDslContext()
|
||||
.select(TABLE_INDEX_DOCUMENT.fields()).from(TABLE_INDEX_DOCUMENT)
|
||||
.where(TABLE_INDEX_DOCUMENT.DATABASE_DOCUMENT_ID.eq(documentId)
|
||||
.and(TABLE_INDEX_DOCUMENT.TABLE_DOCUMENT_ID.in(tableIdIn)))
|
||||
.fetchInto(TableIndexDocumentPojo.class);
|
||||
}
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@ import org.jooq.DSLContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static com.databasir.dao.Tables.TABLE_TRIGGER_DOCUMENT;
|
||||
@@ -28,10 +29,15 @@ public class TableTriggerDocumentDao extends BaseDao<TableTriggerDocumentPojo> {
|
||||
.fetchInto(TableTriggerDocumentPojo.class);
|
||||
}
|
||||
|
||||
public void deleteByDatabaseDocumentId(Integer schemaDocumentId) {
|
||||
getDslContext()
|
||||
.deleteFrom(TABLE_TRIGGER_DOCUMENT)
|
||||
.where(TABLE_TRIGGER_DOCUMENT.DATABASE_DOCUMENT_ID.eq(schemaDocumentId))
|
||||
.execute();
|
||||
public List<TableTriggerDocumentPojo> selectByDatabaseDocumentIdAndIdIn(Integer documentId,
|
||||
List<Integer> tableIdIn) {
|
||||
if (tableIdIn == null || tableIdIn.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return getDslContext()
|
||||
.select(TABLE_TRIGGER_DOCUMENT.fields()).from(TABLE_TRIGGER_DOCUMENT)
|
||||
.where(TABLE_TRIGGER_DOCUMENT.DATABASE_DOCUMENT_ID.eq(documentId)
|
||||
.and(TABLE_TRIGGER_DOCUMENT.TABLE_DOCUMENT_ID.in(tableIdIn)))
|
||||
.fetchInto(TableTriggerDocumentPojo.class);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user