Skip to content

Commit

Permalink
tour guide controller
Browse files Browse the repository at this point in the history
  • Loading branch information
augustus281 committed May 18, 2024
1 parent 9bbc858 commit ed1145e
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions server/src/controllers/tour_guide.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
'use strict'

const GuideTour = require("../models/guide_tour.model");
const { findTourById } = require("../services/tour.service")

class TourGuideController {
assignTourToTourGuide = async (req, res, next) => {
try {
const { tour_id, tour_guide_id } = req.body
const tour = await findTourById(tour_id);
if (!tour) {
return res.status(404).json({ message: "Not found to assign!" })
}
await GuideTour.create({
tour_id, tour_guide_id
})
return res.status(200).json({
message: "Assign tour for tour guide successfully!"
})
} catch (error) {
return res.status(500).json({ message: error.message })
}
}

responseTask = async (req, res, next) => {
try {
const { tour_id, reason, tour_guide_id } = req.body
const guideTour = await GuideTour.findOne({
where: {
tour_id,
tour_guide_id
}
})

if (!guideTour) {
return res.status(404).json({ message: "Not found tour is assigned!" })
}

// TODO

return res.status(200).json({ message: "Response task successfully!" })
} catch (error) {
return res.status(500).json({
message: error.message
})
}
}
}

module.exports = new TourGuideController()

0 comments on commit ed1145e

Please sign in to comment.