diff --git a/luna-backend/src/application/business/(spec)/ambientes/bloco/(dtos)/bloco-find-one/IBlocoFindOneResultDto.ts b/luna-backend/src/application/business/(spec)/ambientes/bloco/(dtos)/bloco-find-one/IBlocoFindOneResultDto.ts index 6ef05f3f..58dc576f 100644 --- a/luna-backend/src/application/business/(spec)/ambientes/bloco/(dtos)/bloco-find-one/IBlocoFindOneResultDto.ts +++ b/luna-backend/src/application/business/(spec)/ambientes/bloco/(dtos)/bloco-find-one/IBlocoFindOneResultDto.ts @@ -1,6 +1,8 @@ +import { IImagemFindOneResultDto } from '../../../../base/imagem/operations'; import { ICampusFindOneResultDto } from '../../../campus'; import { IBlocoModel } from '../../IBlocoModel'; export interface IBlocoFindOneResultDto extends Pick<IBlocoModel, 'id' | 'nome' | 'codigo'> { campus: ICampusFindOneResultDto; + imagemCapa: IImagemFindOneResultDto | null; } diff --git a/luna-backend/src/application/business/(spec)/ambientes/bloco/IBlocoModel.ts b/luna-backend/src/application/business/(spec)/ambientes/bloco/IBlocoModel.ts index bf0be59a..c0950b35 100644 --- a/luna-backend/src/application/business/(spec)/ambientes/bloco/IBlocoModel.ts +++ b/luna-backend/src/application/business/(spec)/ambientes/bloco/IBlocoModel.ts @@ -1,5 +1,6 @@ import { IAmbienteModel } from '..'; import { IDatedObject, IEntityDate, IObjectUuid } from '../../(core)'; +import { IImagemModel } from '../../base/imagem'; import { ICampusModel } from '../campus'; export interface IBlocoModel extends IObjectUuid, IDatedObject { @@ -19,6 +20,7 @@ export interface IBlocoModel extends IObjectUuid, IDatedObject { // ambientes: IAmbienteModel[]; + imagemCapa: IImagemModel | null; // ================================= diff --git a/luna-backend/src/application/business/(spec)/base/imagem-arquivo/IImagemArquivoModel.ts b/luna-backend/src/application/business/(spec)/base/imagem-arquivo/IImagemArquivoModel.ts new file mode 100644 index 00000000..e1408b9b --- /dev/null +++ b/luna-backend/src/application/business/(spec)/base/imagem-arquivo/IImagemArquivoModel.ts @@ -0,0 +1,21 @@ +import * as Dto from 'application/business/(spec)'; + +export interface IImagemArquivoModel extends Dto.IObjectUuid { + id: string; + + // + + largura: number; + altura: number; + formato: string; + mimeType: string; + + imagem: Dto.IImagemModel; + arquivo: Dto.IArquivoModel; + + // + + dateCreated: Dto.IEntityDate; + // dateUpdated: Dto.IEntityDate; + // dateDeleted: null | Dto.IEntityDate; +} diff --git a/luna-backend/src/application/business/(spec)/base/imagem-arquivo/index.ts b/luna-backend/src/application/business/(spec)/base/imagem-arquivo/index.ts new file mode 100644 index 00000000..9c9184f3 --- /dev/null +++ b/luna-backend/src/application/business/(spec)/base/imagem-arquivo/index.ts @@ -0,0 +1 @@ +export * from './IImagemArquivoModel'; diff --git a/luna-backend/src/application/business/(spec)/base/imagem-arquivo/operations/imagem-arquivo-find-one/IImagemArquivoFindOneResultDto.ts b/luna-backend/src/application/business/(spec)/base/imagem-arquivo/operations/imagem-arquivo-find-one/IImagemArquivoFindOneResultDto.ts new file mode 100644 index 00000000..2b38ff2d --- /dev/null +++ b/luna-backend/src/application/business/(spec)/base/imagem-arquivo/operations/imagem-arquivo-find-one/IImagemArquivoFindOneResultDto.ts @@ -0,0 +1,8 @@ +import * as Dto from 'application/business/(spec)'; +import { IArquivoFindOneResultDto } from '../../../arquivo/operations'; +import { IImagemArquivoModel } from '../../IImagemArquivoModel'; + +export interface IImagemArquivoFindOneResultDto extends Pick<IImagemArquivoModel, 'id' | 'largura' | 'altura' | 'formato' | 'mimeType'> { + imagem: Dto.IObjectUuid; + arquivo: IArquivoFindOneResultDto; +} diff --git a/luna-backend/src/application/business/(spec)/base/imagem-arquivo/operations/imagem-arquivo-find-one/index.ts b/luna-backend/src/application/business/(spec)/base/imagem-arquivo/operations/imagem-arquivo-find-one/index.ts new file mode 100644 index 00000000..961a80dd --- /dev/null +++ b/luna-backend/src/application/business/(spec)/base/imagem-arquivo/operations/imagem-arquivo-find-one/index.ts @@ -0,0 +1 @@ +export * from './IImagemArquivoFindOneResultDto'; diff --git a/luna-backend/src/application/business/(spec)/base/imagem-arquivo/operations/index.ts b/luna-backend/src/application/business/(spec)/base/imagem-arquivo/operations/index.ts new file mode 100644 index 00000000..f361b5cc --- /dev/null +++ b/luna-backend/src/application/business/(spec)/base/imagem-arquivo/operations/index.ts @@ -0,0 +1 @@ +export * from './imagem-arquivo-find-one'; diff --git a/luna-backend/src/application/business/(spec)/base/imagem/IImagemModel.ts b/luna-backend/src/application/business/(spec)/base/imagem/IImagemModel.ts new file mode 100644 index 00000000..e29e76db --- /dev/null +++ b/luna-backend/src/application/business/(spec)/base/imagem/IImagemModel.ts @@ -0,0 +1,17 @@ +import * as Dto from 'application/business/(spec)'; +import { IImagemArquivoModel } from '../imagem-arquivo'; + +export interface IImagemModel extends Dto.IObjectUuid, Dto.IDatedObject { + id: string; + + // + + descricao: string | null; + imagemArquivo: IImagemArquivoModel[]; + + // + + dateCreated: Dto.IEntityDate; + dateUpdated: Dto.IEntityDate; + dateDeleted: null | Dto.IEntityDate; +} diff --git a/luna-backend/src/application/business/(spec)/base/imagem/index.ts b/luna-backend/src/application/business/(spec)/base/imagem/index.ts new file mode 100644 index 00000000..2804c849 --- /dev/null +++ b/luna-backend/src/application/business/(spec)/base/imagem/index.ts @@ -0,0 +1 @@ +export * from './IImagemModel'; diff --git a/luna-backend/src/application/business/(spec)/base/imagem/operations/imagem-find-one/IImagemFindOneResultDto.ts b/luna-backend/src/application/business/(spec)/base/imagem/operations/imagem-find-one/IImagemFindOneResultDto.ts new file mode 100644 index 00000000..caa9fe6c --- /dev/null +++ b/luna-backend/src/application/business/(spec)/base/imagem/operations/imagem-find-one/IImagemFindOneResultDto.ts @@ -0,0 +1,6 @@ +import { IImagemArquivoFindOneResultDto } from '../../../imagem-arquivo/operations'; +import { IImagemModel } from '../../IImagemModel'; + +export interface IImagemFindOneResultDto extends Pick<IImagemModel, 'id' | 'descricao'> { + imagemArquivo: Omit<IImagemArquivoFindOneResultDto, 'imagem'>[]; +} diff --git a/luna-backend/src/application/business/(spec)/base/imagem/operations/imagem-find-one/index.ts b/luna-backend/src/application/business/(spec)/base/imagem/operations/imagem-find-one/index.ts new file mode 100644 index 00000000..988aa40c --- /dev/null +++ b/luna-backend/src/application/business/(spec)/base/imagem/operations/imagem-find-one/index.ts @@ -0,0 +1 @@ +export * from './IImagemFindOneResultDto'; diff --git a/luna-backend/src/application/business/(spec)/base/imagem/operations/index.ts b/luna-backend/src/application/business/(spec)/base/imagem/operations/index.ts new file mode 100644 index 00000000..380817c2 --- /dev/null +++ b/luna-backend/src/application/business/(spec)/base/imagem/operations/index.ts @@ -0,0 +1 @@ +export * from './imagem-find-one'; diff --git a/luna-backend/src/application/business/(spec)/base/index.ts b/luna-backend/src/application/business/(spec)/base/index.ts index fc37316b..97a41efc 100644 --- a/luna-backend/src/application/business/(spec)/base/index.ts +++ b/luna-backend/src/application/business/(spec)/base/index.ts @@ -1 +1,3 @@ export * from './arquivo'; +export * from './imagem'; +export * from './imagem-arquivo'; diff --git a/luna-backend/src/application/business/ambientes/bloco/bloco.controller.ts b/luna-backend/src/application/business/ambientes/bloco/bloco.controller.ts index cfd964dd..f4110085 100644 --- a/luna-backend/src/application/business/ambientes/bloco/bloco.controller.ts +++ b/luna-backend/src/application/business/ambientes/bloco/bloco.controller.ts @@ -43,6 +43,16 @@ export class BlocoController { return this.blocoService.blocoFindByIdStrict(contextoDeAcesso, { id }); } + @Get('/:id/imagem/capa') + @DtoOperationFindOne(BlocoOperations.BLOCO_GET_IMAGEM_CAPA) + async blocoGetImagemCapa( + @ContextoDeAcessoHttp() contextoDeAcesso: IContextoDeAcesso, + @HttpDtoParam(BlocoOperations.BLOCO_GET_IMAGEM_CAPA, 'id') + id: string, + ) { + return this.blocoService.blocoGetImagemCapa(contextoDeAcesso, id); + } + // @Post('/') diff --git a/luna-backend/src/application/business/ambientes/bloco/bloco.service.ts b/luna-backend/src/application/business/ambientes/bloco/bloco.service.ts index a7a17f51..9e7a0a9b 100644 --- a/luna-backend/src/application/business/ambientes/bloco/bloco.service.ts +++ b/luna-backend/src/application/business/ambientes/bloco/bloco.service.ts @@ -9,6 +9,7 @@ import { DatabaseContextService } from '../../../../infrastructure/integrate-dat import { BlocoEntity } from '../../../../infrastructure/integrate-database/typeorm/entities/ambientes/bloco.entity'; import { paginateConfig } from '../../../../infrastructure/utils/paginateConfig'; import { IQueryBuilderViewOptionsLoad, getQueryBuilderViewLoadMeta } from '../../../utils/QueryBuilderViewOptionsLoad'; +import { ArquivoService } from '../../base/arquivo/arquivo.service'; import { ImagemService } from '../../base/imagem/imagem.service'; import { CampusService, ICampusQueryBuilderViewOptions } from '../campus/campus.service'; @@ -31,6 +32,7 @@ export class BlocoService { private campusService: CampusService, private databaseContext: DatabaseContextService, private imagemService: ImagemService, + private arquivoService: ArquivoService, ) {} get blocoRepository() { @@ -137,14 +139,16 @@ export class BlocoService { return paginated; } - async blocoFindById(contextoDeAcesso: IContextoDeAcesso, dto: Dtos.IBlocoFindOneByIdInputDto): Promise<Dtos.IBlocoFindOneResultDto | null> { + async blocoFindById(contextoDeAcesso: IContextoDeAcesso | null, dto: Dtos.IBlocoFindOneByIdInputDto): Promise<Dtos.IBlocoFindOneResultDto | null> { // ========================================================= const qb = this.blocoRepository.createQueryBuilder(aliasBloco); // ========================================================= - await contextoDeAcesso.aplicarFiltro('bloco:find', qb, aliasBloco, null); + if (contextoDeAcesso) { + await contextoDeAcesso.aplicarFiltro('bloco:find', qb, aliasBloco, null); + } // ========================================================= @@ -167,7 +171,7 @@ export class BlocoService { return bloco; } - async blocoFindByIdStrict(contextoDeAcesso: IContextoDeAcesso, dto: Dtos.IBlocoFindOneByIdInputDto) { + async blocoFindByIdStrict(contextoDeAcesso: IContextoDeAcesso | null, dto: Dtos.IBlocoFindOneByIdInputDto) { const bloco = await this.blocoFindById(contextoDeAcesso, dto); if (!bloco) { @@ -229,6 +233,23 @@ export class BlocoService { // + async blocoGetImagemCapa(contextoDeAcesso: IContextoDeAcesso | null, id: string) { + const bloco = await this.blocoFindByIdStrict(contextoDeAcesso, { id: id }); + + if (bloco.imagemCapa) { + const [imagemArquivo] = bloco.imagemCapa.imagemArquivo; + + if (imagemArquivo) { + const { arquivo } = imagemArquivo; + return this.arquivoService.getStreamableFile(null, arquivo.id, null); + } + } + + throw new NotFoundException(); + } + + // + async blocoCreate(contextoDeAcesso: IContextoDeAcesso, dto: Dtos.IBlocoInputDto) { // ========================================================= diff --git a/luna-backend/src/application/business/ambientes/bloco/dtos/bloco-find-one.operation.ts b/luna-backend/src/application/business/ambientes/bloco/dtos/bloco-find-one.operation.ts index 53926fc3..2c510a2b 100644 --- a/luna-backend/src/application/business/ambientes/bloco/dtos/bloco-find-one.operation.ts +++ b/luna-backend/src/application/business/ambientes/bloco/dtos/bloco-find-one.operation.ts @@ -1,6 +1,7 @@ import { InputType, ObjectType } from '@nestjs/graphql'; import * as yup from 'yup'; import * as Dto from '../../../(spec)'; +import { IImagemFindOneResultDto } from '../../../(spec)/base/imagem/operations'; import { DtoProperty, ValidationContractUuid, createDtoOperationOptions, createValidationContract, getSchemaField } from '../../../../../infrastructure'; import { BlocoDto, BlocoDtoProperties, BlocoDtoValidationContract } from './bloco.dto'; @@ -21,6 +22,9 @@ export class BlocoFindOneResultDto implements Dto.IBlocoFindOneResultDto { // @DtoProperty(BlocoDtoProperties.BLOCO_CAMPUS_OUTPUT) campus!: Dto.ICampusFindOneResultDto; + + // + imagemCapa!: IImagemFindOneResultDto | null; } // ====================================================== diff --git a/luna-backend/src/application/business/ambientes/bloco/dtos/bloco-get-imagem-capa.operation.ts b/luna-backend/src/application/business/ambientes/bloco/dtos/bloco-get-imagem-capa.operation.ts new file mode 100644 index 00000000..04720d0c --- /dev/null +++ b/luna-backend/src/application/business/ambientes/bloco/dtos/bloco-get-imagem-capa.operation.ts @@ -0,0 +1,28 @@ +import { ValidationContractUuid, createDtoOperationOptions } from '../../../../../infrastructure'; + +// ====================================================== + +export const BLOCO_GET_IMAGEM_CAPA = createDtoOperationOptions({ + description: 'Realiza a consulta a um bloco por ID.', + + gql: null, + + swagger: { + returnType: { + schema: { + type: 'string', + format: 'binary', + }, + }, + + params: [ + { + name: 'id', + description: 'ID do bloco.', + validationContract: ValidationContractUuid, + }, + ], + }, +}); + +// ====================================================== diff --git a/luna-backend/src/application/business/ambientes/bloco/dtos/bloco.dto.ts b/luna-backend/src/application/business/ambientes/bloco/dtos/bloco.dto.ts index fb383bdc..c952a3e6 100644 --- a/luna-backend/src/application/business/ambientes/bloco/dtos/bloco.dto.ts +++ b/luna-backend/src/application/business/ambientes/bloco/dtos/bloco.dto.ts @@ -1,6 +1,7 @@ import { ObjectType } from '@nestjs/graphql'; import * as yup from 'yup'; import * as Dto from '../../../(spec)'; +import { IImagemModel } from '../../../(spec)/base/imagem'; import { CommonPropertyUuid, DtoProperty, @@ -103,6 +104,7 @@ export class BlocoDto implements Dto.IBlocoModel { // ambientes!: Dto.IAmbienteModel[]; + imagemCapa!: IImagemModel | null; // diff --git a/luna-backend/src/application/business/ambientes/bloco/dtos/bloco.operations.ts b/luna-backend/src/application/business/ambientes/bloco/dtos/bloco.operations.ts index 0fccfa7a..c1795f37 100644 --- a/luna-backend/src/application/business/ambientes/bloco/dtos/bloco.operations.ts +++ b/luna-backend/src/application/business/ambientes/bloco/dtos/bloco.operations.ts @@ -2,6 +2,7 @@ import { BLOCO_CREATE } from './bloco-create.operation'; import { BLOCO_DELETE_ONE_BY_ID } from './bloco-delete-one.operation'; import { BLOCO_FIND_ALL } from './bloco-find-all.operation'; import { BLOCO_FIND_ONE_BY_ID } from './bloco-find-one.operation'; +import { BLOCO_GET_IMAGEM_CAPA } from './bloco-get-imagem-capa.operation'; import { BLOCO_UPDATE } from './bloco-update.operation'; export const BlocoOperations = { @@ -9,6 +10,7 @@ export const BlocoOperations = { BLOCO_FIND_ALL: BLOCO_FIND_ALL, // =============================== BLOCO_FIND_ONE_BY_ID: BLOCO_FIND_ONE_BY_ID, + BLOCO_GET_IMAGEM_CAPA: BLOCO_GET_IMAGEM_CAPA, // =============================== BLOCO_CREATE: BLOCO_CREATE, // =============================== diff --git a/luna-backend/src/application/business/base/arquivo/arquivo.controller.ts b/luna-backend/src/application/business/base/arquivo/arquivo.controller.ts index 28043560..7717d4e5 100644 --- a/luna-backend/src/application/business/base/arquivo/arquivo.controller.ts +++ b/luna-backend/src/application/business/base/arquivo/arquivo.controller.ts @@ -1,6 +1,5 @@ -import { Controller, Get, Res, ServiceUnavailableException, StreamableFile } from '@nestjs/common'; +import { Controller, Get, StreamableFile } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; -import { Response } from 'express'; import { IContextoDeAcesso } from '../../../../domain'; import { ContextoDeAcessoHttp, DtoOperationFindOne, HttpDtoParam } from '../../../../infrastructure'; import { HttpDtoQuery } from '../../../../infrastructure/api-documentate/HttpDtoQuery'; @@ -15,26 +14,14 @@ export class ArquivoController { @Get(':id') @DtoOperationFindOne(ArquivoOperations.ARQUIVO_GET_FILE) async getFile( - @Res({ passthrough: true }) res: Response, @ContextoDeAcessoHttp() contextoDeAcesso: IContextoDeAcesso, @HttpDtoParam(ArquivoOperations.ARQUIVO_GET_FILE, 'id') id: string, @HttpDtoQuery(ArquivoOperations.ARQUIVO_GET_FILE, 'acesso.recurso.nome') acessoRecursoNome: string, @HttpDtoQuery(ArquivoOperations.ARQUIVO_GET_FILE, 'acesso.recurso.id') acessoRecursoId: string, ): Promise<StreamableFile> { - const file = await this.arquivoService.getFile(contextoDeAcesso, id, { + return this.arquivoService.getStreamableFile(contextoDeAcesso, id, { id: acessoRecursoId, nome: acessoRecursoNome, }); - - if (!file.stream) { - throw new ServiceUnavailableException(); - } - - res.set({ - 'Content-Type': file.mimeType, - 'Content-Disposition': `attachment; filename="${encodeURIComponent(file.nome ?? file.id)}"`, - }); - - return new StreamableFile(file.stream); } } diff --git a/luna-backend/src/application/business/base/arquivo/arquivo.service.ts b/luna-backend/src/application/business/base/arquivo/arquivo.service.ts index 73616395..32c5facf 100644 --- a/luna-backend/src/application/business/base/arquivo/arquivo.service.ts +++ b/luna-backend/src/application/business/base/arquivo/arquivo.service.ts @@ -1,4 +1,4 @@ -import { ForbiddenException, Injectable, NotFoundException, ServiceUnavailableException } from '@nestjs/common'; +import { ForbiddenException, Injectable, NotFoundException, ServiceUnavailableException, StreamableFile } from '@nestjs/common'; import jetpack, { createReadStream } from 'fs-jetpack'; import { writeFile } from 'node:fs/promises'; import { Readable } from 'node:stream'; @@ -38,7 +38,7 @@ export class ArquivoService { return jetpack.exists(fileFullPath); } - async dataReadAsStream(id: Dto.IArquivoModel['id']) { + async dataReadAsStream(id: Dto.IArquivoModel['id']): Promise<Readable | null> { if (await this.dataExists(id)) { const fileFullPath = this.datGetFilePath(id); const fileReadStream = createReadStream(fileFullPath); @@ -48,7 +48,7 @@ export class ArquivoService { return null; } - async getFile(contextoDeAcesso: IContextoDeAcesso, id: Dto.IArquivoModel['id'], acesso: IGetFileAcesso | null) { + async getFile(contextoDeAcesso: IContextoDeAcesso | null, id: Dto.IArquivoModel['id'], acesso: IGetFileAcesso | null) { const qb = this.arquivoRepository.createQueryBuilder('arquivo'); qb.whereInIds([id]); @@ -71,7 +71,9 @@ export class ArquivoService { qb.andWhere('blocoCapa.id = :blocoCapa', { blocoCapa: acesso.id }); } - await contextoDeAcesso.aplicarFiltro('bloco:find', qb, 'blocoCapa', null); + if (contextoDeAcesso) { + await contextoDeAcesso.aplicarFiltro('bloco:find', qb, 'blocoCapa', null); + } } else { qb.andWhere('FALSE'); } @@ -97,6 +99,19 @@ export class ArquivoService { }; } + async getStreamableFile(contextoDeAcesso: IContextoDeAcesso | null, id: Dto.IArquivoModel['id'], acesso: IGetFileAcesso | null) { + const file = await this.getFile(contextoDeAcesso, id, acesso); + + if (!file.stream) { + throw new ServiceUnavailableException(); + } + + return new StreamableFile(file.stream, { + type: file.mimeType ?? undefined, + disposition: `attachment; filename="${encodeURIComponent(file.nome ?? file.id)}"`, + }); + } + async dataSave(id: Dto.IArquivoModel['id'], data: NodeJS.ArrayBufferView | Readable) { const fileFullPath = this.datGetFilePath(id); await writeFile(fileFullPath, data); diff --git a/luna-backend/src/infrastructure/api-documentate/DtoOperation.ts b/luna-backend/src/infrastructure/api-documentate/DtoOperation.ts index 8bc45f2d..500ec421 100644 --- a/luna-backend/src/infrastructure/api-documentate/DtoOperation.ts +++ b/luna-backend/src/infrastructure/api-documentate/DtoOperation.ts @@ -1,12 +1,41 @@ import { Type, applyDecorators } from '@nestjs/common'; import { Mutation, Query, QueryOptions, ReturnTypeFunc } from '@nestjs/graphql'; import { ApiBearerAuth, ApiBody, ApiParam, ApiQuery, ApiResponse } from '@nestjs/swagger'; +import { ReferenceObject, SchemaObject } from '@nestjs/swagger/dist/interfaces/open-api-spec.interface'; +import { has } from 'lodash'; import { Schema } from 'yup'; import { IValidationContract } from '../validation'; // ============================================================== -export type IDtoOperationSwaggerType = Type<unknown> | any | [any] | string; +export type IDtoOperationSwaggerType = + | Type<unknown> + | any + | [any] + | string + | { + schema: SchemaObject & Partial<ReferenceObject>; + }; + +const isTypeSchema = ( + value: unknown, +): value is { + schema: SchemaObject & Partial<ReferenceObject>; +} => { + return has(value, 'schema'); +}; + +const responseDeclarationFromDtoOperationSwaggerType = (returnType: IDtoOperationSwaggerType) => { + if (isTypeSchema(returnType)) { + return { + schema: returnType.schema, + }; + } + + return { + type: returnType, + }; +}; export type IDtoOperationGqlType = ReturnTypeFunc; @@ -94,7 +123,7 @@ export const DtoOperationFindAll = (options: IDtoOperationOptions) => { ApiResponse({ status: 200, - type: options.swagger.returnType, + ...responseDeclarationFromDtoOperationSwaggerType(options.swagger.returnType), description: options.description ?? 'Lista os recursos cadastrados no sistema.', }), ); @@ -108,7 +137,7 @@ export const DtoOperationFindOne = (options: IDtoOperationOptions) => { ApiResponse({ status: 200, - type: options.swagger.returnType, + ...responseDeclarationFromDtoOperationSwaggerType(options.swagger.returnType), description: options.description ?? 'Retorna a consulta a um registro.', }), @@ -131,7 +160,7 @@ export const DtoOperationCreate = (options: IDtoOperationOptions) => { ApiResponse({ status: 200, - type: options.swagger.returnType, + ...responseDeclarationFromDtoOperationSwaggerType(options.swagger.returnType), description: options.description ?? 'Retorna o registro cadastrado.', }), @@ -153,7 +182,7 @@ export const DtoOperationUpdate = (options: IDtoOperationOptions) => { ApiResponse({ status: 200, - type: options.swagger.returnType, + ...responseDeclarationFromDtoOperationSwaggerType(options.swagger.returnType), description: options.description ?? 'Retorna o registro cadastrado.', }), @@ -176,7 +205,7 @@ export const DtoOperationDelete = (options: IDtoOperationOptions) => { ApiResponse({ status: 200, - type: options.swagger.returnType, + ...responseDeclarationFromDtoOperationSwaggerType(options.swagger.returnType), description: options.description ?? 'Registro marcado como apagado.', }), diff --git a/luna-backend/src/infrastructure/integrate-database/typeorm/entities/base/imagem.entity.ts b/luna-backend/src/infrastructure/integrate-database/typeorm/entities/base/imagem.entity.ts index 066ad1da..ec4af2c2 100644 --- a/luna-backend/src/infrastructure/integrate-database/typeorm/entities/base/imagem.entity.ts +++ b/luna-backend/src/infrastructure/integrate-database/typeorm/entities/base/imagem.entity.ts @@ -1,10 +1,11 @@ import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm'; import { IEntityDate } from '../../../../../application/business/(spec)'; +import { IImagemModel } from '../../../../../application/business/(spec)/base/imagem'; import { BlocoEntity } from '../ambientes/bloco.entity'; import { ImagemArquivoEntity } from './imagem_arquivo.entity'; @Entity('imagem') -export class ImagemEntity { +export class ImagemEntity implements IImagemModel { @PrimaryGeneratedColumn('uuid') id!: string; diff --git a/luna-backend/src/infrastructure/integrate-database/typeorm/entities/base/imagem_arquivo.entity.ts b/luna-backend/src/infrastructure/integrate-database/typeorm/entities/base/imagem_arquivo.entity.ts index adb3cf39..4cec2f49 100644 --- a/luna-backend/src/infrastructure/integrate-database/typeorm/entities/base/imagem_arquivo.entity.ts +++ b/luna-backend/src/infrastructure/integrate-database/typeorm/entities/base/imagem_arquivo.entity.ts @@ -1,10 +1,11 @@ import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'; import { IEntityDate } from '../../../../../application/business/(spec)'; +import { IImagemArquivoModel } from '../../../../../application/business/(spec)/base/imagem-arquivo'; import { ArquivoEntity } from './arquivo.entity'; import { ImagemEntity } from './imagem.entity'; @Entity('imagem_arquivo') -export class ImagemArquivoEntity { +export class ImagemArquivoEntity implements IImagemArquivoModel { @PrimaryGeneratedColumn('uuid') id!: string; @@ -36,4 +37,7 @@ export class ImagemArquivoEntity { @Column({ name: 'date_created', type: 'timestamptz', nullable: false }) dateCreated!: IEntityDate; + + // dateUpdated!: IEntityDate; + // dateDeleted!: IEntityDate | null; }