From e614890d87d4af277ebc83e675f199383bc8a374 Mon Sep 17 00:00:00 2001 From: Rinaldy Adin <16521390@mahasiswa.itb.ac.id> Date: Sun, 21 Apr 2024 12:44:36 +0700 Subject: [PATCH] feat: clear todos --- .../alokasi-ruangan.controller.ts | 1 - src/alokasi-ruangan/alokasi-ruangan.dto.ts | 4 +++- src/alokasi-ruangan/alokasi-ruangan.service.ts | 17 ++++++++++++----- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/alokasi-ruangan/alokasi-ruangan.controller.ts b/src/alokasi-ruangan/alokasi-ruangan.controller.ts index f368ac4..1994fd4 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 8eb18ca..94d819b 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 ea48604..93cd452 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 { -- GitLab