Skip to content

Commit

Permalink
feat: ambiente: dto: imagemCapa
Browse files Browse the repository at this point in the history
  • Loading branch information
guesant committed Mar 29, 2024
1 parent 7cf01dd commit c92f623
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { IImagemFindOneResultDto } from '../../../../base';
import { IBlocoFindOneResultDto } from '../../../bloco';
import { IAmbienteModel } from '../../IAmbienteModel';

export interface IAmbienteFindOneResultDto extends Pick<IAmbienteModel, 'id' | 'codigo' | 'capacidade' | 'nome' | 'descricao' | 'tipo'> {
bloco: IBlocoFindOneResultDto;
imagemCapa: IImagemFindOneResultDto | null;
}
Original file line number Diff line number Diff line change
@@ -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;

//
// =================================
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ export interface IBlocoModel extends IObjectUuid, IDatedObject {
// =================================

campus: ICampusModel;
imagemCapa: IImagemModel | null;

//
// =================================

ambientes: IAmbienteModel[];
imagemCapa: IImagemModel | null;

// =================================

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

// ============================================================================

Expand All @@ -19,6 +21,7 @@ const aliasAmbiente = 'ambiente';

export type IAmbienteQueryBuilderViewOptions = {
loadBloco?: IQueryBuilderViewOptionsLoad<IBlocoQueryBuilderViewOptions>;
loadImagemCapa?: IQueryBuilderViewOptionsLoad<ICampusQueryBuilderViewOptions>;
};

// ============================================================================
Expand Down Expand Up @@ -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);
}
}

//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

// ======================================================
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -12,6 +12,7 @@ import {
createDtoPropertyMap,
createValidationContract,
} from '../../../../../infrastructure';
import { ImagemDto, ImagemFindOneResultDto } from '../../../base/imagem/dtos';
import { BlocoDto, BlocoFindOneResultDto } from '../../bloco/dtos';

// ======================================================
Expand Down Expand Up @@ -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,
},
},
});

// ======================================================
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit c92f623

Please sign in to comment.