put account
This commit is contained in:
parent
d4eef1e6c1
commit
8700a44ad6
@ -17,7 +17,7 @@ router.post("/", (req, res, next) => {
|
||||
const name = req.body.name;
|
||||
const des = req.body.description;
|
||||
const type = req.body.type;
|
||||
const new_acc = db.prepare(`INSERT INTO accounts (name, qualifiedName, description, type, balance, localBalance) VALUES ('${name}', 'test','${des}', '${type}', 0, 0)`).run()
|
||||
const new_acc = db.prepare(`INSERT INTO accounts (name, qualifiedName, description, type, balance, localBalance) VALUES (?, 'test',?, ?, 0, 0)`).run(name, des, type)
|
||||
res.status(204).send()
|
||||
|
||||
console.log(new_acc);
|
||||
@ -25,23 +25,42 @@ router.post("/", (req, res, next) => {
|
||||
|
||||
router.get("/:account", (req, res) => {
|
||||
const acc = db
|
||||
.prepare("SELECT * FROM accounts WHERE account_id = ?")
|
||||
.get(req.params.account);
|
||||
.prepare("SELECT * FROM accounts WHERE qualifiedName = ?")
|
||||
.get(req.params.account);
|
||||
|
||||
if (acc == undefined) {
|
||||
res.status(404).send({
|
||||
code: 404,
|
||||
message: "Account not Found",
|
||||
message: "Account not found",
|
||||
additionalPropl: {}
|
||||
});
|
||||
} else {
|
||||
acc['entries'] = []
|
||||
console.log(acc)
|
||||
res.send(acc);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
router.put("/:account", (req, res) => {});
|
||||
router.put("/:account", (req, res) => {
|
||||
const name = req.body.name;
|
||||
const description = req.body.description;
|
||||
const type = req.body.type
|
||||
const acc = db.prepare(`INSERT INTO accounts (name, description, type) VALUES ('${name}', '${description}', '${type}')`).run()
|
||||
|
||||
if (acc == undefined) {
|
||||
res.status(404).send({
|
||||
code: 404,
|
||||
message: "Account not found",
|
||||
additionalPropl: {}
|
||||
})
|
||||
} else {
|
||||
res.status(204).send({
|
||||
OK
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
router.delete("/:account", (req, res) => {});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user