Skip to content

Commit

Permalink
feat: ✨ adds method to find a record with a specific sei number fga-e…
Browse files Browse the repository at this point in the history
…ps-mds/2021.1-Oraculo#185

Co-authored-by: Joao Paulo Lima da Silva <jpaulo.on@gmail.com>
  • Loading branch information
lucasvmx and jpaulohe4rt committed Nov 9, 2021
1 parent e7832a4 commit 40e786a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Controller/RecordController.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,22 @@ async function reopenRecord(req, res) {
}
}

async function findRecordWithSeiNumber(req, res) {
const { sei_number } = req.body;
const seiNumber = String(sei_number);

if (!seiNumber.length === 0) {
return res.status(400).json({ error: "empty sei number provided" });
}

const record = await Record.findOne({ where: { sei_number: seiNumber } });
if (!record) {
return res.status(404).json({ found: false });
}

return res.status(200).json({ found: true });
}

module.exports = {
getRecordByID,
getAllRecords,
Expand All @@ -529,4 +545,5 @@ module.exports = {
editRecord,
closeRecord,
reopenRecord,
findRecordWithSeiNumber,
};

0 comments on commit 40e786a

Please sign in to comment.