Merge branch 'Lino' of https://github.com/IO420/api-nexus into Axel

This commit is contained in:
2025-09-17 14:35:31 -06:00
32 changed files with 523 additions and 266 deletions
+3 -2
View File
@@ -1,5 +1,5 @@
import { Type } from 'class-transformer';
import { IsDate, IsNotEmpty, IsNumber, IsString } from 'class-validator';
import { IsEmail, IsNotEmpty, IsNumber, IsString } from 'class-validator';
export class CreateStudentDto {
@IsNotEmpty()
@@ -17,6 +17,7 @@ export class CreateStudentDto {
@IsNumber()
id_carrera: number;
@IsEmail()
@IsString()
correo: string;
}
+1 -1
View File
@@ -26,7 +26,7 @@ export class Student {
scale: 2,
default: 0.0,
})
credito: string;
credito: number;
@Column({
name: 'fecha_actualizacion_credito',
+1 -14
View File
@@ -3,13 +3,10 @@ import {
Get,
Post,
Body,
Patch,
Param,
Delete,
} from '@nestjs/common';
import { StudentService } from './student.service';
import { CreateStudentDto } from './dto/create-student.dto';
import { UpdateStudentDto } from './dto/update-student.dto';
import { Student } from './entities/student.entity';
@Controller('student')
@@ -27,17 +24,7 @@ export class StudentController {
}
@Get(':id')
findOne(@Param('id') id: string) {
findOne(@Param('id') id: number) {
return this.studentService.findOne(+id);
}
@Patch(':id')
update(@Param('id') id: string, @Body() updateStudentDto: UpdateStudentDto) {
return this.studentService.update(+id, updateStudentDto);
}
@Delete(':id')
remove(@Param('id') id: string) {
return this.studentService.remove(+id);
}
}
+16 -5
View File
@@ -2,7 +2,7 @@ import { Injectable, NotFoundException } from '@nestjs/common';
import { CreateStudentDto } from './dto/create-student.dto';
import { UpdateStudentDto } from './dto/update-student.dto';
import { Student } from './entities/student.entity';
import { Repository } from 'typeorm';
import { EntityManager, Repository } from 'typeorm';
import { InjectRepository } from '@nestjs/typeorm';
@Injectable()
@@ -32,11 +32,22 @@ export class StudentService {
return student;
}
update(id: number, updateStudentDto: UpdateStudentDto) {
return `This action updates a #${id} student`;
async GetCredit(id_cuenta: number): Promise<Student['credito']> {
const student = await this.findOne(id_cuenta);
return student.credito;
}
remove(id: number) {
return `This action removes a #${id} student`;
async UpdateCredit(
id_cuenta: number,
credit: number,
manager: EntityManager,
) {
const repo = manager.getRepository(Student);
return await repo
.createQueryBuilder()
.update()
.set({ credito: () => `credito - ${credit}` })
.where({ id_cuenta })
.execute();
}
}