added new Ep to servicio and periodo
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
import { PeriodoService } from './periodo.service';
|
||||
|
||||
@Controller('periodo')
|
||||
export class PeriodoController {
|
||||
constructor(private readonly periodoService:PeriodoService){}
|
||||
|
||||
@Get()
|
||||
findAll(){
|
||||
return this.periodoService.findAll();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { PeriodoService } from './periodo.service';
|
||||
import { PeriodoController } from './periodo.controller';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { Periodo } from './entities/periodo.entity';
|
||||
|
||||
@Module({
|
||||
imports:[TypeOrmModule.forFeature([Periodo])],
|
||||
controllers: [PeriodoController],
|
||||
providers: [PeriodoService],
|
||||
})
|
||||
|
||||
@@ -1,7 +1,20 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CreatePeriodoDto } from './dto/create-periodo.dto';
|
||||
import { UpdatePeriodoDto } from './dto/update-periodo.dto';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Periodo } from './entities/periodo.entity';
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
@Injectable()
|
||||
export class PeriodoService {
|
||||
constructor(
|
||||
@InjectRepository(Periodo)
|
||||
private readonly periodoRepository: Repository<Periodo>,
|
||||
) {}
|
||||
|
||||
async findOne() {
|
||||
return this.periodoRepository.findOne({ where: {} });
|
||||
}
|
||||
|
||||
async findAll(){
|
||||
return this.periodoRepository.find();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,9 @@ export class Recibo {
|
||||
@Column({ name: 'fecha_recibo', type: 'date', nullable: false })
|
||||
fecha_recibo: Date;
|
||||
|
||||
@Column({ name: 'fecha_registro', type: 'timestamp', nullable: false })
|
||||
fecha_registro: Date;
|
||||
|
||||
@ManyToOne(() => Alumno, (alum) => alum.id_cuenta, { eager: true })
|
||||
@JoinColumn({ name: 'id_cuenta' })
|
||||
alum: Alumno;
|
||||
|
||||
@@ -25,7 +25,6 @@ export class ReciboService {
|
||||
}
|
||||
|
||||
async findByDateRange(desde: string, hasta: string) {
|
||||
// Convertimos strings a objetos Date
|
||||
const fechaDesde = new Date(desde);
|
||||
const fechaHasta = new Date(hasta);
|
||||
|
||||
|
||||
@@ -1,35 +1,12 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
||||
import { Controller, Get } 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);
|
||||
}
|
||||
}
|
||||
//IO
|
||||
@@ -1,8 +1,11 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ServicioService } from './servicio.service';
|
||||
import { ServicioController } from './servicio.controller';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { Servicio } from './entities/servicio.entity';
|
||||
|
||||
@Module({
|
||||
imports:[TypeOrmModule.forFeature([Servicio])],
|
||||
controllers: [ServicioController],
|
||||
providers: [ServicioService],
|
||||
})
|
||||
|
||||
@@ -1,26 +1,16 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CreateServicioDto } from './dto/create-servicio.dto';
|
||||
import { UpdateServicioDto } from './dto/update-servicio.dto';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Servicio } from './entities/servicio.entity';
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
@Injectable()
|
||||
export class ServicioService {
|
||||
create(createServicioDto: CreateServicioDto) {
|
||||
return 'This action adds a new servicio';
|
||||
}
|
||||
constructor(
|
||||
@InjectRepository(Servicio)
|
||||
private readonly ServicioRepository: Repository<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`;
|
||||
return this.ServicioRepository.find();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,9 @@ export class UserService {
|
||||
const user = await this.userRepository.findOne({
|
||||
where: { usuario, password },
|
||||
});
|
||||
console.log(usuario);
|
||||
console.log(password);
|
||||
console.log(user);
|
||||
|
||||
if (!user) {
|
||||
throw new NotFoundException(`El usuario o la contraseña es incorrecta`);
|
||||
@@ -38,7 +41,11 @@ export class UserService {
|
||||
async Login(data: Login, res: Response) {
|
||||
const user = await this.findOneByNameandPassword(data);
|
||||
|
||||
const payload = { id: user.id_usuario, usuario: user.usuario, role:user.perfil.perfil};
|
||||
const payload = {
|
||||
id: user.id_usuario,
|
||||
usuario: user.usuario,
|
||||
role: user.perfil.perfil,
|
||||
};
|
||||
const token = await this.jwtService.signAsync(payload);
|
||||
|
||||
res.cookie('token', token, {
|
||||
@@ -88,9 +95,9 @@ export class UserService {
|
||||
throw new NotFoundException('Perfil not found');
|
||||
}
|
||||
|
||||
const fecha_registro = new Date()
|
||||
const fecha_registro = new Date();
|
||||
|
||||
const datauser = { ...rest, perfil ,fecha_registro};
|
||||
const datauser = { ...rest, perfil, fecha_registro };
|
||||
|
||||
const usercreate = this.userRepository.create(datauser);
|
||||
return this.userRepository.save(usercreate);
|
||||
@@ -101,14 +108,17 @@ export class UserService {
|
||||
usuario: (await this.findOne(id_usuario)).usuario,
|
||||
password: data.password,
|
||||
});
|
||||
console.log(user);
|
||||
|
||||
user.password = data.newPassword;
|
||||
return this.userRepository.save(user);
|
||||
}
|
||||
async getAll(){
|
||||
|
||||
async getAll() {
|
||||
return this.userRepository.find();
|
||||
}
|
||||
async getAllPerfil(){
|
||||
|
||||
async getAllPerfil() {
|
||||
return this.perfilRepository.find();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user