forked from lucasanthony/tcc-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from codexjr-dev/dev
Sprint 3: Dev to Main
- Loading branch information
Showing
10 changed files
with
226 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,50 @@ | ||
const { Schema, model } = require('mongoose'); | ||
const Ej = require('@ej/Ej') | ||
const { Schema, model } = require("mongoose"); | ||
const Ej = require("@ej/Ej"); | ||
|
||
const LinkSchema = new Schema({ | ||
const LinkSchema = new Schema( | ||
{ | ||
name: { | ||
type: String, | ||
required: true | ||
type: String, | ||
required: true, | ||
}, | ||
url: { | ||
type: String, | ||
required: true | ||
type: String, | ||
required: true, | ||
}, | ||
tags: [{ | ||
tags: [ | ||
{ | ||
type: String, | ||
enum: ['importante', 'treinamento'], | ||
required: false | ||
}], | ||
enum: ["Importante", "Treinamento", "Documentação"], | ||
required: false, | ||
}, | ||
], | ||
ej: { | ||
type: Schema.Types.ObjectId, | ||
ref: Ej, | ||
required: true | ||
type: Schema.Types.ObjectId, | ||
ref: Ej, | ||
required: true, | ||
}, | ||
departments: [{ | ||
departments: [ | ||
{ | ||
type: String, | ||
enum: ['projetos', 'qualidade', 'presedência', 'pessoas'], | ||
required: false | ||
}], | ||
enum: [ | ||
"Presidência", | ||
"Gente & Gestão", | ||
"Projetos", | ||
"Qualidade", | ||
"Marketing", | ||
"Negócios", | ||
], | ||
required: false, | ||
}, | ||
], | ||
observations: { | ||
type: String, | ||
required: false | ||
} | ||
}, | ||
{ | ||
timestamps: true, | ||
}); | ||
type: String, | ||
required: false, | ||
}, | ||
}, | ||
{ | ||
timestamps: true, | ||
} | ||
); | ||
|
||
module.exports = model('Link', LinkSchema); | ||
module.exports = model("Link", LinkSchema); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,49 @@ | ||
const { save, findByEj, remove, update } = require('./MemberService'); | ||
const { save, findByEj, remove, update } = require("./MemberService"); | ||
|
||
module.exports = { | ||
async save(req, res) { | ||
try { | ||
const member = await save(req.body, req.ejId); | ||
return res.status(201).send({ member: member }); | ||
} catch (error) { | ||
return res.status(500).send({ error: error.message }); | ||
} | ||
}, | ||
async save(req, res) { | ||
try { | ||
const member = await save(req.body, req.ejId); | ||
return res.status(201).send({ member: member }); | ||
} catch (error) { | ||
return res.status(500).send({ error: error.message }); | ||
} | ||
}, | ||
|
||
async findByEj(req, res) { | ||
try { | ||
const members = await findByEj(req.ejId); | ||
return res.status(200).send({ members: members }); | ||
} catch (error) { | ||
return res.status(500).send({ error: error.message }); | ||
} | ||
}, | ||
async findByEj(req, res) { | ||
try { | ||
const members = await findByEj(req); | ||
return res.status(200).send({ members: members }); | ||
} catch (error) { | ||
return res.status(500).send({ error: error.message }); | ||
} | ||
}, | ||
|
||
async remove(req, res) { | ||
try { | ||
const removedMember = await remove(req.params.id); | ||
return res.status(200).send({ member: removedMember, message: 'Membero removido com sucesso!' }); | ||
} catch (error) { | ||
return res.status(500).send({ error: error.message }); | ||
} | ||
}, | ||
async remove(req, res) { | ||
try { | ||
const removedMember = await remove(req.params.id); | ||
return res | ||
.status(200) | ||
.send({ | ||
member: removedMember, | ||
message: "Membero removido com sucesso!", | ||
}); | ||
} catch (error) { | ||
return res.status(500).send({ error: error.message }); | ||
} | ||
}, | ||
|
||
async update(req, res) { | ||
try { | ||
const updatedMember = await update(req.params.id, req.body); | ||
return res.status(200).send({ member: updatedMember, message: 'Membro atualizado com sucesso!' }); | ||
} catch (error) { | ||
return res.status(500).send({ error: error.message }); | ||
} | ||
async update(req, res) { | ||
try { | ||
const updatedMember = await update(req.params.id, req.body); | ||
return res | ||
.status(200) | ||
.send({ | ||
member: updatedMember, | ||
message: "Membro atualizado com sucesso!", | ||
}); | ||
} catch (error) { | ||
return res.status(500).send({ error: error.message }); | ||
} | ||
} | ||
}, | ||
}; |
Oops, something went wrong.