Commit 1bbd1d88 authored by D’jalmar Gutierrez Titirico's avatar D’jalmar Gutierrez Titirico 🚲

cambios a las rutas

parent c05ff73a
Modulo Personal
===================
Cargos
------
> **Titulo**
Mostrar los Cargos
> **URL**
/cargos
> **Metodo**
<kbd>GET</kbd>
> **Respuesta correcta**
> **Codigo:** 200
**Contenido:**
```json
[
{
"_id": 1,
"nombre": "Director general",
"fecha_creacion": "2016-03-14T15:06:36.051Z",
"fecha_modificacion": "2016-03-14T15:06:36.051Z"
},
{
"_id": 2,
"nombre": "Jefe de personal",
"fecha_creacion": "2016-03-14T15:28:20.063Z",
"fecha_modificacion": "2016-03-14T15:28:20.063Z"
}
]
```
> **Respuesta de error**
**Codigo:** 500
**Contenido:** Error en el servidor.
**Codigo:** 4xx
**Contenido:** Error en el servidor.
**Crear un cargo**
----
* **URL**
/cargos
* **Método:**
`POST`
* **Parametros del cuerpo**
``{
"nombre": "Director general"
}``
* **Respuesta correcta:**
<_What should the status code be on success and is there any returned data? This is useful when people need to to know what their callbacks should expect!_>
* **Code:** 200
**Content:**
```javascript
{
"_id": 1,
"nombre": "Director general",
"fecha_modificacion": "2016-03-14T15:06:36.051Z",
"fecha_creacion": "2016-03-14T15:06:36.051Z"
}
```
* **Error Response:**
<_Most endpoints will have many ways they can fail. From unauthorized access, to wrongful parameters etc. All of those should be liste d here. It might seem repetitive, but it helps prevent assumptions from being made where they should be._>
* **Code:** 401 UNAUTHORIZED <br />
**Content:** `{ error : "Log in" }`
OR
* **Code:** 422 UNPROCESSABLE ENTRY <br />
**Content:** `{ error : "Email Invalid" }`
* **Sample Call:**
<_Just a sample call to your endpoint in a runnable format ($.ajax call or a curl request) - this makes life easier and more predictable._>
* **Notes:**
<_This is where all uncertainties, commentary, discussion etc. can go. I recommend timestamping and identifying oneself when leaving comments here._>
......@@ -14,7 +14,13 @@ export default function(sequelize, DataTypes) {
primaryKey: true,
autoIncrement: true
},
nombre: DataTypes.STRING
nombre: {
type: DataTypes.STRING,
allowNull: false,
validate: {
notEmpty: true
}
}
}, {
schema:'public',
tableName: 'cargo',
......
......@@ -6,10 +6,14 @@ var controller = require('./postulacion.controller');
var router = express.Router();
router.get('/', controller.index);
router.get('/:idPostulante',controller.postulante);
router.get('/:id', controller.show);
router.post('/', controller.create);
router.put('/:id', controller.update);
router.patch('/:id', controller.update);
router.delete('/:id', controller.destroy);
module.exports = router;
......@@ -11,6 +11,7 @@
import _ from 'lodash';
import {Postulacion} from '../../sqldb';
import {Postulante} from '../../sqldb';
function respondWithResult(res, statusCode) {
statusCode = statusCode || 200;
......@@ -103,11 +104,27 @@ export function update(req, res) {
// Deletes a Postulacion from the DB
export function destroy(req, res) {
Postulacion.find({
where: {
_id: req.params.id
}
})
where: {
_id: req.params.id
}
})
.then(handleEntityNotFound(res))
.then(removeEntity(res))
.catch(handleError(res));
}
export function postulante(req, res) {
Postulante.find({
where: {
_id: req.params.idPostulante
}
})
.then(handleEntityNotFound(res))
.then(function (postulante) {
postulante.getPostulaciones()
.then(function (postulaciones) {
return res.json(postulaciones);
})
})
.catch(handleError(res));
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment