From 603632b6af5edb01b774fc8cafb277de4607930a Mon Sep 17 00:00:00 2001 From: Firman Ramdhani <33869609+firmanramdhani@users.noreply.github.com> Date: Wed, 3 Jul 2024 12:20:48 +0700 Subject: [PATCH] feat: setup api for get label history on bookmark --- .../report-bookmark.controller.ts | 23 ++++++++++---- .../report-bookmark.service.ts | 31 ++++++++++++++++++- .../report-export/report-export.controller.ts | 13 +++++--- .../report-export/report-export.service.ts | 28 ++++++++++++++++- src/modules/reports/report/report.service.ts | 4 +-- .../shared/dto/report-bookmark.create.dto.ts | 8 +++-- .../shared/dto/report-bookmark.get.dto.ts | 20 ++++++++++++ 7 files changed, 110 insertions(+), 17 deletions(-) diff --git a/src/modules/reports/report-bookmark/report-bookmark.controller.ts b/src/modules/reports/report-bookmark/report-bookmark.controller.ts index 20e8111..08df759 100644 --- a/src/modules/reports/report-bookmark/report-bookmark.controller.ts +++ b/src/modules/reports/report-bookmark/report-bookmark.controller.ts @@ -11,36 +11,47 @@ import { import { ApiBearerAuth, ApiTags } from '@nestjs/swagger'; import { Public } from 'src/core/guards'; import { MODULE_NAME } from 'src/core/strings/constants/module.constants'; -import { GetReportBookmarkDto } from '../shared/dto/report-bookmark.get.dto'; +import { + GetLabelReportBookmarkDto, + GetReportBookmarkDto, +} from '../shared/dto/report-bookmark.get.dto'; import { CreateReportBookmarkDto } from '../shared/dto/report-bookmark.create.dto'; +import { ReportBookmarkService } from './report-bookmark.service'; @ApiTags(`${MODULE_NAME.REPORT_BOOKMARK.split('-').join(' ')}`) @Controller(`v1/${MODULE_NAME.REPORT_BOOKMARK}`) @Public(false) @ApiBearerAuth('JWT') export class ReportBookmarkController { + constructor(private service: ReportBookmarkService) {} + @Post() async create(@Body() body: CreateReportBookmarkDto) { - return; + return await this.service.create(body); } @Get() async getAll(@Query() query: GetReportBookmarkDto) { - return; + return await this.service.getAll(query); + } + + @Get('label-history') + async getAllLabelHistory(@Query() query: GetLabelReportBookmarkDto) { + return await this.service.getAllLabelHistory(query); } @Put('applied/:id') async applied(@Param('id') id: string) { - return; + return await this.service.applied(id); } @Put('unapplied/:id') async unapplied(@Param('id') id: string) { - return; + return await this.service.unapplied(id); } @Delete(':id') async delete(@Param('id') id: string) { - return; + return await this.service.delete(id); } } diff --git a/src/modules/reports/report-bookmark/report-bookmark.service.ts b/src/modules/reports/report-bookmark/report-bookmark.service.ts index 8dc3e05..4f76e2b 100644 --- a/src/modules/reports/report-bookmark/report-bookmark.service.ts +++ b/src/modules/reports/report-bookmark/report-bookmark.service.ts @@ -1,5 +1,34 @@ import { Injectable } from '@nestjs/common'; import { BaseReportService } from '../shared/services/base-report.service'; +import { CreateReportBookmarkDto } from '../shared/dto/report-bookmark.create.dto'; +import { + GetLabelReportBookmarkDto, + GetReportBookmarkDto, +} from '../shared/dto/report-bookmark.get.dto'; @Injectable() -export class ReportBookmarkService extends BaseReportService {} +export class ReportBookmarkService extends BaseReportService { + async create(body: CreateReportBookmarkDto) { + return 'you hit API for create report bookmark'; + } + + async getAll(query: GetReportBookmarkDto) { + return 'you hit API for get all report bookmark'; + } + + async getAllLabelHistory(query: GetLabelReportBookmarkDto) { + return 'you hit API for get all label history report bookmark'; + } + + async applied(id: string) { + return 'you hit API for applied report bookmark'; + } + + async unapplied(id: string) { + return 'you hit API for unapplied report bookmark'; + } + + async delete(id: string) { + return 'you hit API for delete report bookmark'; + } +} diff --git a/src/modules/reports/report-export/report-export.controller.ts b/src/modules/reports/report-export/report-export.controller.ts index f3bf3f7..c18a5a3 100644 --- a/src/modules/reports/report-export/report-export.controller.ts +++ b/src/modules/reports/report-export/report-export.controller.ts @@ -17,34 +17,37 @@ import { GetReportExportFileNameDto, GetReportExportProcessingDto, } from '../shared/dto/report-export.get.dto'; +import { ReportExportService } from './report-export.service'; @ApiTags(`${MODULE_NAME.REPORT_EXPORT.split('-').join(' ')}`) @Controller(`v1/${MODULE_NAME.REPORT_EXPORT}`) @Public(false) @ApiBearerAuth('JWT') export class ReportExportController { + constructor(private service: ReportExportService) {} + @Post() async create(@Body() body: CreateReportExportDto) { - return; + return await this.service.create(body); } @Get() async getAll(@Query() query: GetReportExportDto) { - return; + return await this.service.getAll(query); } @Delete(':id') async delete(@Param('id') id: string) { - return; + return await this.service.delete(id); } @Get('processing') async getAllProcessing(@Query() query: GetReportExportProcessingDto) { - return; + return await this.service.getAllProcessing(query); } @Get('filename-history') async getListHistoryFileName(@Query() query: GetReportExportFileNameDto) { - return; + return await this.service.getListHistoryFileName(query); } } diff --git a/src/modules/reports/report-export/report-export.service.ts b/src/modules/reports/report-export/report-export.service.ts index 223f1c4..c5b6322 100644 --- a/src/modules/reports/report-export/report-export.service.ts +++ b/src/modules/reports/report-export/report-export.service.ts @@ -1,5 +1,31 @@ import { Injectable } from '@nestjs/common'; import { BaseReportService } from '../shared/services/base-report.service'; +import { CreateReportExportDto } from '../shared/dto/report-export.create.dto'; +import { + GetReportExportDto, + GetReportExportFileNameDto, + GetReportExportProcessingDto, +} from '../shared/dto/report-export.get.dto'; @Injectable() -export class ReportExportService extends BaseReportService {} +export class ReportExportService extends BaseReportService { + async create(body: CreateReportExportDto) { + return 'you hit API for create report export'; + } + + async getAll(query: GetReportExportDto) { + return 'you hit API for get all report export'; + } + + async delete(id: string) { + return 'you hit API for delete report export'; + } + + async getAllProcessing(query: GetReportExportProcessingDto) { + return 'you hit API for get all processing report export'; + } + + async getListHistoryFileName(query: GetReportExportFileNameDto) { + return 'you hit API for get all file name report export'; + } +} diff --git a/src/modules/reports/report/report.service.ts b/src/modules/reports/report/report.service.ts index a251f38..390737d 100644 --- a/src/modules/reports/report/report.service.ts +++ b/src/modules/reports/report/report.service.ts @@ -6,10 +6,10 @@ import { GetReportDataDto } from '../shared/dto/report-data.get.dto'; @Injectable() export class ReportService extends BaseReportService { async getReportConfig(query: GetReportConfigDto) { - return this.getUser(); + return 'you hit API for get report config'; } async getReportData(body: GetReportDataDto) { - return this.getUser(); + return 'you hit API for get report data'; } } diff --git a/src/modules/reports/shared/dto/report-bookmark.create.dto.ts b/src/modules/reports/shared/dto/report-bookmark.create.dto.ts index b4db379..2279e8b 100644 --- a/src/modules/reports/shared/dto/report-bookmark.create.dto.ts +++ b/src/modules/reports/shared/dto/report-bookmark.create.dto.ts @@ -19,8 +19,12 @@ export class CreateReportBookmarkDto { @IsBoolean() applied: boolean; - @ApiProperty({ name: 'type', required: true }) - @IsBoolean() + @ApiProperty({ + name: 'type', + required: true, + default: REPORT_BOOKMARK_TYPE.TABLE_CONFIG, + }) + @IsString() type: REPORT_BOOKMARK_TYPE; @ApiProperty({ diff --git a/src/modules/reports/shared/dto/report-bookmark.get.dto.ts b/src/modules/reports/shared/dto/report-bookmark.get.dto.ts index c325336..b3d8ba2 100644 --- a/src/modules/reports/shared/dto/report-bookmark.get.dto.ts +++ b/src/modules/reports/shared/dto/report-bookmark.get.dto.ts @@ -21,3 +21,23 @@ export class GetReportBookmarkDto { }) types?: REPORT_BOOKMARK_TYPE[]; } + +export class GetLabelReportBookmarkDto { + @ApiProperty({ type: ['string'], required: false }) + @Transform((body) => { + return Array.isArray(body.value) ? body.value : [body.value]; + }) + group_names?: string; + + @ApiProperty({ type: ['string'], required: false }) + @Transform((body) => { + return Array.isArray(body.value) ? body.value : [body.value]; + }) + unique_names?: string[]; + + @ApiProperty({ type: ['string'], required: false }) + @Transform((body) => { + return Array.isArray(body.value) ? body.value : [body.value]; + }) + types?: REPORT_BOOKMARK_TYPE[]; +}