Skip to content

Commit

Permalink
fix: loadImagem
Browse files Browse the repository at this point in the history
  • Loading branch information
guesant committed Mar 29, 2024
1 parent 63fc72f commit c96219a
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ import { AmbienteEntity } from '../../../../infrastructure/integrate-database/ty
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 { IImagemQueryBuilderViewOptions, ImagemService } from '../../base/imagem/imagem.service';
import { BlocoService, IBlocoQueryBuilderViewOptions } from '../bloco/bloco.service';
import { ICampusQueryBuilderViewOptions } from '../campus/campus.service';

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

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

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

// ============================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { BlocoEntity } from '../../../../infrastructure/integrate-database/typeo
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 { IImagemQueryBuilderViewOptions, ImagemService } from '../../base/imagem/imagem.service';
import { CampusService, ICampusQueryBuilderViewOptions } from '../campus/campus.service';

// ============================================================================
Expand All @@ -21,7 +21,7 @@ const aliasBloco = 'bloco';

export type IBlocoQueryBuilderViewOptions = {
loadCampus?: IQueryBuilderViewOptionsLoad<ICampusQueryBuilderViewOptions>;
loadImagemCapa?: IQueryBuilderViewOptionsLoad<ICampusQueryBuilderViewOptions>;
loadImagemCapa?: IQueryBuilderViewOptionsLoad<IImagemQueryBuilderViewOptions>;
};

// ============================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ import * as Dtos from '../../(spec)';
import { IContextoDeAcesso } from '../../../../domain';
import { DatabaseContextService } from '../../../../infrastructure/integrate-database/database-context/database-context.service';
import { IQueryBuilderViewOptionsLoad, getQueryBuilderViewLoadMeta } from '../../../utils/QueryBuilderViewOptionsLoad';
import { ICampusQueryBuilderViewOptions } from '../../ambientes/campus/campus.service';
import { ArquivoService } from '../../base/arquivo/arquivo.service';
import { ImagemService } from '../../base/imagem/imagem.service';
import { IImagemQueryBuilderViewOptions, ImagemService } from '../../base/imagem/imagem.service';

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

Expand All @@ -19,8 +18,8 @@ const aliasUsuario = 'usuario';
// ============================================================================

export type IUsuarioQueryBuilderViewOptions = {
loadImagemCapa?: IQueryBuilderViewOptionsLoad<ICampusQueryBuilderViewOptions>;
loadImagemPerfil?: IQueryBuilderViewOptionsLoad<ICampusQueryBuilderViewOptions>;
loadImagemCapa?: IQueryBuilderViewOptionsLoad<IImagemQueryBuilderViewOptions>;
loadImagemPerfil?: IQueryBuilderViewOptionsLoad<IImagemQueryBuilderViewOptions>;
};

// ============================================================================
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Controller, Delete, Get, Param, ParseUUIDPipe, Patch, Post, Put, UploadedFile, UseInterceptors } from '@nestjs/common';
import { FileInterceptor } from '@nestjs/platform-express';
import { ApiBody, ApiConsumes, ApiProduces, ApiTags } from '@nestjs/swagger';
import { Paginate, PaginateQuery } from 'nestjs-paginate';
import * as Dto from '../../(spec)';
Expand All @@ -16,7 +17,6 @@ import {
} from '../../../../infrastructure';
import { CursoService } from './curso.service';
import { CursoOperations } from './dtos';
import { FileInterceptor } from '@nestjs/platform-express';

@ApiTags('Cursos')
@Controller('/cursos')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { paginateConfig } from '../../../../infrastructure/utils/paginateConfig'
import { IQueryBuilderViewOptionsLoad, getQueryBuilderViewLoadMeta } from '../../../utils/QueryBuilderViewOptionsLoad';
import { CampusService, ICampusQueryBuilderViewOptions } from '../../ambientes/campus/campus.service';
import { ArquivoService } from '../../base/arquivo/arquivo.service';
import { ImagemService } from '../../base/imagem/imagem.service';
import { IImagemQueryBuilderViewOptions, ImagemService } from '../../base/imagem/imagem.service';
import { IModalidadeQueryBuilderViewOptions, ModalidadeService } from '../modalidade/modalidade.service';

