Creacion de entities
This commit is contained in:
@@ -1,21 +1,31 @@
|
||||
import { Column, Entity, PrimaryColumn } from "typeorm";
|
||||
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
|
||||
|
||||
@Entity({ name: 'alumno' })
|
||||
export class Student {
|
||||
|
||||
@PrimaryColumn({ name: 'id_cuenta', type: 'int', unsigned: true })
|
||||
@PrimaryGeneratedColumn({ name: 'id_cuenta', type: 'int', unsigned: true })
|
||||
id_cuenta: number;
|
||||
|
||||
@Column({ name: 'nombre', type: 'varchar', length: 300, nullable: false })
|
||||
nombre: string;
|
||||
|
||||
@Column({ name: 'fecha_nacimiento', type: 'varchar', length: 8, nullable: true })
|
||||
@Column({
|
||||
name: 'fecha_nacimiento',
|
||||
type: 'varchar',
|
||||
length: 8,
|
||||
nullable: true,
|
||||
})
|
||||
fecha_nacimiento: string | null;
|
||||
|
||||
@Column({ name: 'correo', type: 'varchar', length: 100, nullable: true })
|
||||
correo: string | null;
|
||||
|
||||
@Column({ name: 'credito', type: 'decimal', precision: 10, scale: 2, default: 0.00 })
|
||||
@Column({
|
||||
name: 'credito',
|
||||
type: 'decimal',
|
||||
precision: 10,
|
||||
scale: 2,
|
||||
default: 0.0,
|
||||
})
|
||||
credito: string;
|
||||
|
||||
@Column({
|
||||
@@ -6,6 +6,9 @@ import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { StudentModule } from './student/student.module';
|
||||
import { UserModule } from './user/user.module';
|
||||
import { User } from './user/entities/user.entity';
|
||||
import { DetalleServicioModule } from './detalle_servicio/detalle_servicio.module';
|
||||
import { PeriodoModule } from './periodo/periodo.module';
|
||||
import { ServicioModule } from './servicio/servicio.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
@@ -27,6 +30,9 @@ import { User } from './user/entities/user.entity';
|
||||
}),
|
||||
}),
|
||||
UserModule,
|
||||
DetalleServicioModule,
|
||||
PeriodoModule,
|
||||
ServicioModule,
|
||||
],
|
||||
controllers: [AppController],
|
||||
providers: [AppService],
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { DetalleServicioController } from './detalle_servicio.controller';
|
||||
import { DetalleServicioService } from './detalle_servicio.service';
|
||||
|
||||
describe('DetalleServicioController', () => {
|
||||
let controller: DetalleServicioController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
controllers: [DetalleServicioController],
|
||||
providers: [DetalleServicioService],
|
||||
}).compile();
|
||||
|
||||
controller = module.get<DetalleServicioController>(DetalleServicioController);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(controller).toBeDefined();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,34 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
||||
import { DetalleServicioService } from './detalle_servicio.service';
|
||||
import { CreateDetalleServicioDto } from './dto/create-detalle_servicio.dto';
|
||||
import { UpdateDetalleServicioDto } from './dto/update-detalle_servicio.dto';
|
||||
|
||||
@Controller('detalle-servicio')
|
||||
export class DetalleServicioController {
|
||||
constructor(private readonly detalleServicioService: DetalleServicioService) {}
|
||||
|
||||
@Post()
|
||||
create(@Body() createDetalleServicioDto: CreateDetalleServicioDto) {
|
||||
return this.detalleServicioService.create(createDetalleServicioDto);
|
||||
}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.detalleServicioService.findAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.detalleServicioService.findOne(+id);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
update(@Param('id') id: string, @Body() updateDetalleServicioDto: UpdateDetalleServicioDto) {
|
||||
return this.detalleServicioService.update(+id, updateDetalleServicioDto);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
remove(@Param('id') id: string) {
|
||||
return this.detalleServicioService.remove(+id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { DetalleServicioService } from './detalle_servicio.service';
|
||||
import { DetalleServicioController } from './detalle_servicio.controller';
|
||||
|
||||
@Module({
|
||||
controllers: [DetalleServicioController],
|
||||
providers: [DetalleServicioService],
|
||||
})
|
||||
export class DetalleServicioModule {}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { DetalleServicioService } from './detalle_servicio.service';
|
||||
|
||||
describe('DetalleServicioService', () => {
|
||||
let service: DetalleServicioService;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [DetalleServicioService],
|
||||
}).compile();
|
||||
|
||||
service = module.get<DetalleServicioService>(DetalleServicioService);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(service).toBeDefined();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,26 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CreateDetalleServicioDto } from './dto/create-detalle_servicio.dto';
|
||||
import { UpdateDetalleServicioDto } from './dto/update-detalle_servicio.dto';
|
||||
|
||||
@Injectable()
|
||||
export class DetalleServicioService {
|
||||
create(createDetalleServicioDto: CreateDetalleServicioDto) {
|
||||
return 'This action adds a new detalleServicio';
|
||||
}
|
||||
|
||||
findAll() {
|
||||
return `This action returns all detalleServicio`;
|
||||
}
|
||||
|
||||
findOne(id: number) {
|
||||
return `This action returns a #${id} detalleServicio`;
|
||||
}
|
||||
|
||||
update(id: number, updateDetalleServicioDto: UpdateDetalleServicioDto) {
|
||||
return `This action updates a #${id} detalleServicio`;
|
||||
}
|
||||
|
||||
remove(id: number) {
|
||||
return `This action removes a #${id} detalleServicio`;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import { Type } from 'class-transformer';
|
||||
import { IsDate, IsInt, IsNotEmpty, IsOptional, Min } from 'class-validator';
|
||||
|
||||
export class CreateDetalleServicioDto {
|
||||
@IsInt()
|
||||
@Min(0)
|
||||
@IsNotEmpty()
|
||||
numero_hojas: number;
|
||||
|
||||
@IsOptional()
|
||||
@Type(() => Date)
|
||||
@IsDate()
|
||||
fecha_operacion?: Date;
|
||||
|
||||
@IsInt()
|
||||
@IsNotEmpty()
|
||||
id_cuenta: number;
|
||||
|
||||
@IsInt()
|
||||
@IsNotEmpty()
|
||||
id_servicio: number;
|
||||
|
||||
@IsInt()
|
||||
@IsNotEmpty()
|
||||
id_usuario: number;
|
||||
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
id_periodo?: number;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
export class DetalleServicioDto {
|
||||
id_detalle_servicio: number;
|
||||
numero_hojas: number;
|
||||
fecha_operacion: Date;
|
||||
id_cuenta: number;
|
||||
id_servicio: number;
|
||||
id_usuario: number;
|
||||
id_periodo: number | null;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { PartialType } from '@nestjs/mapped-types';
|
||||
import { CreateDetalleServicioDto } from './create-detalle_servicio.dto';
|
||||
|
||||
export class UpdateDetalleServicioDto extends PartialType(CreateDetalleServicioDto) {}
|
||||
@@ -0,0 +1,51 @@
|
||||
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
|
||||
|
||||
@Entity({ name: 'detalle_servicio' })
|
||||
export class DetalleServicio {
|
||||
@PrimaryGeneratedColumn({
|
||||
name: 'id_detalle_servicio',
|
||||
type: 'int',
|
||||
unsigned: true,
|
||||
})
|
||||
id_detalle_servicio: number;
|
||||
|
||||
@Column('decimal', {
|
||||
name: 'monto',
|
||||
precision: 10,
|
||||
scale: 2,
|
||||
nullable: false,
|
||||
})
|
||||
monto: string;
|
||||
|
||||
@Column({ name: 'numero_hojas', type: 'int', nullable: false, default: 0 })
|
||||
numero_hojas: number;
|
||||
|
||||
@Column({
|
||||
name: 'fecha_operacion',
|
||||
type: 'timestamp',
|
||||
default: () => 'CURRENT_TIMESTAMP',
|
||||
nullable: false,
|
||||
})
|
||||
fecha_operacion: Date;
|
||||
|
||||
@Column({ name: 'id_cuenta', type: 'int', nullable: false })
|
||||
id_cuenta: number;
|
||||
|
||||
@Column({ name: 'id_servicio', type: 'int', nullable: false })
|
||||
id_servicio: number;
|
||||
|
||||
@Column({ name: 'id_usuario', type: 'int', nullable: false })
|
||||
id_usuario: number;
|
||||
|
||||
@Column({ name: 'id_perido', type: 'int', default: null })
|
||||
id_periodo: number;
|
||||
}
|
||||
|
||||
/* `id_detalle_servicio` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`monto` decimal(10,2) NOT NULL,
|
||||
`numero_hojas` int(11) NOT NULL DEFAULT 0,
|
||||
`fecha_operacion` timestamp NOT NULL DEFAULT current_timestamp(),
|
||||
`id_cuenta` int(9) unsigned zerofill NOT NULL,
|
||||
`id_servicio` int(11) NOT NULL,
|
||||
`id_usuario` int(11) NOT NULL,
|
||||
`id_periodo` int(11) DEFAULT NULL,*/
|
||||
@@ -0,0 +1 @@
|
||||
export class CreatePeriodoDto {}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { PartialType } from '@nestjs/mapped-types';
|
||||
import { CreatePeriodoDto } from './create-periodo.dto';
|
||||
|
||||
export class UpdatePeriodoDto extends PartialType(CreatePeriodoDto) {}
|
||||
@@ -0,0 +1 @@
|
||||
export class Periodo {}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { PeriodoController } from './periodo.controller';
|
||||
import { PeriodoService } from './periodo.service';
|
||||
|
||||
describe('PeriodoController', () => {
|
||||
let controller: PeriodoController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
controllers: [PeriodoController],
|
||||
providers: [PeriodoService],
|
||||
}).compile();
|
||||
|
||||
controller = module.get<PeriodoController>(PeriodoController);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(controller).toBeDefined();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,34 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
||||
import { PeriodoService } from './periodo.service';
|
||||
import { CreatePeriodoDto } from './dto/create-periodo.dto';
|
||||
import { UpdatePeriodoDto } from './dto/update-periodo.dto';
|
||||
|
||||
@Controller('periodo')
|
||||
export class PeriodoController {
|
||||
constructor(private readonly periodoService: PeriodoService) {}
|
||||
|
||||
@Post()
|
||||
create(@Body() createPeriodoDto: CreatePeriodoDto) {
|
||||
return this.periodoService.create(createPeriodoDto);
|
||||
}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.periodoService.findAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.periodoService.findOne(+id);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
update(@Param('id') id: string, @Body() updatePeriodoDto: UpdatePeriodoDto) {
|
||||
return this.periodoService.update(+id, updatePeriodoDto);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
remove(@Param('id') id: string) {
|
||||
return this.periodoService.remove(+id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { PeriodoService } from './periodo.service';
|
||||
import { PeriodoController } from './periodo.controller';
|
||||
|
||||
@Module({
|
||||
controllers: [PeriodoController],
|
||||
providers: [PeriodoService],
|
||||
})
|
||||
export class PeriodoModule {}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { PeriodoService } from './periodo.service';
|
||||
|
||||
describe('PeriodoService', () => {
|
||||
let service: PeriodoService;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [PeriodoService],
|
||||
}).compile();
|
||||
|
||||
service = module.get<PeriodoService>(PeriodoService);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(service).toBeDefined();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,26 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CreatePeriodoDto } from './dto/create-periodo.dto';
|
||||
import { UpdatePeriodoDto } from './dto/update-periodo.dto';
|
||||
|
||||
@Injectable()
|
||||
export class PeriodoService {
|
||||
create(createPeriodoDto: CreatePeriodoDto) {
|
||||
return 'This action adds a new periodo';
|
||||
}
|
||||
|
||||
findAll() {
|
||||
return `This action returns all periodo`;
|
||||
}
|
||||
|
||||
findOne(id: number) {
|
||||
return `This action returns a #${id} periodo`;
|
||||
}
|
||||
|
||||
update(id: number, updatePeriodoDto: UpdatePeriodoDto) {
|
||||
return `This action updates a #${id} periodo`;
|
||||
}
|
||||
|
||||
remove(id: number) {
|
||||
return `This action removes a #${id} periodo`;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export class CreateServicioDto {}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { PartialType } from '@nestjs/mapped-types';
|
||||
import { CreateServicioDto } from './create-servicio.dto';
|
||||
|
||||
export class UpdateServicioDto extends PartialType(CreateServicioDto) {}
|
||||
@@ -0,0 +1 @@
|
||||
export class Servicio {}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { ServicioController } from './servicio.controller';
|
||||
import { ServicioService } from './servicio.service';
|
||||
|
||||
describe('ServicioController', () => {
|
||||
let controller: ServicioController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
controllers: [ServicioController],
|
||||
providers: [ServicioService],
|
||||
}).compile();
|
||||
|
||||
controller = module.get<ServicioController>(ServicioController);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(controller).toBeDefined();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,34 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
||||
import { ServicioService } from './servicio.service';
|
||||
import { CreateServicioDto } from './dto/create-servicio.dto';
|
||||
import { UpdateServicioDto } from './dto/update-servicio.dto';
|
||||
|
||||
@Controller('servicio')
|
||||
export class ServicioController {
|
||||
constructor(private readonly servicioService: ServicioService) {}
|
||||
|
||||
@Post()
|
||||
create(@Body() createServicioDto: CreateServicioDto) {
|
||||
return this.servicioService.create(createServicioDto);
|
||||
}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.servicioService.findAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.servicioService.findOne(+id);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
update(@Param('id') id: string, @Body() updateServicioDto: UpdateServicioDto) {
|
||||
return this.servicioService.update(+id, updateServicioDto);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
remove(@Param('id') id: string) {
|
||||
return this.servicioService.remove(+id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ServicioService } from './servicio.service';
|
||||
import { ServicioController } from './servicio.controller';
|
||||
|
||||
@Module({
|
||||
controllers: [ServicioController],
|
||||
providers: [ServicioService],
|
||||
})
|
||||
export class ServicioModule {}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { ServicioService } from './servicio.service';
|
||||
|
||||
describe('ServicioService', () => {
|
||||
let service: ServicioService;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [ServicioService],
|
||||
}).compile();
|
||||
|
||||
service = module.get<ServicioService>(ServicioService);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(service).toBeDefined();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,26 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CreateServicioDto } from './dto/create-servicio.dto';
|
||||
import { UpdateServicioDto } from './dto/update-servicio.dto';
|
||||
|
||||
@Injectable()
|
||||
export class ServicioService {
|
||||
create(createServicioDto: CreateServicioDto) {
|
||||
return 'This action adds a new servicio';
|
||||
}
|
||||
|
||||
findAll() {
|
||||
return `This action returns all servicio`;
|
||||
}
|
||||
|
||||
findOne(id: number) {
|
||||
return `This action returns a #${id} servicio`;
|
||||
}
|
||||
|
||||
update(id: number, updateServicioDto: UpdateServicioDto) {
|
||||
return `This action updates a #${id} servicio`;
|
||||
}
|
||||
|
||||
remove(id: number) {
|
||||
return `This action removes a #${id} servicio`;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user