This commit is contained in:
Felipe Batista
2025-01-27 17:44:27 -03:00
commit 47e7f75720
238 changed files with 36425 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
import { CategoryService } from './category.service';
import { Controller, Get, HttpException, HttpStatus, Param } from '@nestjs/common';
import { ApiExcludeEndpoint, ApiTags } from '@nestjs/swagger';
import { ResultModel } from 'src/domain/models/result.model';
@ApiTags('BackOffice')
@Controller('v1/category')
export class CategoryController {
constructor(private readonly categoryService: CategoryService){}
@Get(':idSecion')
@ApiExcludeEndpoint()
async getSection(@Param('idSecion') idSection: number) {
try {
const result = await this.categoryService.find(idSection);
return new ResultModel(true, null, result, []);
} catch (error) {
throw new HttpException(new ResultModel(false, 'Não foi possível consultar lista de departamentos', {}, error), HttpStatus.INTERNAL_SERVER_ERROR);
}
}
}

View File

@@ -0,0 +1,15 @@
import { Pccategoria } from '../../domain/entity/tables/pccategoria.entity';
import { CategoryService } from './category.service';
import { CategoryController } from './category.controller';
import { CacheModule, Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
@Module({
imports: [CacheModule.register(),
TypeOrmModule.forFeature([Pccategoria])],
controllers: [
CategoryController,],
providers: [
CategoryService,],
})
export class CategoryModule { }

View File

@@ -0,0 +1,22 @@
import { Pccategoria } from '../../domain/entity/tables/pccategoria.entity';
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
@Injectable()
export class CategoryService {
constructor(@InjectRepository(Pccategoria)
private categoryRespository: Repository<Pccategoria>) { }
async find(idSecion: number): Promise<Pccategoria[]> {
return await this.categoryRespository
.createQueryBuilder('pccategoria')
.select('"pccategoria".codcategoria', 'codigoCategoria')
.addSelect('concat(concat("pccategoria".codcategoria, \'-\'),"pccategoria".categoria)', 'descricaoCategoria')
//.addSelect('concat(concat("pccategoria".codcategoria, \'-\'),"pccategoria".categoria)', 'descricaoCategoria')
.where("codsec = :codsec", { codsec: idSecion })
.getRawMany();
}
}