Commit 260a3ac5 authored by Odair M.'s avatar Odair M. Committed by Matheus Horstmann

Refatora backend

parent af9e1d76
......@@ -232,6 +232,21 @@ module.exports = function(Turma) {
* @param {Function(Error, object)} callback
*/
Turma.beforeRemote("create_turma", function(ctx,a,next){
console.log("Antes do ctx",ctx.req,"aaaaaaaaaaaaaaaaaaaa")
const _ctx = {
"options": {
"accessToken": {"userId":ctx.req.accessToken.userId }
},
"instance": ctx.args.turma
}
console.log("---------------------- Inicio -----------------------")
console.log("Meu ctx",_ctx)
console.log("---------------------- Fim -----------------------")
acl_custom.aclSecretarioDpto(["Turma","codigo"],_ctx,next)
})
Turma.create_turma = async function(turma) {
//verifica se existe o campo id, se sim encontra modelo correspondente,
//caso contrário cria
......
......@@ -2,14 +2,14 @@
set -e
# if [ "$1" = 'DEVELOPMENT' ]; then
# /usr/local/bin/node /app/bin/automigrate.js
# # echo "oi"
# fi
# if [ "$1" = 'PRODUCTION' ]; then
# /usr/local/bin/node /app/bin/automigrate.js
# fi
#if [ "$1" = 'DEVELOPMENT' ]; then
# /usr/local/bin/node /app/bin/automigrate.js
# # echo "oi"
#fi
#
#if [ "$1" = 'PRODUCTION' ]; then
# /usr/local/bin/node /app/bin/automigrate.js
#fi
# echo "while true; do sleep 2; done" >> /app/test.sh && chmod +x /app/test.sh
# /bin/bash /app/test.sh
......
......@@ -26,13 +26,15 @@ async function aclSecretarioDpto(_model,ctx,next) {
function(user,instance,secretario,callback) { // pega a instancia no banco
app.models[_model[0]].findById(instance[_model[1]],(err,obj)=>{
console.log("obj",obj)
if(obj)
return callback(err,user,instance,secretario,obj)
else
return callback(err,user,instance,secretario,instance)
return callback(null,user,instance,secretario,instance)
})
},
function(user,instance,secretario,modelo,callback) { // pega o departamento da instancia
console.log("modelo",modelo)
app.models.Departamento.findById(modelo.departamentoCod,(err,obj)=>{
if(!obj)
return callback(true,{"code":3,"msg":"Departamento não existe"})
......@@ -49,13 +51,17 @@ async function aclSecretarioDpto(_model,ctx,next) {
], function(err,result){
if(err) {
if(result) {
if(result.code == 3) //não salva
if(result.code == 3){//não salva
console.log("code 333")
return next(new Error(result.msg))
}
if(result.code == 2 || result.code == 1)
return next()
}
}
console.log("como entrei aqui")
return next()
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment