Add picks and apps to game details
This commit is contained in:
@@ -44,7 +44,7 @@ const Pick = sequelize.define(
|
|||||||
{
|
{
|
||||||
gameId: { type: DataTypes.INTEGER, primaryKey: true },
|
gameId: { type: DataTypes.INTEGER, primaryKey: true },
|
||||||
gameTitle: { type: DataTypes.TEXT },
|
gameTitle: { type: DataTypes.TEXT },
|
||||||
character: { type: DataTypes.INTEGER, primaryKey: true },
|
characterId: { type: DataTypes.INTEGER, primaryKey: true },
|
||||||
characterName: { type: DataTypes.TEXT }
|
characterName: { type: DataTypes.TEXT }
|
||||||
},
|
},
|
||||||
{ timestamps: false }
|
{ timestamps: false }
|
||||||
@@ -79,7 +79,7 @@ app.post('/api/character', jsonParser, async (req, res) => {
|
|||||||
const count = req.body.count
|
const count = req.body.count
|
||||||
|
|
||||||
res.setHeader('Content-Type', 'application/json')
|
res.setHeader('Content-Type', 'application/json')
|
||||||
res.send(await Character.findAll({offset: page * count, limit: count}))
|
res.send(await Character.findAll({ offset: page * count, limit: count }))
|
||||||
})
|
})
|
||||||
|
|
||||||
app.get('/api/game/:characterId', async (req, res) => {
|
app.get('/api/game/:characterId', async (req, res) => {
|
||||||
@@ -92,16 +92,39 @@ app.post('/api/game', jsonParser, async (req, res) => {
|
|||||||
const count = req.body.count
|
const count = req.body.count
|
||||||
|
|
||||||
res.setHeader('Content-Type', 'application/json')
|
res.setHeader('Content-Type', 'application/json')
|
||||||
res.send(await Game.findAll({offset: page * count, limit: count}))
|
res.send(await Game.findAll({ offset: page * count, limit: count }))
|
||||||
})
|
})
|
||||||
|
|
||||||
app.get('/api/game/:gameId', async (req, res) => {
|
app.get('/api/game/:gameId', async (req, res) => {
|
||||||
|
|
||||||
const game = await Game.findOne({ where: { id: req.params['gameId'] } })
|
const game = await Game.findOne({ where: { id: req.params['gameId'] } })
|
||||||
console.log(game)
|
console.log(game)
|
||||||
res.send(game)
|
res.send(game)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
app.post('/api/game/:gameId/apps', async (req, res) => {
|
||||||
|
const apps = await App.findAll({ where: { gameId: req.params['gameId'] } })
|
||||||
|
console.log(apps)
|
||||||
|
res.send(apps)
|
||||||
|
})
|
||||||
|
|
||||||
|
app.post('/api/character/:characterId/apps', async (req, res) => {
|
||||||
|
const apps = await App.findAll({ where: { characterId: req.params['characterId'] } })
|
||||||
|
console.log(apps)
|
||||||
|
res.send(apps)
|
||||||
|
})
|
||||||
|
|
||||||
|
app.post('/api/game/:gameId/picks', async (req, res) => {
|
||||||
|
const picks = await Pick.findAll({ where: { gameId: req.params['gameId'] } })
|
||||||
|
console.log(picks)
|
||||||
|
res.send(picks)
|
||||||
|
})
|
||||||
|
|
||||||
|
app.post('/api/character/:characterId/picks', async (req, res) => {
|
||||||
|
const picks = await Pick.findAll({ where: { characterId: req.params['characterId'] } })
|
||||||
|
console.log(picks)
|
||||||
|
res.send(picks)
|
||||||
|
})
|
||||||
|
|
||||||
app.listen(port, async () => {
|
app.listen(port, async () => {
|
||||||
await sequelize.authenticate()
|
await sequelize.authenticate()
|
||||||
return console.log(`Express is listening at http://localhost:${port}`)
|
return console.log(`Express is listening at http://localhost:${port}`)
|
||||||
|
|||||||
@@ -1,9 +1,23 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>{{ gameId }}</div>
|
<div>#{{ game.id }} - {{game.title}}</div>
|
||||||
<div>{{ game }}</div>
|
<div>{{game.gamemaster}}</div>
|
||||||
|
<div>
|
||||||
|
Payout
|
||||||
|
<div>{{game.payoutEB}} eb</div>
|
||||||
|
<div>{{game.payoutIP}} IP</div>
|
||||||
|
<div>{{game.payoutLoot}}</div>
|
||||||
|
|
||||||
|
<div>Picks</div>
|
||||||
|
<div v-for="pick in picks">
|
||||||
|
{{pick.characterId}} - {{pick.characterName}}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>Apps</div>
|
||||||
|
<div v-for="app in apps">
|
||||||
|
{{app.characterId}} - {{app.characterName}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div>#{{ game.id }} - {{ game.title }}</div>
|
|
||||||
<div>{{ game.gamemaster }}</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
@@ -15,6 +29,8 @@ const route = useRoute()
|
|||||||
|
|
||||||
const gameId = ref(route.params.gameId)
|
const gameId = ref(route.params.gameId)
|
||||||
const game = ref({})
|
const game = ref({})
|
||||||
|
const picks = ref({})
|
||||||
|
const apps = ref({})
|
||||||
|
|
||||||
loadGameDetails()
|
loadGameDetails()
|
||||||
|
|
||||||
@@ -29,5 +45,18 @@ watch(
|
|||||||
async function loadGameDetails() {
|
async function loadGameDetails() {
|
||||||
const response = await axios.get(`/api/game/${gameId.value}`)
|
const response = await axios.get(`/api/game/${gameId.value}`)
|
||||||
game.value = response.data
|
game.value = response.data
|
||||||
|
loadPicks()
|
||||||
|
loadApps()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function loadPicks() {
|
||||||
|
const response = await axios.post(`/api/game/${gameId.value}/picks`)
|
||||||
|
picks.value = response.data
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadApps() {
|
||||||
|
const response = await axios.post(`/api/game/${gameId.value}/apps`)
|
||||||
|
apps.value = response.data
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user