diff --git a/src/alokasi-ruangan/alokasi-ruangan.controller.ts b/src/alokasi-ruangan/alokasi-ruangan.controller.ts index f368ac433d1b59c803d997efcd5c588454006386..1994fd435d23c13bf931d45fdd02a01344096301 100644 --- a/src/alokasi-ruangan/alokasi-ruangan.controller.ts +++ b/src/alokasi-ruangan/alokasi-ruangan.controller.ts @@ -26,7 +26,6 @@ import { } from "./alokasi-ruangan.dto"; import { AlokasiRuanganService } from "./alokasi-ruangan.service"; -// TODO test if role guard works @ApiTags("Alokasi Ruangan") @ApiBearerAuth() @ApiCookieAuth() diff --git a/src/alokasi-ruangan/alokasi-ruangan.dto.ts b/src/alokasi-ruangan/alokasi-ruangan.dto.ts index 8eb18ca1406db3ec86131bf9a11f2d86f9f36bee..94d819b7fb4360abc1532d74a0acb874d7a05d50 100644 --- a/src/alokasi-ruangan/alokasi-ruangan.dto.ts +++ b/src/alokasi-ruangan/alokasi-ruangan.dto.ts @@ -69,8 +69,10 @@ export class GetOnePengajuanSidangRespDto extends GetAllPengajuanSidangItemDto { } export class UpdateAlokasiRuanganReqDto { - @ApiProperty() @IsString() + @ApiProperty({ + description: "Can send empty string, will update DB to set as null", + }) ruangan: string; } diff --git a/src/alokasi-ruangan/alokasi-ruangan.service.ts b/src/alokasi-ruangan/alokasi-ruangan.service.ts index ea48604280274c003920576632a377a5e618f2b6..93cd45279dd966867a1d38dfd9353a7efe8ddfba 100644 --- a/src/alokasi-ruangan/alokasi-ruangan.service.ts +++ b/src/alokasi-ruangan/alokasi-ruangan.service.ts @@ -3,7 +3,7 @@ import { InjectRepository } from "@nestjs/typeorm"; import { DosenBimbingan } from "src/entities/dosenBimbingan.entity"; import { PendaftaranSidsem } from "src/entities/pendaftaranSidsem"; import { PengujiSidsem } from "src/entities/pengujiSidsem.entity"; -import { Like, Repository } from "typeorm"; +import { IsNull, Like, Repository } from "typeorm"; import { GetAllPengajuanSidangItemDto, GetAllPengajuanSidangReqQueryDto, @@ -33,6 +33,7 @@ export class AlokasiRuanganService { id: true, waktuMulai: true, tipe: true, + lulus: true, ruangan: true, pendaftaranTesis: { id: true, @@ -51,6 +52,7 @@ export class AlokasiRuanganService { skip: (query.page - 1) * query.limit || undefined, where: { tipe: query.jenisSidang, + lulus: IsNull(), pendaftaranTesis: { mahasiswa: [ { nim: Like(`%${query.search ?? ""}%`) }, @@ -73,7 +75,6 @@ export class AlokasiRuanganService { } async findOne(id: string): Promise<GetOnePengajuanSidangRespDto> { - // TODO handle errors const sidsemQueryData = await this.pendaftaranSidsemRepo.findOne({ select: { id: true, @@ -105,6 +106,11 @@ export class AlokasiRuanganService { }, }); + if (sidsemQueryData === null) + throw new BadRequestException( + "Pendaftaran sidang with given id does not exist", + ); + const pengujiQueryData = await this.pengujiSidsemRepo.find({ select: { dosen: { @@ -139,7 +145,6 @@ export class AlokasiRuanganService { idPengajuanSidsem: sidsemQueryData.id, nimMahasiswa: sidsemQueryData.pendaftaranTesis.mahasiswa.nim, namaMahasiswa: sidsemQueryData.pendaftaranTesis.mahasiswa.nama, - // TODO jadwal sidang pake column apa jadwalSidang: sidsemQueryData.waktuMulai.toISOString(), jenisSidang: sidsemQueryData.tipe, ruangan: sidsemQueryData.ruangan, @@ -154,7 +159,6 @@ export class AlokasiRuanganService { return data; } - // TODO bisa set lagi ke null atau tidak? async update( id: string, updateAlokasiRuanganDto: UpdateAlokasiRuanganReqDto, @@ -187,7 +191,10 @@ export class AlokasiRuanganService { "Pendaftaran sidang/seminar with diven id does not exist", ); - pendaftaranSidsem.ruangan = updateAlokasiRuanganDto.ruangan; + pendaftaranSidsem.ruangan = + updateAlokasiRuanganDto.ruangan === "" + ? null + : updateAlokasiRuanganDto.ruangan; await this.pendaftaranSidsemRepo.save(pendaftaranSidsem); return {