diff --git a/src/common/modules/lookup/controllers/lookup.controller.ts b/src/common/modules/lookup/controllers/lookup.controller.ts index 2916ab2..904c20d 100644 --- a/src/common/modules/lookup/controllers/lookup.controller.ts +++ b/src/common/modules/lookup/controllers/lookup.controller.ts @@ -20,4 +20,13 @@ export class LookupController { return ResponseFactory.dataArray(avatars.map((avatar) => new DocumentMetaResponseDto(avatar))); } + + @UseGuards(AccessTokenGuard) + @Get('default-task-logos') + @ApiDataArrayResponse(DocumentMetaResponseDto) + async findDefaultTaskLogos() { + const avatars = await this.lookupService.findDefaultTasksLogo(); + + return ResponseFactory.dataArray(avatars.map((avatar) => new DocumentMetaResponseDto(avatar))); + } } diff --git a/src/db/migrations/1733990253208-seeds-default-tasks-logo.ts b/src/db/migrations/1733990253208-seeds-default-tasks-logo.ts new file mode 100644 index 0000000..ea02a1c --- /dev/null +++ b/src/db/migrations/1733990253208-seeds-default-tasks-logo.ts @@ -0,0 +1,41 @@ +import { MigrationInterface, QueryRunner } from 'typeorm'; +import { v4 as uuid } from 'uuid'; +import { Document } from '~/document/entities'; +import { DocumentType } from '~/document/enums'; +const DEFAULT_TASK_LOGOS = [ + { + id: uuid(), + name: 'bed-furniture', + extension: '.jpg', + documentType: DocumentType.DEFAULT_TASKS_LOGO, + }, + { + id: uuid(), + name: 'dog', + extension: '.jpg', + documentType: DocumentType.DEFAULT_TASKS_LOGO, + }, + { + id: uuid(), + name: 'dish-washing', + extension: '.jpg', + documentType: DocumentType.DEFAULT_TASKS_LOGO, + }, + { + id: uuid(), + name: 'walking-the-dog', + extension: '.jpg', + documentType: DocumentType.DEFAULT_TASKS_LOGO, + }, +]; +export class SeedsDefaultTasksLogo1733990253208 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.manager.getRepository(Document).save(DEFAULT_TASK_LOGOS); + } + + public async down(queryRunner: QueryRunner): Promise { + await DEFAULT_TASK_LOGOS.forEach(async (logo) => { + await queryRunner.manager.getRepository(Document).delete({ name: logo.name, documentType: logo.documentType }); + }); + } +} diff --git a/src/db/migrations/index.ts b/src/db/migrations/index.ts index fca9ad4..b250ac9 100644 --- a/src/db/migrations/index.ts +++ b/src/db/migrations/index.ts @@ -9,3 +9,4 @@ export * from './1733732021622-create-guardian-entity'; export * from './1733748083604-create-theme-entity'; export * from './1733750228289-seed-default-avatar'; export * from './1733904556416-create-task-entities'; +export * from './1733990253208-seeds-default-tasks-logo'; diff --git a/src/document/controllers/document.controller.ts b/src/document/controllers/document.controller.ts index f6502c7..ac7442a 100644 --- a/src/document/controllers/document.controller.ts +++ b/src/document/controllers/document.controller.ts @@ -24,7 +24,9 @@ export class DocumentController { }, documentType: { type: 'string', - enum: Object.values(DocumentType), + enum: Object.values(DocumentType).filter( + (value) => ![DocumentType.DEFAULT_AVATAR, DocumentType.DEFAULT_TASKS_LOGO].includes(value), + ), }, }, required: ['document', 'documentType'],