From ee565534bc3ffcfdd61d8736e5c291d6c84e7ca5 Mon Sep 17 00:00:00 2001 From: NotHydra Date: Fri, 9 Feb 2024 12:28:48 +0800 Subject: [PATCH] feat: report module #16 --- apps/api/src/app.module.ts | 3 +- .../api/src/model/report/report.controller.ts | 31 +++++++++++++ apps/api/src/model/report/report.module.ts | 12 +++++ apps/api/src/model/report/report.rest | 46 +++++++++++++++++++ 4 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 apps/api/src/model/report/report.controller.ts create mode 100644 apps/api/src/model/report/report.module.ts create mode 100644 apps/api/src/model/report/report.rest diff --git a/apps/api/src/app.module.ts b/apps/api/src/app.module.ts index e9c7b2d..fe557f9 100644 --- a/apps/api/src/app.module.ts +++ b/apps/api/src/app.module.ts @@ -7,8 +7,9 @@ import { TrashBinModule } from "./model/trash-bin/trash-bin.module"; import { SubTrashBinModule } from "./model/sub-trash-bin/sub-trash-bin.module"; import { TrashModule } from "./model/trash/trash.module"; import { HistoryModule } from "./model/history/history.module"; +import { ReportModule } from "./model/report/report.module"; @Module({ - imports: [ConfigModule, UserModule, TrashBinModule, SubTrashBinModule, TrashModule, HistoryModule], + imports: [ConfigModule, UserModule, TrashBinModule, SubTrashBinModule, TrashModule, HistoryModule, ReportModule], }) export class AppModule {} diff --git a/apps/api/src/model/report/report.controller.ts b/apps/api/src/model/report/report.controller.ts new file mode 100644 index 0000000..06dd00d --- /dev/null +++ b/apps/api/src/model/report/report.controller.ts @@ -0,0 +1,31 @@ +import { Body, Controller, ForbiddenException, Param, ParseIntPipe, UseInterceptors } from "@nestjs/common"; +import { ReportCreateDTO, ReportModel, ReportUpdateDTO, ResponseFormatInterface } from "@trashtrack/common"; + +import { ResponseFormatInterceptor } from "../../interceptor/response-format.interceptor"; + +import { ExtendController } from "../extend.controller"; + +import { ReportService } from "./report.service"; + +interface ReportControllerInterface {} + +@Controller("report") +@UseInterceptors(ResponseFormatInterceptor) +export class ReportController + extends ExtendController + implements ReportControllerInterface +{ + constructor(modelService: ReportService) { + super(ReportController.name, modelService); + } + + public async change( + // eslint-disable-next-line @typescript-eslint/no-unused-vars + @Param("id", ParseIntPipe) id: number, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + @Body() payload: ReportUpdateDTO + ): Promise> { + this.loggerService.error(`Change: Method Is Disabled`); + throw new ForbiddenException("Method Is Disabled"); + } +} diff --git a/apps/api/src/model/report/report.module.ts b/apps/api/src/model/report/report.module.ts new file mode 100644 index 0000000..78f2691 --- /dev/null +++ b/apps/api/src/model/report/report.module.ts @@ -0,0 +1,12 @@ +import { Module } from "@nestjs/common"; + +import { PrismaService } from "../../provider/prisma.service"; + +import { ReportController } from "./report.controller"; +import { ReportService } from "./report.service"; + +@Module({ + controllers: [ReportController], + providers: [PrismaService, ReportService], +}) +export class ReportModule {} diff --git a/apps/api/src/model/report/report.rest b/apps/api/src/model/report/report.rest new file mode 100644 index 0000000..64b7ae0 --- /dev/null +++ b/apps/api/src/model/report/report.rest @@ -0,0 +1,46 @@ +GET http://localhost:3001/api/report +Content-Type: application/json + +### + +GET http://localhost:3001/api/report/id/1 +Content-Type: application/json + +### + +GET http://localhost:3001/api/report/extend +Content-Type: application/json + +### + +GET http://localhost:3001/api/report/id/2/extend +Content-Type: application/json + +### + +POST http://localhost:3001/api/report +Content-Type: application/json + +{ + "trashBinId": 2, + "nik": "64711092301923", + "name": "Budi Santoso", + "phoneNumber": "6281234567891", + "imagePath": "imagepath1", + "description": "Tempat sampah rusak" +} + +### + +PUT http://localhost:3001/api/report/2/status +Content-Type: application/json + +{ + "status": 1 +} + +### + +DELETE http://localhost:3001/api/report/1 + +### \ No newline at end of file