mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-11-26 00:24:54 +00:00
feat: seed default task logos
This commit is contained in:
@ -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)));
|
||||
}
|
||||
}
|
||||
|
||||
41
src/db/migrations/1733990253208-seeds-default-tasks-logo.ts
Normal file
41
src/db/migrations/1733990253208-seeds-default-tasks-logo.ts
Normal file
@ -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<void> {
|
||||
await queryRunner.manager.getRepository(Document).save(DEFAULT_TASK_LOGOS);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await DEFAULT_TASK_LOGOS.forEach(async (logo) => {
|
||||
await queryRunner.manager.getRepository(Document).delete({ name: logo.name, documentType: logo.documentType });
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -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';
|
||||
|
||||
@ -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'],
|
||||
|
||||
Reference in New Issue
Block a user