added new table costo
This commit is contained in:
+5
-1
@@ -43,6 +43,8 @@ import { BitacoraModule } from './bitacora/bitacora.module';
|
||||
import { Bitacora } from './bitacora/entities/bitacora.entity';
|
||||
import { MensajeModule } from './mensaje/mensaje.module';
|
||||
import { Mensaje } from './mensaje/entities/mensaje.entity';
|
||||
import { CostoModule } from './costo/costo.module';
|
||||
import { Costo } from './costo/entities/costo.entity';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
@@ -79,7 +81,8 @@ import { Mensaje } from './mensaje/entities/mensaje.entity';
|
||||
ProgramaEquipo,
|
||||
BitacoraMesa,
|
||||
Bitacora,
|
||||
Mensaje
|
||||
Mensaje,
|
||||
Costo,
|
||||
],
|
||||
synchronize: false, //Never change to true in production!
|
||||
}),
|
||||
@@ -103,6 +106,7 @@ import { Mensaje } from './mensaje/entities/mensaje.entity';
|
||||
BitacoraMesaModule,
|
||||
BitacoraModule,
|
||||
MensajeModule,
|
||||
CostoModule,
|
||||
],
|
||||
controllers: [AppController],
|
||||
providers: [AppService],
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { CostoController } from './costo.controller';
|
||||
import { CostoService } from './costo.service';
|
||||
|
||||
describe('CostoController', () => {
|
||||
let controller: CostoController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
controllers: [CostoController],
|
||||
providers: [CostoService],
|
||||
}).compile();
|
||||
|
||||
controller = module.get<CostoController>(CostoController);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(controller).toBeDefined();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,13 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
||||
import { CostoService } from './costo.service';
|
||||
|
||||
@Controller('costo')
|
||||
export class CostoController {
|
||||
constructor(private readonly costoService: CostoService) {}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.costoService.findAll();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { CostoService } from './costo.service';
|
||||
import { CostoController } from './costo.controller';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { Costo } from './entities/costo.entity';
|
||||
|
||||
@Module({
|
||||
imports:[TypeOrmModule.forFeature([Costo])],
|
||||
controllers: [CostoController],
|
||||
providers: [CostoService],
|
||||
})
|
||||
export class CostoModule {}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { CostoService } from './costo.service';
|
||||
|
||||
describe('CostoService', () => {
|
||||
let service: CostoService;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [CostoService],
|
||||
}).compile();
|
||||
|
||||
service = module.get<CostoService>(CostoService);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(service).toBeDefined();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,14 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Costo } from './entities/costo.entity';
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
@Injectable()
|
||||
export class CostoService {
|
||||
constructor(@InjectRepository(Costo)
|
||||
private readonly CostoRepository: Repository<Costo>) { }
|
||||
findAll() {
|
||||
return this.CostoRepository.find();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export class CreateCostoDto {}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { PartialType } from '@nestjs/mapped-types';
|
||||
import { CreateCostoDto } from './create-costo.dto';
|
||||
|
||||
export class UpdateCostoDto extends PartialType(CreateCostoDto) {}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm';
|
||||
|
||||
@Entity('costo')
|
||||
export class Costo {
|
||||
|
||||
@PrimaryGeneratedColumn()
|
||||
id_costo: number;
|
||||
|
||||
@Column('decimal', { precision: 10, scale: 2 })
|
||||
costo: number;
|
||||
|
||||
@Column({ type: 'int' })
|
||||
id_servicio: number;
|
||||
|
||||
@Column({
|
||||
type: 'timestamp',
|
||||
default: () => 'CURRENT_TIMESTAMP',
|
||||
})
|
||||
fecha_registro: Date;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user