// ============================================================================
Expand All @@ -23,6 +23,7 @@ const aliasCurso = 'curso';
export type ICursoQueryBuilderViewOptions = {
loadCampus?: IQueryBuilderViewOptionsLoad<ICampusQueryBuilderViewOptions>;
loadModalidade?: IQueryBuilderViewOptionsLoad<IModalidadeQueryBuilderViewOptions>;
loadImagemCapa?: IQueryBuilderViewOptionsLoad<IImagemQueryBuilderViewOptions>;
};

// ============================================================================
Expand Down Expand Up @@ -64,6 +65,13 @@ export class CursoService {
qb.innerJoin(`${alias}.modalidade`, `${loadModalidade.alias}`);
ModalidadeService.ModalidadeQueryBuilderView(loadModalidade.alias, qb, loadModalidade.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 @@ -8,16 +8,19 @@ import { getPaginateQueryFromSearchInput } from '../../../../infrastructure';
import { DatabaseContextService } from '../../../../infrastructure/integrate-database/database-context/database-context.service';
import { DisciplinaEntity } from '../../../../infrastructure/integrate-database/typeorm/entities/ensino/disciplina.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 { IImagemQueryBuilderViewOptions, ImagemService } from '../../base/imagem/imagem.service';

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

const aliasDisciplina = 'disciplina';

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

export type IDisciplinaQueryBuilderViewOptions = any;
export type IDisciplinaQueryBuilderViewOptions = {
loadImagemCapa?: IQueryBuilderViewOptionsLoad<IImagemQueryBuilderViewOptions>;
};

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

Expand All @@ -36,13 +39,20 @@ export class DisciplinaService {
//

// eslint-disable-next-line @typescript-eslint/no-unused-vars
static DisciplinaQueryBuilderView(alias: string, qb: SelectQueryBuilder<any>, _: IDisciplinaQueryBuilderViewOptions = {}) {
static DisciplinaQueryBuilderView(alias: string, qb: SelectQueryBuilder<any>, options: IDisciplinaQueryBuilderViewOptions = {}) {
qb.addSelect([
//
`${alias}.id`,
`${alias}.nome`,
`${alias}.cargaHoraria`,
]);

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 @@ -11,7 +11,7 @@ import { paginateConfig } from '../../../../infrastructure/utils/paginateConfig'
import { IQueryBuilderViewOptionsLoad, getQueryBuilderViewLoadMeta } from '../../../utils/QueryBuilderViewOptionsLoad';
import { AmbienteService, IAmbienteQueryBuilderViewOptions } from '../../ambientes/ambiente/ambiente.service';
import { ArquivoService } from '../../base/arquivo/arquivo.service';
import { ImagemService } from '../../base/imagem/imagem.service';
import { IImagemQueryBuilderViewOptions, ImagemService } from '../../base/imagem/imagem.service';
import { CursoService, ICursoQueryBuilderViewOptions } from '../curso/curso.service';

// ============================================================================
Expand All @@ -23,6 +23,7 @@ const aliasTurma = 'turma';
export type ITurmaQueryBuilderViewOptions = {
loadCurso?: IQueryBuilderViewOptionsLoad<ICursoQueryBuilderViewOptions>;
loadAmbientePadraoAula?: IQueryBuilderViewOptionsLoad<IAmbienteQueryBuilderViewOptions>;
loadImagemCapa?: IQueryBuilderViewOptionsLoad<IImagemQueryBuilderViewOptions>;
};

// ============================================================================
Expand Down Expand Up @@ -65,6 +66,13 @@ export class TurmaService {
qb.leftJoin(`${alias}.ambientePadraoAula`, `${loadAmbientePadraoAula.alias}`);
AmbienteService.AmbienteQueryBuilderView(loadAmbientePadraoAula.alias, qb, loadAmbientePadraoAula.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

0 comments on commit c96219a

Please sign in to comment.