generated from azures04/Base-REST-API
Add badges, checkins, and transport endpoints
Introduce gamification and check-in support plus expanded transport/admin APIs. Added DDL for checkins, badges and user_badges. New repositories: badgeRepository, userBadgeRepository, checkinRepository. New routes: admin badge management, admin transport (lines/platforms/stations), public transport endpoints, user checkins and stations endpoints, and user badges on /me. Services updated: adminService (badge CRUD & user assignment), userService (checkins, badge queries), authService (hasAdminRights). Minor package.json name update. These changes implement database, repo, service and route wiring for badges, user_badins and checkin features and additional transport admin routes.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
const express = require("express")
|
||||
const transportService = require("../../../../services/transportService")
|
||||
const router = express.Router({ mergeParams: true })
|
||||
|
||||
router.get("/:lineId", async (req, res) => {
|
||||
const { lineId } = req.params
|
||||
const line = await transportService.getLineById({ lineId })
|
||||
return res.status(200).json(line)
|
||||
})
|
||||
|
||||
router.get("/:lineId/stations", async (req, res) => {
|
||||
const { lineId } = req.params
|
||||
const stations = await transportService.getLineStations({ lineId, directionId: 0 })
|
||||
return res.status(200).json(stations)
|
||||
})
|
||||
|
||||
router.get("/all", async (req, res) => {
|
||||
const lines = await transportService.getAllLines()
|
||||
return res.status(200).json(lines)
|
||||
})
|
||||
|
||||
router.get("/all/:transportType", async (req, res) => {
|
||||
const { transportType } = req.params
|
||||
const lines = await transportService.getLinesByTransportType(transportType)
|
||||
return res.status(200).json(lines)
|
||||
})
|
||||
|
||||
module.exports = router
|
||||
@@ -0,0 +1,29 @@
|
||||
const express = require("express")
|
||||
const transportService = require("../../../../services/transportService")
|
||||
const router = express.Router({ mergeParams: true })
|
||||
|
||||
router.get("/:platformId", async (req, res) => {
|
||||
const { platformId } = req.params
|
||||
const line = await transportService.getPlatformById({ platformId })
|
||||
return res.status(200).json(line)
|
||||
})
|
||||
|
||||
router.get("/:platformId/lines", async (req, res) => {
|
||||
const { platformId } = req.params
|
||||
const stations = await transportService.getPlatformLines({ platformId, directionId: 0 })
|
||||
return res.status(200).json(stations)
|
||||
})
|
||||
|
||||
router.get("/bystation/:stationId", async (req, res) => {
|
||||
const { stationId } = req.params
|
||||
const platforms = await transportService.getPlatformsByStation({ stationId })
|
||||
return res.status(200).json(platforms)
|
||||
})
|
||||
|
||||
router.get("/nearest/:lineId/:latitude/:longitude/:radiusM", async (req, res) => {
|
||||
const { lineId, latitude, longitude, radiusM } = req.params
|
||||
const lines = await transportService.findNearestPlatformForLine({ lineId, latitude, longitude, radiusM })
|
||||
return res.status(200).json(lines)
|
||||
})
|
||||
|
||||
module.exports = router
|
||||
@@ -0,0 +1,34 @@
|
||||
const express = require("express")
|
||||
const transportService = require("../../../../services/transportService")
|
||||
const router = express.Router({ mergeParams: true })
|
||||
|
||||
router.get("/:stationId", async (req, res) => {
|
||||
const { stationId } = req.params
|
||||
const station = await transportService.getStationByIdx({ stationId })
|
||||
return res.status(200).json(station)
|
||||
})
|
||||
|
||||
router.get("/:stationId/lines", async (req, res) => {
|
||||
const { stationId } = req.params
|
||||
const lines = await transportService.getStationLines(stationId)
|
||||
return res.status(200).json(lines)
|
||||
})
|
||||
|
||||
router.get("/all", async (req, res) => {
|
||||
const stations = await transportService.getAllStations()
|
||||
return res.status(200).json(stations)
|
||||
})
|
||||
|
||||
router.get("/:radiusKm/:latitude/:longitude", async (req, res) => {
|
||||
const { radiusKm, latitude, longitude } = req.params
|
||||
const station = await transportService.getStationsByDistance({ latitude, longitude, radiusKm })
|
||||
return res.status(200).json(station)
|
||||
})
|
||||
|
||||
router.get("/accessible/:radiusKm/:latitude/:longitude", async (req, res) => {
|
||||
const { radiusKm, latitude, longitude } = req.params
|
||||
const station = await transportService.getAccessibleStations({ latitude, longitude, radiusKm })
|
||||
return res.status(200).json(station)
|
||||
})
|
||||
|
||||
module.exports = router
|
||||
Reference in New Issue
Block a user