Skip to content

Commit

Permalink
Rota de Edição de Tipo de ACC
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavocrvls committed Feb 21, 2021
1 parent 4d191bf commit 7d58a49
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 12 deletions.
39 changes: 27 additions & 12 deletions src/controllers/TipoDeAccController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ export default {
const { id } = req.params;
const tipoDeAccRepository = getRepository(TipoDeAcc);

const tipoDeAcc = await tipoDeAccRepository.findOne({
const tipoDeACC = await tipoDeAccRepository.findOne({
relations: ['unidade_de_medida'],
where: {
id,
},
});

return res.json({ tipoDeAcc });
return res.json({ tipoDeACC });
},

/**
Expand Down Expand Up @@ -99,6 +99,31 @@ export default {
return res.status(201).json(tipoDeAcc);
},

async delete(req: Request, res: Response): Promise<any> {
const { id } = req.params;

const tipoDeAccRepository = getRepository(TipoDeAcc);

const tipoDeACC = await tipoDeAccRepository.delete({ id: Number(id) });

res.send({ tipoDeACC });
},

async update(req: Request, res: Response): Promise<any> {
const { id } = req.params;

const tipoDeACCRepository = getRepository(TipoDeAcc);

const tipoDeACC = await tipoDeACCRepository
.createQueryBuilder('tipo-de-acc')
.update(TipoDeAcc)
.set(req.body)
.where({ id: Number(id) })
.execute();

res.json({ tipoDeACC });
},

async massCreate(req: Request, res: Response): Promise<any> {
const { tiposDeAcc } = req.body;

Expand Down Expand Up @@ -168,14 +193,4 @@ export default {

res.json(tiposDeAcc);
},

async delete(req: Request, res: Response): Promise<any> {
const { id } = req.params;

const tipoDeAccRepository = getRepository(TipoDeAcc);

const tipoDeACC = await tipoDeAccRepository.delete({ id: Number(id) });

res.send({ tipoDeACC });
},
};
6 changes: 6 additions & 0 deletions src/routes/tipos_de_acc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,10 @@ routes.delete(
TipoDeAccController.delete,
);

routes.put(
'/:id',
verifyToken([PERFIL.ADMINISTRADOR]),
TipoDeAccController.update,
);

export default routes;

1 comment on commit 7d58a49

@vercel
Copy link

@vercel vercel bot commented on 7d58a49 Feb 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.