-
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.
Merge pull request #26 from DucHuy2801/fix-bug
API for Admin
- Loading branch information
Showing
7 changed files
with
308 additions
and
104 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
'use strict' | ||
|
||
const { StatusOrder } = require("../common/status") | ||
const Order = require("../models/order.model") | ||
const Tour = require("../models/tour.model") | ||
|
||
class AdminController { | ||
getCustomerNumber = async (req, res, next) => { | ||
try { | ||
const totalBookedNumber = await Tour.sum("booked_number") | ||
return res.status(200).json({ | ||
message: "Get total booked number successfully!", | ||
total: totalBookedNumber | ||
}) | ||
} catch (error) { | ||
return res.status(500).json({ message: error.message }) | ||
} | ||
} | ||
|
||
getTotalRevenue = async (req, res, next) => { | ||
try { | ||
const totalRevenue = await Order.sum("total_to_pay", { | ||
where: { | ||
status: StatusOrder.COMPLETE | ||
} | ||
}) | ||
return res.status(200).json({ | ||
message: "Get total revenue successfully!", | ||
total_revenue: totalRevenue | ||
}) | ||
} catch (error) { | ||
return res.status(500).json({ message: error.message }) | ||
} | ||
} | ||
} | ||
|
||
module.exports = new AdminController() |
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
Oops, something went wrong.