demo rector
This commit is contained in:
@@ -1,30 +0,0 @@
|
||||
import { getManager } from 'typeorm'
|
||||
import { Ayuda, AyudaRequest } from '@db/entity/Ayuda'
|
||||
import { TipoProblema } from '@db/entity/TipoProblema'
|
||||
|
||||
export class AyudaController {
|
||||
private ayudaRepository: any
|
||||
private tipoProblemaRepository: any
|
||||
constructor () {
|
||||
this.ayudaRepository = getManager().getRepository(Ayuda)
|
||||
this.tipoProblemaRepository = getManager().getRepository(TipoProblema)
|
||||
}
|
||||
|
||||
async create (request: AyudaRequest) {
|
||||
const tipoProblema = this.tipoProblemaRepository.findOne(
|
||||
request.tipoProblema
|
||||
)
|
||||
request.tipoProblema = tipoProblema
|
||||
const ayuda = this.ayudaRepository.create(request)
|
||||
const result = await this.ayudaRepository.save(ayuda)
|
||||
return result
|
||||
}
|
||||
|
||||
async getOne (id: number) {
|
||||
return await this.ayudaRepository.findOne(id)
|
||||
}
|
||||
|
||||
async getAll () {
|
||||
return await this.ayudaRepository.findOne()
|
||||
}
|
||||
}
|
||||
|
||||
+68
-15
@@ -123,23 +123,76 @@ export class UsuarioController {
|
||||
carrera: 'Matematicas aplicadas',
|
||||
interno: true
|
||||
}
|
||||
const usuarioExterno = {
|
||||
nombre: 'Paulina',
|
||||
apellidoPaterno: 'Guerrero',
|
||||
apellidoMaterno: 'Lopez',
|
||||
institucion: 'FES Iztacala',
|
||||
carrera: 'Biologia',
|
||||
interno: false
|
||||
const alumnos = [
|
||||
{
|
||||
cuenta: 124493,
|
||||
nombre: 'Nora',
|
||||
apellidoPaterno: 'Goris',
|
||||
apellidoMaterno: 'Mayans',
|
||||
institucion: 'FES Acatlan',
|
||||
carrera: 'Sociologia',
|
||||
interno: false
|
||||
},
|
||||
{
|
||||
cuenta: 91770,
|
||||
nombre: 'Manuel',
|
||||
apellidoPaterno: 'Martinez',
|
||||
apellidoMaterno: 'Justo',
|
||||
institucion: 'FES Acatlan',
|
||||
carrera: 'Derecho',
|
||||
interno: false
|
||||
},
|
||||
{
|
||||
cuenta: 123456789,
|
||||
nombre: 'Enrique',
|
||||
apellidoPaterno: 'Graue',
|
||||
apellidoMaterno: 'Wiechers',
|
||||
institucion: 'Facultad de Mediciona',
|
||||
carrera: 'Medicina',
|
||||
interno: false
|
||||
},
|
||||
{
|
||||
cuenta: 40108,
|
||||
nombre: 'Fernando',
|
||||
apellidoPaterno: 'Martinez',
|
||||
apellidoMaterno: 'Ramirez',
|
||||
institucion: 'Facultad de Ciencias',
|
||||
carrera: 'Matematicas',
|
||||
interno: false
|
||||
},
|
||||
{
|
||||
cuenta: 415112133,
|
||||
nombre: 'arturo',
|
||||
apellidoPaterno: 'Guerrero',
|
||||
apellidoMaterno: 'Lopez',
|
||||
institucion: 'FES Iztacala',
|
||||
carrera: 'Biologia',
|
||||
interno: false
|
||||
}
|
||||
]
|
||||
for (let index = 0; index < alumnos.length; index++) {
|
||||
if (alumnos[index].cuenta === +usuarioId) {
|
||||
res.status(200).json(alumnos[index])
|
||||
return
|
||||
}
|
||||
}
|
||||
// const usuarioExterno = {
|
||||
// nombre: 'Paulina',
|
||||
// apellidoPaterno: 'Guerrero',
|
||||
// apellidoMaterno: 'Lopez',
|
||||
// institucion: 'FES Iztacala',
|
||||
// carrera: 'Biologia',
|
||||
// interno: false
|
||||
// }
|
||||
|
||||
if (usuarios.includes(usuarioId)) {
|
||||
res.status(200).json(usuarioInterno)
|
||||
return
|
||||
}
|
||||
if (externos.includes(usuarioId)) {
|
||||
res.status(200).json(usuarioExterno)
|
||||
return
|
||||
}
|
||||
// if (usuarios.includes(usuarioId)) {
|
||||
// res.status(200).json(usuarioInterno)
|
||||
// return
|
||||
// }
|
||||
// if (externos.includes(usuarioId)) {
|
||||
// res.status(200).json(usuarioExterno)
|
||||
// return
|
||||
// }
|
||||
res.status(400).json({ err: 'no se encontro un usuario' })
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user