Skip to content

Commit

Permalink
Fix: create schedule
Browse files Browse the repository at this point in the history
  • Loading branch information
augustus281 committed May 30, 2024
1 parent dde8cb9 commit 361e4a5
Show file tree
Hide file tree
Showing 21 changed files with 3,178 additions and 863 deletions.
14 changes: 13 additions & 1 deletion server/src/common/status.js → server/src/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,22 @@ const TypeNotification = {
TOUR_001: "new tour by customer like"
}

const Transport = {
PLANE: "Máy bay",
TRAIN: "Tàu hỏa",
BUS: "Xe bus",
MOTORBIKE: "Xe máy",
BICYCLE: "Xe đạp",
COACH: "Xe khách",
TAXI: "Taxi",
CAR: "Ô tô"
}

module.exports = {
StatusTour,
StatusOrder,
RoleUser,
TypeDiscount,
TypeNotification
TypeNotification,
Transport
}
2 changes: 1 addition & 1 deletion server/src/controllers/admin.controller.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const { StatusOrder } = require("../common/status")
const { StatusOrder } = require("../common/index")
const Order = require("../models/order.model")
const Tour = require("../models/tour.model")

Expand Down
29 changes: 29 additions & 0 deletions server/src/controllers/attraction.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const Attraction = require("../models/attraction.model")
const Destination = require("../models/destination.model")
const Hotel = require("../models/hotel.model")

class AttractionController {
getAllAttractionsByDestination = async(req, res, next) => {
Expand Down Expand Up @@ -29,6 +30,34 @@ class AttractionController {
return res.status(500).json({ message: error.message })
}
}

getAllHotelsByDestination = async (req, res, next) => {
try {
const { destination } = req.query
const dest = await Destination.findOne({
where: {
name: destination
}
})

if (!dest) {
return res.status(404).json({ message: "Not found destination." });
}

const hotels = await Hotel.findAll({
where: {
destination_id: dest.destination_id
}
})

return res.status(200).json({
message: "Get all hotels by destination successfully!",
data: hotels
});
} catch (error) {
return res.status(500).json({ message: error.message })
}
}
}

module.exports = new AttractionController()
2 changes: 2 additions & 0 deletions server/src/controllers/destination.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class DestinationController {
name: hotelInfo.name,
price: hotelInfo.price,
rating: hotelInfo.rating,
description: hotelInfo.description,
destination_id: destination.destination_id
}
})
Expand All @@ -64,6 +65,7 @@ class DestinationController {
name: hotelInfo.name,
price: hotelInfo.price,
rating: hotelInfo.rating,
description: hotelInfo.description,
destination_id: destination.destination_id
}
})
Expand Down
2 changes: 1 addition & 1 deletion server/src/controllers/order.controller.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const { StatusOrder } = require("../common/status");
const { StatusOrder } = require("../common/index");
const { NotFoundError, BadRequestError } = require("../core/error.response");
const Order = require("../models/order.model");
const OrderItem = require("../models/order_item.model");
Expand Down
2 changes: 1 addition & 1 deletion server/src/controllers/payment.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const OrderItem = require('../models/order_item.model');
const OrderTour = require('../models/order_tour.model')
const User = require('../models/user.model')
const Order = require('../models/order.model');
const { StatusOrder } = require('../common/status');
const { StatusOrder } = require('../common/index');
const { updateTotalCart } = require('../services/cart.service');
const { findVoucherById } = require('../services/voucher.service');
const { Op } = require('sequelize');
Expand Down
2 changes: 1 addition & 1 deletion server/src/controllers/review.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const { findTourById } = require("../services/tour.service")
const { findUserById } = require("../services/user.service")
const Comment = require("../models/comment.model")
const Order = require("../models/order.model")
const { StatusOrder } = require("../common/status")
const { StatusOrder } = require("../common/index")
const Tour = require("../models/tour.model")

class ReviewController {
Expand Down
5 changes: 3 additions & 2 deletions server/src/controllers/schedule.controller.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const { StatusTour } = require("../common/status")
const { StatusTour } = require("../common/index")
const Attraction = require("../models/attraction.model")
const OtherAttraction = require("../models/other_attraction.model")
const Schedule = require("../models/schedule.model")
Expand Down Expand Up @@ -153,7 +153,7 @@ class ScheduleController {
}

let scheduleDetails = schedule.schedule_detail;
schedule.schedule_detail = [];
schedule.schedule_detail = null;
await schedule.save()

for (const detailUpdate of schedule_detail) {
Expand All @@ -178,6 +178,7 @@ class ScheduleController {

schedule.schedule_detail = scheduleDetails;
await schedule.save();


return res.status(200).json({
message: "Schedule updated successfully!",
Expand Down
2 changes: 1 addition & 1 deletion server/src/controllers/tour.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const Destination = require("../models/destination.model")
const DestinationTour = require("../models/destination_tour.model")
const Op = Sequelize.Op
const Attraction = require("../models/attraction.model")
const { StatusTour } = require("../common/status")
const { StatusTour } = require("../common/index")
const { findTourById, duplicateTour, getTopRatedTour } = require("../services/tour.service")
const AttractionTour = require("../models/attraction_tour.model")
const Review = require("../models/review.model")
Expand Down
2 changes: 1 addition & 1 deletion server/src/controllers/tour_guide.controller.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const { RoleUser } = require("../common/status");
const { RoleUser } = require("../common/index");
const { BadRequestError } = require("../core/error.response");
const GuideTour = require("../models/task.model");
const TourGuide = require("../models/tour_guide.model");
Expand Down
2 changes: 1 addition & 1 deletion server/src/controllers/user.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const WishlistTour = require("../models/wishlist_tour.model")
const OrderTour = require("../models/order_tour.model")
const { findUserById } = require("../services/user.service")
const { findTourById } = require("../services/tour.service")
const { StatusTour } = require("../common/status")
const { StatusTour } = require("../common/index")
const UserTour = require("../models/user_tour.model")
const { where } = require("sequelize")
const { NotFoundError, BadRequestError } = require("../core/error.response")
Expand Down
Loading

0 comments on commit 361e4a5

Please sign in to comment.