Skip to content
This repository has been archived by the owner on Aug 23, 2024. It is now read-only.

Commit

Permalink
feat: report module #16
Browse files Browse the repository at this point in the history
  • Loading branch information
NotHydra committed Feb 9, 2024
1 parent 6e92a48 commit ee56553
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 1 deletion.
3 changes: 2 additions & 1 deletion apps/api/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
31 changes: 31 additions & 0 deletions apps/api/src/model/report/report.controller.ts
Original file line number Diff line number Diff line change
@@ -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<ReportModel, ReportCreateDTO, ReportUpdateDTO, ReportService>
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<ResponseFormatInterface<ReportModel>> {
this.loggerService.error(`Change: Method Is Disabled`);
throw new ForbiddenException("Method Is Disabled");
}
}
12 changes: 12 additions & 0 deletions apps/api/src/model/report/report.module.ts
Original file line number Diff line number Diff line change
@@ -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 {}
46 changes: 46 additions & 0 deletions apps/api/src/model/report/report.rest
Original file line number Diff line number Diff line change
@@ -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

###

0 comments on commit ee56553

Please sign in to comment.