From c92f623c28d73386bdf0da610ced76e13df63a1c Mon Sep 17 00:00:00 2001 From: "Gabriel R. Antunes" Date: Fri, 29 Mar 2024 08:49:25 -0400 Subject: [PATCH] feat: ambiente: dto: imagemCapa --- .../IAmbienteFindOneResultDto.ts | 2 ++ .../ambientes/ambiente/IAmbienteModel.ts | 13 +++++++------ .../(spec)/ambientes/bloco/IBlocoModel.ts | 4 ++-- .../ambientes/ambiente/ambiente.service.ts | 10 ++++++++++ .../dtos/ambiente-find-one.operation.ts | 3 +++ .../ambientes/ambiente/dtos/ambiente.dto.ts | 18 +++++++++++++++++- 6 files changed, 41 insertions(+), 9 deletions(-) diff --git a/luna-backend/src/application/business/(spec)/ambientes/ambiente/(dtos)/ambiente-find-one/IAmbienteFindOneResultDto.ts b/luna-backend/src/application/business/(spec)/ambientes/ambiente/(dtos)/ambiente-find-one/IAmbienteFindOneResultDto.ts index 698a6392..8f365e11 100644 --- a/luna-backend/src/application/business/(spec)/ambientes/ambiente/(dtos)/ambiente-find-one/IAmbienteFindOneResultDto.ts +++ b/luna-backend/src/application/business/(spec)/ambientes/ambiente/(dtos)/ambiente-find-one/IAmbienteFindOneResultDto.ts @@ -1,6 +1,8 @@ +import { IImagemFindOneResultDto } from '../../../../base'; import { IBlocoFindOneResultDto } from '../../../bloco'; import { IAmbienteModel } from '../../IAmbienteModel'; export interface IAmbienteFindOneResultDto extends Pick { bloco: IBlocoFindOneResultDto; + imagemCapa: IImagemFindOneResultDto | null; } diff --git a/luna-backend/src/application/business/(spec)/ambientes/ambiente/IAmbienteModel.ts b/luna-backend/src/application/business/(spec)/ambientes/ambiente/IAmbienteModel.ts index 6f8b9a8d..5905d47e 100644 --- a/luna-backend/src/application/business/(spec)/ambientes/ambiente/IAmbienteModel.ts +++ b/luna-backend/src/application/business/(spec)/ambientes/ambiente/IAmbienteModel.ts @@ -1,29 +1,30 @@ import { IDatedObject, IEntityDate, IObjectUuid } from '../../(core)'; +import { IImagemModel } from '../../base'; import { IBlocoModel } from '../bloco'; export interface IAmbienteModel extends IObjectUuid, IDatedObject { - // + // ================================= id: string; - // + // ================================= nome: string; descricao: string; codigo: string; - capacidade: number | null; tipo: string | null; - // + // ================================= bloco: IBlocoModel; + imagemCapa: IImagemModel | null; - // + // ================================= dateCreated: IEntityDate; dateUpdated: IEntityDate; dateDeleted: null | IEntityDate; - // + // ================================= } 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 bff17b97..f48a016e 100644 --- a/luna-backend/src/application/business/(spec)/ambientes/bloco/IBlocoModel.ts +++ b/luna-backend/src/application/business/(spec)/ambientes/bloco/IBlocoModel.ts @@ -16,11 +16,11 @@ export interface IBlocoModel extends IObjectUuid, IDatedObject { // ================================= campus: ICampusModel; + imagemCapa: IImagemModel | null; - // + // ================================= ambientes: IAmbienteModel[]; - imagemCapa: IImagemModel | null; // ================================= diff --git a/luna-backend/src/application/business/ambientes/ambiente/ambiente.service.ts b/luna-backend/src/application/business/ambientes/ambiente/ambiente.service.ts index 0004990e..3c9b47d4 100644 --- a/luna-backend/src/application/business/ambientes/ambiente/ambiente.service.ts +++ b/luna-backend/src/application/business/ambientes/ambiente/ambiente.service.ts @@ -10,6 +10,8 @@ import { AmbienteEntity } from '../../../../infrastructure/integrate-database/ty import { paginateConfig } from '../../../../infrastructure/utils/paginateConfig'; import { IQueryBuilderViewOptionsLoad, getQueryBuilderViewLoadMeta } from '../../../utils/QueryBuilderViewOptionsLoad'; import { BlocoService, IBlocoQueryBuilderViewOptions } from '../bloco/bloco.service'; +import { ICampusQueryBuilderViewOptions } from '../campus/campus.service'; +import { ImagemService } from '../../base/imagem/imagem.service'; // ============================================================================ @@ -19,6 +21,7 @@ const aliasAmbiente = 'ambiente'; export type IAmbienteQueryBuilderViewOptions = { loadBloco?: IQueryBuilderViewOptionsLoad; + loadImagemCapa?: IQueryBuilderViewOptionsLoad; }; // ============================================================================ @@ -54,6 +57,13 @@ export class AmbienteService { qb.leftJoin(`${alias}.bloco`, `${loadBloco.alias}`); BlocoService.BlocoQueryBuilderView(loadBloco.alias, qb, loadBloco.options); } + + const loadImagemCapa = getQueryBuilderViewLoadMeta(options.loadImagemCapa, true, `${alias}_imagemCapa`); + + if (loadImagemCapa) { + qb.leftJoin(`${alias}.imagemCapa`, `${loadImagemCapa.alias}`); + ImagemService.ImagemQueryBuilderView(loadImagemCapa.alias, qb, loadImagemCapa.options); + } } // diff --git a/luna-backend/src/application/business/ambientes/ambiente/dtos/ambiente-find-one.operation.ts b/luna-backend/src/application/business/ambientes/ambiente/dtos/ambiente-find-one.operation.ts index 846d1bee..1be7fc29 100644 --- a/luna-backend/src/application/business/ambientes/ambiente/dtos/ambiente-find-one.operation.ts +++ b/luna-backend/src/application/business/ambientes/ambiente/dtos/ambiente-find-one.operation.ts @@ -33,6 +33,9 @@ export class AmbienteFindOneResultDto implements IAmbienteFindOneResultDto { @DtoProperty(AmbienteDtoProperties.AMBIENTE_BLOCO_OUTPUT) bloco!: IBlocoFindOneResultDto; + + @DtoProperty(AmbienteDtoProperties.AMBIENTE_IMAGEM_CAPA_OUTPUT) + imagemCapa!: Dto.IImagemModel | null; } // ====================================================== diff --git a/luna-backend/src/application/business/ambientes/ambiente/dtos/ambiente.dto.ts b/luna-backend/src/application/business/ambientes/ambiente/dtos/ambiente.dto.ts index 2e806497..e29cb3f4 100644 --- a/luna-backend/src/application/business/ambientes/ambiente/dtos/ambiente.dto.ts +++ b/luna-backend/src/application/business/ambientes/ambiente/dtos/ambiente.dto.ts @@ -1,6 +1,6 @@ import { Int, ObjectType } from '@nestjs/graphql'; import * as yup from 'yup'; -import { IAmbienteModel, IBlocoModel, IEntityDate } from '../../../(spec)'; +import { IAmbienteModel, IBlocoModel, IEntityDate, IImagemModel } from '../../../(spec)'; import { CommonPropertyUuid, DtoProperty, @@ -12,6 +12,7 @@ import { createDtoPropertyMap, createValidationContract, } from '../../../../../infrastructure'; +import { ImagemDto, ImagemFindOneResultDto } from '../../../base/imagem/dtos'; import { BlocoDto, BlocoFindOneResultDto } from '../../bloco/dtos'; // ====================================================== @@ -120,6 +121,18 @@ export const AmbienteDtoProperties = createDtoPropertyMap({ type: () => BlocoFindOneResultDto, }, }, + + AMBIENTE_IMAGEM_CAPA_OUTPUT: { + nullable: true, + description: 'Imagem de capa do ambiente.', + // + gql: { + type: () => ImagemDto, + }, + swagger: { + type: ImagemFindOneResultDto, + }, + }, }); // ====================================================== @@ -149,6 +162,9 @@ export class AmbienteDto implements IAmbienteModel { @DtoProperty(AmbienteDtoProperties.AMBIENTE_BLOCO_OUTPUT) bloco!: IBlocoModel; + @DtoProperty(AmbienteDtoProperties.AMBIENTE_IMAGEM_CAPA_OUTPUT) + imagemCapa!: IImagemModel | null; + // dateCreated!: IEntityDate;