order by
This commit is contained in:
@@ -4,8 +4,7 @@ import {
|
||||
NotFoundException,
|
||||
} from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { FindOperator, Not, Repository } from 'typeorm';
|
||||
import { Institucion } from 'src/institucion/entity/institucion.entity';
|
||||
import { Not, Repository } from 'typeorm';
|
||||
import { InstitucionPrograma } from './entity/institucion-programa.entity';
|
||||
import { Programa } from './entity/programa.entity';
|
||||
import { InstitucionService } from '../institucion/institucion.service';
|
||||
|
||||
@@ -53,16 +53,28 @@ export class InstitucionTipoCarritoService {
|
||||
}
|
||||
|
||||
findAll() {
|
||||
return this.tipoCarritoRepository.find();
|
||||
return this.tipoCarritoRepository.find({ order: { tipo_carrito: 'ASC' } });
|
||||
}
|
||||
|
||||
async findAllByIdInstitucion(id_institucion: number, mostrar = false) {
|
||||
const institucion = await this.institucionService.findById(id_institucion);
|
||||
const query = this.institucionTipoCarritoRepository
|
||||
.createQueryBuilder('itc')
|
||||
.innerJoinAndSelect(
|
||||
'itc.institucion',
|
||||
'i',
|
||||
'i.id_institucion = :id_institucion',
|
||||
{ id_institucion: institucion.id_institucion },
|
||||
)
|
||||
.innerJoinAndSelect('itc.tipoCarrito', 'tc')
|
||||
.orderBy('tc.tipo_carrito');
|
||||
const busqueda: { institucion: Institucion; mostrar?: boolean } = {
|
||||
institucion,
|
||||
};
|
||||
|
||||
if (mostrar) busqueda.mostrar = mostrar;
|
||||
if (mostrar) query.andWhere('itc.mostrar = 1');
|
||||
return query.getMany();
|
||||
return this.institucionTipoCarritoRepository.find(busqueda);
|
||||
}
|
||||
|
||||
|
||||
@@ -49,17 +49,24 @@ export class InstitucionTipoEntradaService {
|
||||
}
|
||||
|
||||
findAll() {
|
||||
return this.tipoEntradaRepository.find();
|
||||
return this.tipoEntradaRepository.find({ order: { tipo_entrada: 'ASC' } });
|
||||
}
|
||||
|
||||
async findAllByIdInstitucion(id_institucion: number, mostrar = false) {
|
||||
const institucion = await this.institucionService.findById(id_institucion);
|
||||
const busqueda: { institucion: Institucion; mostrar?: boolean } = {
|
||||
institucion,
|
||||
};
|
||||
const query = await this.institucionTipoEntradaRepository
|
||||
.createQueryBuilder('ite')
|
||||
.innerJoinAndSelect(
|
||||
'ite.institucion',
|
||||
'i',
|
||||
'i.id_institucion = :id_institucion',
|
||||
{ id_institucion: institucion.id_institucion },
|
||||
)
|
||||
.innerJoinAndSelect('ite.tipoEntrada', 'te')
|
||||
.orderBy('te.tipo_entrada');
|
||||
|
||||
if (mostrar) busqueda.mostrar = mostrar;
|
||||
return this.institucionTipoEntradaRepository.find(busqueda);
|
||||
if (mostrar) query.andWhere('ite.mostrar = 1');
|
||||
return query.getMany();
|
||||
}
|
||||
|
||||
findById(id_institucion_tipo_entrada: number) {
|
||||
|
||||
Reference in New Issue
Block a user