commit
This commit is contained in:
39
src/backoffice/ncm/ncm.service.ts
Normal file
39
src/backoffice/ncm/ncm.service.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { Pcncm } from '../../domain/entity/tables/pcncm.entity';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
@Injectable()
|
||||
export class NcmService {
|
||||
constructor(@InjectRepository(Pcncm)
|
||||
private ncmRepository: Repository<Pcncm>){}
|
||||
|
||||
async findAll(): Promise<Pcncm[]> {
|
||||
return await this.ncmRepository
|
||||
.createQueryBuilder('pcncm')
|
||||
.select('"pcncm".codncmex', 'codigoNcmEx')
|
||||
.addSelect('concat(concat("pcncm".codncmex, \' - \'),SUBSTR("pcncm".descricao,1,100))', 'descricaoNcm')
|
||||
.where('dtexclusao is null')
|
||||
.getRawMany();
|
||||
}
|
||||
|
||||
async findByDescription(description: string): Promise<Pcncm[]> {
|
||||
|
||||
return await this.ncmRepository
|
||||
.createQueryBuilder('pcncm')
|
||||
.select('"pcncm".codncmex', 'codigoNcmEx')
|
||||
.addSelect('concat(concat("pcncm".codncmex, \' - \'),SUBSTR("pcncm".descricao,1,100))', 'descricaoNcm')
|
||||
.where('dtexclusao is null')
|
||||
.andWhere("descricao like UPPER(:description)||'%'", {description})
|
||||
.getRawMany();
|
||||
}
|
||||
|
||||
async find(ncm: string): Promise<Pcncm[]> {
|
||||
return await this.ncmRepository
|
||||
.createQueryBuilder('pcncm')
|
||||
.where("dtexclusao is null and codncm like :ncm||'%'", { ncm })
|
||||
.getRawMany();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user