Skip to content

Commit

Permalink
Resolvidos erros pontuais
Browse files Browse the repository at this point in the history
  • Loading branch information
hugorochaffs committed Dec 4, 2020
1 parent 927294e commit 6556228
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions js/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,10 @@ async function insertCaso(caso){
const conn = await connect();
var data = new Date();
var dataA = data.getFullYear()+"-"+data.getMonth()+"-"+data.getDate()
const sql = 'SELECT COUNT(*) AS countCasos FROM casos WHERE cid = "'+caso.cid+'" AND data ="'+dataA+'" AND usuario ="'+caso.usuario+'" AND ra ="'+caso.ra+'"';
const [rows] = await conn.query(sql);
if(rows[0].countCasos<=0){
const sql = 'INSERT INTO casos(cid,data,usuario,ra,dataOcorrencia) VALUES (?,?,?,?,?);';
const values = [caso.cid,dataA,caso.usuario,caso.ra,caso.dataOcorrencia];
if(conn.query(sql, values)){return await 1;}else{return await 0;}
}
else{return await 3;}

}

async function selectUser(user){
Expand Down

0 comments on commit 6556228

Please sign in to comment.