mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-16 18:56:22 +00:00
Merge pull request #213 from SyncrowIOT/bufgix/list-space-models
updated listing
This commit is contained in:
@ -98,14 +98,17 @@ export function TypeORMCustomModel(repository: Repository<any>) {
|
|||||||
|
|
||||||
if (customQueryBuilder) {
|
if (customQueryBuilder) {
|
||||||
const qb = customQueryBuilder.skip(skip).take(size);
|
const qb = customQueryBuilder.skip(skip).take(size);
|
||||||
|
|
||||||
if (order) {
|
if (order) {
|
||||||
Object.keys(order).forEach((key) => {
|
Object.keys(order).forEach((key) => {
|
||||||
qb.addOrderBy(key, order[key]);
|
qb.addOrderBy(key, order[key]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (whereClause) {
|
if (whereClause) {
|
||||||
qb.where(whereClause);
|
qb.andWhere(whereClause); // Use .andWhere instead of .where to avoid overwriting conditions
|
||||||
}
|
}
|
||||||
|
|
||||||
if (select) {
|
if (select) {
|
||||||
const selectColumns = Array.isArray(select)
|
const selectColumns = Array.isArray(select)
|
||||||
? select
|
? select
|
||||||
@ -114,6 +117,7 @@ export function TypeORMCustomModel(repository: Repository<any>) {
|
|||||||
);
|
);
|
||||||
qb.select(selectColumns as string[]);
|
qb.select(selectColumns as string[]);
|
||||||
}
|
}
|
||||||
|
|
||||||
[data, count] = await qb.getManyAndCount();
|
[data, count] = await qb.getManyAndCount();
|
||||||
} else {
|
} else {
|
||||||
[data, count] = await repository.findAndCount({
|
[data, count] = await repository.findAndCount({
|
||||||
|
@ -121,12 +121,27 @@ export class SpaceModelService {
|
|||||||
pageable.include =
|
pageable.include =
|
||||||
'subspaceModels,tags,subspaceModels.tags,tags.product,subspaceModels.tags.product';
|
'subspaceModels,tags,subspaceModels.tags,tags.product,subspaceModels.tags.product';
|
||||||
|
|
||||||
const queryBuilder = this.spaceModelRepository
|
const queryBuilder = await this.spaceModelRepository
|
||||||
.createQueryBuilder('spaceModel')
|
.createQueryBuilder('spaceModel')
|
||||||
.leftJoinAndSelect('spaceModel.subspaceModels', 'subspaceModels')
|
.leftJoinAndSelect(
|
||||||
.leftJoinAndSelect('spaceModel.tags', 'tags')
|
'spaceModel.subspaceModels',
|
||||||
|
'subspaceModels',
|
||||||
|
'subspaceModels.disabled = :subspaceDisabled',
|
||||||
|
{ subspaceDisabled: false },
|
||||||
|
)
|
||||||
|
.leftJoinAndSelect(
|
||||||
|
'spaceModel.tags',
|
||||||
|
'tags',
|
||||||
|
'tags.disabled = :tagsDisabled',
|
||||||
|
{ tagsDisabled: false },
|
||||||
|
)
|
||||||
.leftJoinAndSelect('tags.product', 'spaceTagproduct')
|
.leftJoinAndSelect('tags.product', 'spaceTagproduct')
|
||||||
.leftJoinAndSelect('subspaceModels.tags', 'subspaceModelTags')
|
.leftJoinAndSelect(
|
||||||
|
'subspaceModels.tags',
|
||||||
|
'subspaceModelTags',
|
||||||
|
'subspaceModelTags.disabled = :subspaceModelTagsDisabled',
|
||||||
|
{ subspaceModelTagsDisabled: false },
|
||||||
|
)
|
||||||
.leftJoinAndSelect('subspaceModelTags.product', 'subspaceTagproduct')
|
.leftJoinAndSelect('subspaceModelTags.product', 'subspaceTagproduct')
|
||||||
.where('spaceModel.disabled = :disabled', { disabled: false })
|
.where('spaceModel.disabled = :disabled', { disabled: false })
|
||||||
.andWhere('spaceModel.project = :projectUuid', {
|
.andWhere('spaceModel.project = :projectUuid', {
|
||||||
@ -144,6 +159,8 @@ export class SpaceModelService {
|
|||||||
queryBuilder,
|
queryBuilder,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
console.log(baseResponseDto);
|
||||||
|
|
||||||
return new PageResponse<SpaceModelDto>(
|
return new PageResponse<SpaceModelDto>(
|
||||||
baseResponseDto,
|
baseResponseDto,
|
||||||
paginationResponseDto,
|
paginationResponseDto,
|
||||||
|
@ -184,11 +184,31 @@ export class SpaceService {
|
|||||||
'children.disabled = :disabled',
|
'children.disabled = :disabled',
|
||||||
{ disabled: false },
|
{ disabled: false },
|
||||||
)
|
)
|
||||||
.leftJoinAndSelect('space.incomingConnections', 'incomingConnections')
|
.leftJoinAndSelect(
|
||||||
.leftJoinAndSelect('space.tags', 'tags')
|
'space.incomingConnections',
|
||||||
|
'incomingConnections',
|
||||||
|
'incomingConnections.disabled = :incomingConnectionDisabled',
|
||||||
|
{ incomingConnectionDisabled: false },
|
||||||
|
)
|
||||||
|
.leftJoinAndSelect(
|
||||||
|
'space.tags',
|
||||||
|
'tags',
|
||||||
|
'tags.disabled = :tagDisabled',
|
||||||
|
{ tagDisabled: false },
|
||||||
|
)
|
||||||
.leftJoinAndSelect('tags.product', 'tagProduct')
|
.leftJoinAndSelect('tags.product', 'tagProduct')
|
||||||
.leftJoinAndSelect('space.subspaces', 'subspaces')
|
.leftJoinAndSelect(
|
||||||
.leftJoinAndSelect('subspaces.tags', 'subspaceTags')
|
'space.subspaces',
|
||||||
|
'subspaces',
|
||||||
|
'subspaces.disabled = :subspaceDisabled',
|
||||||
|
{ subspaceDisabled: false },
|
||||||
|
)
|
||||||
|
.leftJoinAndSelect(
|
||||||
|
'subspaces.tags',
|
||||||
|
'subspaceTags',
|
||||||
|
'subspaceTags.disabled = :subspaceTagsDisabled',
|
||||||
|
{ subspaceTagsDisabled: false },
|
||||||
|
)
|
||||||
.leftJoinAndSelect('subspaceTags.product', 'subspaceTagProduct')
|
.leftJoinAndSelect('subspaceTags.product', 'subspaceTagProduct')
|
||||||
.where('space.community_id = :communityUuid', { communityUuid })
|
.where('space.community_id = :communityUuid', { communityUuid })
|
||||||
.andWhere('space.spaceName != :orphanSpaceName', {
|
.andWhere('space.spaceName != :orphanSpaceName', {
|
||||||
|
Reference in New Issue
Block a user