Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…_da_Saude into T08
  • Loading branch information
AGoretti committed Nov 20, 2020
2 parents 3c26ead + cbbd576 commit fa4db7c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
9 changes: 8 additions & 1 deletion backend/DiarioSaude/controllers/auth.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,16 @@ exports.signin = (req, res) => {
};

exports.getUser = (req, res) => {
console.log(req)
Person.getPerson(req.params.cpf, (err, user) => {
if(err) res.json({status: 400, message: err})
res.json({status:200, user: {name: user.name, id: user.id, birthDate: user.birthDate, gender: user.gender}})
})
}

exports.getAll = (req, res) => {
Person.find((err, users) => {
if (err) res.json({status:400, message:err})

res.json({status: 200, users: users})
})
}
8 changes: 8 additions & 0 deletions backend/DiarioSaude/controllers/group.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,11 @@ exports.addMember = (req, res) => {
res.json({status: 200, message: "Member added"})
})
}

exports.listMember = (req, res) => {
Group.findById(req.body.group_id, (err, group) => {
if(err) res.json({status:400, message: err})

res.json({status:200, members: group.users})
})
}
1 change: 1 addition & 0 deletions backend/DiarioSaude/routes/auth.route.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ module.exports = function(app) {

app.post("/auth/signin", controller.signin);
app.get('/user/:cpf', controller.getUser)
app.get('/users', controller.getAll)
};

3 changes: 3 additions & 0 deletions backend/DiarioSaude/routes/group.route.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ module.exports = (app) => {
app.post('/group/member', group.addMember);
// Add Form
app.post('/group/form', group.addForm);

// List member
app.get('/members', group.listMember)
}

0 comments on commit fa4db7c

Please sign in to comment.