-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
452 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import getDBConnection from "./getDBConnection.js"; | ||
|
||
export const compraItens = async (idPersonagem, idItem) => { | ||
// const query = "'CALL comprarItem($1, $2)', [idPersonagem, idItem]"; | ||
return await getDBConnection('CALL comprarItem($1, $2)', [idPersonagem, idItem]); | ||
}; | ||
|
||
export const ItemComprados = async () => { | ||
// console.log('teste'); | ||
// const query = `SELECT * FROM inventario`; | ||
// return await getDBConnection(query); | ||
const query = ` | ||
SELECT i.nome, c.quantidade, c.valorTotal, c.dataCompra | ||
FROM compra c | ||
JOIN item i ON c.idItem = i.idItem | ||
WHERE c.id_personagem = $1 | ||
ORDER BY c.dataCompra DESC; | ||
`; | ||
return await getDBConnection(query, [1]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { ItemComprados, compraItens } from "../Services/compraServiceDB.js"; | ||
|
||
class CompraController { | ||
async ComprarItem(req, res) { | ||
try { | ||
// Acessando o parâmetro da rota | ||
const { idPersonagem, idItem } = req.params; | ||
console.log("DEU bom o params", idPersonagem, idItem); | ||
const response = (await compraItens(idPersonagem, idItem)) ?? null; | ||
return res.status(200).json(response); | ||
} catch (error) { | ||
console.error(error.message); | ||
return res.status(500).json({ error: "Compra não efetuada" }); | ||
} | ||
} | ||
|
||
async ItemComprados(req, res) { | ||
try { | ||
// Acessando o parâmetro da rota | ||
const response = (await ItemComprados()) ?? null; | ||
return res.status(200).json(response); | ||
} catch (error) { | ||
console.error(error.message); | ||
return res.status(500).json({ error: "Compra não efetuada" }); | ||
} | ||
} | ||
} | ||
|
||
export default new CompraController(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Body, Footer, Header, ModalContainer } from "./styles"; | ||
|
||
// interface IInimigoModal { | ||
// inventario: IInventario; | ||
// inventarioItens: ItemRPG[]; | ||
// } | ||
|
||
export default function InimigoModal() { | ||
return ( | ||
<ModalContainer> | ||
<Header> | ||
<h1>Inimigo</h1> | ||
</Header> | ||
<Body></Body> | ||
|
||
<Footer></Footer> | ||
</ModalContainer> | ||
); | ||
} |
Oops, something went wrong.