From 82d18f763765af3219563791df850e9e54d2d229 Mon Sep 17 00:00:00 2001 From: NotHydra Date: Fri, 9 Feb 2024 13:58:54 +0800 Subject: [PATCH] fix: #17 --- apps/api/src/app.module.ts | 12 ++++++- .../src/model/feedback/feedback.controller.ts | 31 +++++++++++++++++++ .../api/src/model/feedback/feedback.module.ts | 12 +++++++ apps/api/src/model/feedback/feedback.rest | 22 +++++++++++++ 4 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 apps/api/src/model/feedback/feedback.controller.ts create mode 100644 apps/api/src/model/feedback/feedback.module.ts create mode 100644 apps/api/src/model/feedback/feedback.rest diff --git a/apps/api/src/app.module.ts b/apps/api/src/app.module.ts index fe557f9..e8b1e83 100644 --- a/apps/api/src/app.module.ts +++ b/apps/api/src/app.module.ts @@ -8,8 +8,18 @@ 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"; +import { FeedbackModule } from "./model/feedback/feedback.module"; @Module({ - imports: [ConfigModule, UserModule, TrashBinModule, SubTrashBinModule, TrashModule, HistoryModule, ReportModule], + imports: [ + ConfigModule, + UserModule, + TrashBinModule, + SubTrashBinModule, + TrashModule, + HistoryModule, + ReportModule, + FeedbackModule, + ], }) export class AppModule {} diff --git a/apps/api/src/model/feedback/feedback.controller.ts b/apps/api/src/model/feedback/feedback.controller.ts new file mode 100644 index 0000000..5ba24c5 --- /dev/null +++ b/apps/api/src/model/feedback/feedback.controller.ts @@ -0,0 +1,31 @@ +import { Body, Controller, ForbiddenException, Param, ParseIntPipe, UseInterceptors } from "@nestjs/common"; +import { FeedbackCreateDTO, FeedbackModel, FeedbackUpdateDTO, ResponseFormatInterface } from "@trashtrack/common"; + +import { ResponseFormatInterceptor } from "../../interceptor/response-format.interceptor"; + +import { BaseController } from "../base.controller"; + +import { FeedbackService } from "./feedback.service"; + +interface FeedbackControllerInterface {} + +@Controller("feedback") +@UseInterceptors(ResponseFormatInterceptor) +export class FeedbackController + extends BaseController + implements FeedbackControllerInterface +{ + constructor(modelService: FeedbackService) { + super(FeedbackController.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: FeedbackUpdateDTO + ): Promise> { + this.loggerService.error(`Change: Method Is Disabled`); + throw new ForbiddenException("Method Is Disabled"); + } +} diff --git a/apps/api/src/model/feedback/feedback.module.ts b/apps/api/src/model/feedback/feedback.module.ts new file mode 100644 index 0000000..4863a66 --- /dev/null +++ b/apps/api/src/model/feedback/feedback.module.ts @@ -0,0 +1,12 @@ +import { Module } from "@nestjs/common"; + +import { PrismaService } from "../../provider/prisma.service"; + +import { FeedbackController } from "./feedback.controller"; +import { FeedbackService } from "./feedback.service"; + +@Module({ + controllers: [FeedbackController], + providers: [PrismaService, FeedbackService], +}) +export class FeedbackModule {} diff --git a/apps/api/src/model/feedback/feedback.rest b/apps/api/src/model/feedback/feedback.rest new file mode 100644 index 0000000..7b175db --- /dev/null +++ b/apps/api/src/model/feedback/feedback.rest @@ -0,0 +1,22 @@ +GET http://localhost:3001/api/feedback + +### + +GET http://localhost:3001/api/feedback/id/1 + +### + +POST http://localhost:3001/api/feedback +Content-Type: application/json + +{ + "reportId": 1, + "title": "First Response", + "description": "First Description" +} + +### + +DELETE http://localhost:3001/api/feedback/1 + +### \ No newline at end of file