mirror of
https://github.com/SyncrowIOT/backend.git
synced 2026-10-24 12:57:54 +00:00
removed unit,floor,building,room modules
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { SpaceType } from '@app/common/constants/space-type.enum';
|
||||
import { SpaceRepository } from '@app/common/modules/space/repositories';
|
||||
import {
|
||||
Injectable,
|
||||
@@ -40,11 +39,7 @@ export class CheckBuildingTypeGuard implements CanActivate {
|
||||
where: { uuid: buildingUuid },
|
||||
relations: ['spaceType'],
|
||||
});
|
||||
if (
|
||||
!buildingData ||
|
||||
!buildingData.spaceType ||
|
||||
buildingData.spaceType.type !== SpaceType.BUILDING
|
||||
) {
|
||||
if (!buildingData) {
|
||||
throw new BadRequestException('Invalid building UUID');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
} from '@nestjs/common';
|
||||
import { SpaceRepository } from '@app/common/modules/space/repositories';
|
||||
import { BadRequestException } from '@nestjs/common';
|
||||
import { SpaceType } from '@app/common/constants/space-type.enum';
|
||||
|
||||
@Injectable()
|
||||
export class CheckCommunityTypeGuard implements CanActivate {
|
||||
@@ -41,11 +40,7 @@ export class CheckCommunityTypeGuard implements CanActivate {
|
||||
relations: ['spaceType'],
|
||||
});
|
||||
|
||||
if (
|
||||
!communityData ||
|
||||
!communityData.spaceType ||
|
||||
communityData.spaceType.type !== SpaceType.COMMUNITY
|
||||
) {
|
||||
if (!communityData) {
|
||||
throw new BadRequestException('Invalid community UUID');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { SpaceType } from '@app/common/constants/space-type.enum';
|
||||
import { SpaceRepository } from '@app/common/modules/space/repositories';
|
||||
import {
|
||||
Injectable,
|
||||
@@ -37,14 +36,9 @@ export class CheckFloorTypeGuard implements CanActivate {
|
||||
async checkFloorIsFloorType(floorUuid: string) {
|
||||
const floorData = await this.spaceRepository.findOne({
|
||||
where: { uuid: floorUuid },
|
||||
relations: ['spaceType'],
|
||||
});
|
||||
|
||||
if (
|
||||
!floorData ||
|
||||
!floorData.spaceType ||
|
||||
floorData.spaceType.type !== SpaceType.FLOOR
|
||||
) {
|
||||
if (!floorData) {
|
||||
throw new BadRequestException('Invalid floor UUID');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
import { SpaceRepository } from '@app/common/modules/space/repositories';
|
||||
import { BadRequestException, NotFoundException } from '@nestjs/common';
|
||||
import { DeviceRepository } from '@app/common/modules/device/repositories';
|
||||
import { SpaceType } from '@app/common/constants/space-type.enum';
|
||||
|
||||
@Injectable()
|
||||
export class CheckRoomGuard implements CanActivate {
|
||||
@@ -43,9 +42,6 @@ export class CheckRoomGuard implements CanActivate {
|
||||
const room = await this.spaceRepository.findOne({
|
||||
where: {
|
||||
uuid: roomUuid,
|
||||
spaceType: {
|
||||
type: SpaceType.ROOM,
|
||||
},
|
||||
},
|
||||
});
|
||||
if (!room) {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { SpaceType } from '@app/common/constants/space-type.enum';
|
||||
import { SpaceRepository } from '@app/common/modules/space/repositories';
|
||||
import {
|
||||
Injectable,
|
||||
@@ -37,14 +36,9 @@ export class CheckUnitTypeGuard implements CanActivate {
|
||||
async checkFloorIsFloorType(unitUuid: string) {
|
||||
const unitData = await this.spaceRepository.findOne({
|
||||
where: { uuid: unitUuid },
|
||||
relations: ['spaceType'],
|
||||
});
|
||||
|
||||
if (
|
||||
!unitData ||
|
||||
!unitData.spaceType ||
|
||||
unitData.spaceType.type !== SpaceType.UNIT
|
||||
) {
|
||||
if (!unitData) {
|
||||
throw new BadRequestException('Invalid unit UUID');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import {
|
||||
import { SpaceRepository } from '@app/common/modules/space/repositories';
|
||||
import { BadRequestException, NotFoundException } from '@nestjs/common';
|
||||
import { UserRepository } from '@app/common/modules/user/repositories';
|
||||
import { SpaceType } from '@app/common/constants/space-type.enum';
|
||||
|
||||
@Injectable()
|
||||
export class CheckUserBuildingGuard implements CanActivate {
|
||||
@@ -44,7 +43,7 @@ export class CheckUserBuildingGuard implements CanActivate {
|
||||
|
||||
private async checkBuildingIsFound(spaceUuid: string) {
|
||||
const spaceData = await this.spaceRepository.findOne({
|
||||
where: { uuid: spaceUuid, spaceType: { type: SpaceType.BUILDING } },
|
||||
where: { uuid: spaceUuid },
|
||||
relations: ['spaceType'],
|
||||
});
|
||||
if (!spaceData) {
|
||||
|
||||
@@ -7,7 +7,6 @@ import {
|
||||
import { SpaceRepository } from '@app/common/modules/space/repositories';
|
||||
import { BadRequestException, NotFoundException } from '@nestjs/common';
|
||||
import { UserRepository } from '@app/common/modules/user/repositories';
|
||||
import { SpaceType } from '@app/common/constants/space-type.enum';
|
||||
|
||||
@Injectable()
|
||||
export class CheckUserCommunityGuard implements CanActivate {
|
||||
@@ -44,8 +43,7 @@ export class CheckUserCommunityGuard implements CanActivate {
|
||||
|
||||
private async checkCommunityIsFound(spaceUuid: string) {
|
||||
const spaceData = await this.spaceRepository.findOne({
|
||||
where: { uuid: spaceUuid, spaceType: { type: SpaceType.COMMUNITY } },
|
||||
relations: ['spaceType'],
|
||||
where: { uuid: spaceUuid },
|
||||
});
|
||||
if (!spaceData) {
|
||||
throw new NotFoundException('Community not found');
|
||||
|
||||
@@ -44,8 +44,7 @@ export class CheckUserFloorGuard implements CanActivate {
|
||||
|
||||
private async checkFloorIsFound(spaceUuid: string) {
|
||||
const spaceData = await this.spaceRepository.findOne({
|
||||
where: { uuid: spaceUuid, spaceType: { type: SpaceType.FLOOR } },
|
||||
relations: ['spaceType'],
|
||||
where: { uuid: spaceUuid },
|
||||
});
|
||||
if (!spaceData) {
|
||||
throw new NotFoundException('Floor not found');
|
||||
|
||||
@@ -7,7 +7,6 @@ import {
|
||||
import { SpaceRepository } from '@app/common/modules/space/repositories';
|
||||
import { BadRequestException, NotFoundException } from '@nestjs/common';
|
||||
import { UserRepository } from '@app/common/modules/user/repositories';
|
||||
import { SpaceType } from '@app/common/constants/space-type.enum';
|
||||
|
||||
@Injectable()
|
||||
export class CheckUserRoomGuard implements CanActivate {
|
||||
@@ -44,7 +43,7 @@ export class CheckUserRoomGuard implements CanActivate {
|
||||
|
||||
private async checkRoomIsFound(spaceUuid: string) {
|
||||
const spaceData = await this.spaceRepository.findOne({
|
||||
where: { uuid: spaceUuid, spaceType: { type: SpaceType.ROOM } },
|
||||
where: { uuid: spaceUuid },
|
||||
relations: ['spaceType'],
|
||||
});
|
||||
if (!spaceData) {
|
||||
|
||||
@@ -7,7 +7,6 @@ import {
|
||||
import { SpaceRepository } from '@app/common/modules/space/repositories';
|
||||
import { BadRequestException, NotFoundException } from '@nestjs/common';
|
||||
import { UserRepository } from '@app/common/modules/user/repositories';
|
||||
import { SpaceType } from '@app/common/constants/space-type.enum';
|
||||
|
||||
@Injectable()
|
||||
export class CheckUserUnitGuard implements CanActivate {
|
||||
@@ -44,7 +43,7 @@ export class CheckUserUnitGuard implements CanActivate {
|
||||
|
||||
private async checkUnitIsFound(spaceUuid: string) {
|
||||
const spaceData = await this.spaceRepository.findOne({
|
||||
where: { uuid: spaceUuid, spaceType: { type: SpaceType.UNIT } },
|
||||
where: { uuid: spaceUuid },
|
||||
relations: ['spaceType'],
|
||||
});
|
||||
if (!spaceData) {
|
||||
|
||||
Reference in New Issue
Block a user