Skip to content

Commit

Permalink
make updates in date time
Browse files Browse the repository at this point in the history
  • Loading branch information
sathirauop committed May 15, 2021
1 parent 1fb3988 commit 4942444
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
6 changes: 3 additions & 3 deletions Backends/Local Server/src/controllers/card.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ exports.issueCard = async(req,res,next)=>{
}
})
} else {

return res.status(httpStatus.INTERNAL_SERVER_ERROR).json({Error: err.message})
console.log("test 1");
return res.status(httpStatus.BAD_REQUEST).json({Error: err})
}
})
}else{
if(err.message === "Card is already issued"){
return res.status(httpStatus.CREATED).json({msg : `card ${details.card_id} is allready issued`})
return res.status(httpStatus.ALREADY_REPORTED).json({msg : `card ${details.card_id} is allready issued`})
}else{
return res.status(httpStatus.INTERNAL_SERVER_ERROR).json({Error: err.message})
}
Expand Down
21 changes: 11 additions & 10 deletions Backends/Local Server/src/models/rfidCard.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ exports.cardIssueing = async (card, callback) => {

exports.addtoIssuelog = async(details,callback)=>{
if(details){
const sql_addtoissuelog = `INSERT INTO ISSUE_LOG(CardId, NIC, CustomerName, DepositAmount) VALUES ('${details.card_id}','${details.employee_id}','${details.customer_name}','${details.amount}');`
let ts = Date.now();
let date_ob = new Date(ts);
let date = date_ob.getDate();
let month = date_ob.getMonth() + 1;
let year = date_ob.getFullYear();
const sql_addtoissuelog = `INSERT INTO ISSUE_LOG(CardId, NIC, CustomerName, DepositAmount,Date) VALUES ('${details.card_id}','${details.employee_id}','${details.customer_name}','${details.amount}','${year + "-" + month + "-" + date}');`
await client.sendQuery(sql_addtoissuelog, (err, result) => {
if(err) {

Expand Down Expand Up @@ -179,8 +184,8 @@ exports.cardScanning = async (details,callback)=>{

await client.sendQuery(sql_findBalance, (err, result) => {
if(err) {
console.error(`SQLQueryError: ${err.sqlMessage}`)
callback(err.code)
console.error(`SQLQueryError: ${err.code}`)
callback(err)
} else {
if (result[0]) {
if(!result[0]['IsIssued']){
Expand Down Expand Up @@ -211,17 +216,13 @@ exports.cardScanning2 = async (details,callback)=>{

await client.sendQuery(sql_findPrice, (err, result) => {
if(err) {
console.error(`SQLQueryError: ${err.sqlMessage}`)
callback(err.code)
console.error(`SQLQueryError: ${err.code}`)
callback(err)
} else {
if (result[0]) {


if (result[0]) {
callback(null,result)

}
else {

callback(Error("ZERO_ROWS_AFFECTED POSSIBLY BECAUSE WRONG NODE_ID"))
}
}
Expand Down
2 changes: 1 addition & 1 deletion Backends/Local Server/src/validations/CardValidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module.exports = {
customer_name: Joi.string()
.required(),
time: Joi.string(),
data: Joi.date(),
date: Joi.date(),
tag:Joi.string().required()

}),
Expand Down
1 change: 1 addition & 0 deletions Hardware_coding/Node/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ void loop()
Serial.println(name);
Serial.println(">>");
delay(1500);


}
else if(httpCode == 401){
Expand Down

0 comments on commit 4942444

Please sign in to comment.