Skip to content
Snippets Groups Projects
Commit 4476d73a authored by ems19's avatar ems19
Browse files

[ADD] Rascunho

parent 03a18a3a
No related branches found
No related tags found
4 merge requests!377prd_version of simcaq,!373merge dev -> homologa,!370Dev migration,!369Postgres migration
...@@ -70,7 +70,6 @@ pubApp.post('/', upload.single('file'), async (req, res, next) => { ...@@ -70,7 +70,6 @@ pubApp.post('/', upload.single('file'), async (req, res, next) => {
if(!_file_id) if(!_file_id)
console.log("NAO ARQUIVO");} console.log("NAO ARQUIVO");}
let data = JSON.parse(req.body.data); let data = JSON.parse(req.body.data);
console.log(data);
let pb = await Publication.create({ let pb = await Publication.create({
id: 0, id: 0,
filter: data.categoria, filter: data.categoria,
...@@ -97,19 +96,25 @@ pubApp.post('/', upload.single('file'), async (req, res, next) => { ...@@ -97,19 +96,25 @@ pubApp.post('/', upload.single('file'), async (req, res, next) => {
req.result = pb.toJSON; req.result = pb.toJSON;
}, response('publication')); }, response('publication'));
pubApp.post('/rascunho', passport.authenticate('bearer', { session: false }), async (req, res, next) => { pubApp.post('/rascunho', upload.single('file'), passport.authenticate('bearer', { session: false }), async (req, res, next) => {
let _file_id = null
if(req.file){
_file_id = await fileWorker.uploadFile(req.file);
if(!_file_id)
console.log("NAO ARQUIVO");}
let data = JSON.parse(req.body.data);
let pb = await Publication.create({ let pb = await Publication.create({
id: 0, id: 0,
filter: req.body.categoria, filter: data.categoria,
title: req.body.title, title: data.title,
authors: req.body.autores, authors: data.autores,
organization: req.body.organizacao, organization: data.organizacao,
year: req.body.ano, year: data.ano,
text: req.body.texto, text: data.texto,
link: req.body.link, link: data.link,
upload: req.body.upload, upload: _file_id,
is_draft: true, is_draft: true,
is_homepage: req.body.homepage is_homepage: data.homepage
}).catch(function (err) { }).catch(function (err) {
log.error(err); log.error(err);
let errors = []; let errors = [];
...@@ -128,7 +133,7 @@ pubApp.post('/rascunho', passport.authenticate('bearer', { session: false }), as ...@@ -128,7 +133,7 @@ pubApp.post('/rascunho', passport.authenticate('bearer', { session: false }), as
req.result = pb.toJSON(); req.result = pb.toJSON();
next(); next();
}); },response('rascunho'));
pubApp.put('/:id', passport.authenticate('bearer', { session: false }), async (req, res, next) => { pubApp.put('/:id', passport.authenticate('bearer', { session: false }), async (req, res, next) => {
let pb = await Publication.findByPk(req.params.id).catch(function (err) { let pb = await Publication.findByPk(req.params.id).catch(function (err) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment