Merge branch 'master' of ssh://85.143.175.152:222/bro-students/multy-stub
This commit is contained in:
commit
1bf68cea08
@ -3,21 +3,22 @@ const { MasterModel } = require("./model/master");
|
||||
const mongoose = require("mongoose");
|
||||
const { OrderModel } = require("./model/order");
|
||||
|
||||
router.get("/masters", async (req, res, next) => {
|
||||
router.post("/masters/list", async (req, res, next) => {
|
||||
try {
|
||||
const { startDate, endDate } = req.body;
|
||||
|
||||
if (!startDate || !endDate) {
|
||||
throw new Error("Missing startDate or endDate");
|
||||
}
|
||||
|
||||
const start = new Date(startDate);
|
||||
const end = new Date(endDate);
|
||||
const masters = await MasterModel.find({});
|
||||
|
||||
// Создаем объекты для начала и конца текущего дня
|
||||
const today = new Date();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
const tomorrow = new Date(today);
|
||||
tomorrow.setDate(tomorrow.getDate() + 1);
|
||||
|
||||
const orders = await OrderModel.find({
|
||||
startWashTime: {
|
||||
$gte: today,
|
||||
$lt: tomorrow,
|
||||
},
|
||||
$or: [
|
||||
{ startWashTime: { $lt: end }, endWashTime: { $gt: start } }
|
||||
]
|
||||
});
|
||||
|
||||
const mastersWithOrders = masters.map((master) => {
|
||||
|
Loading…
Reference in New Issue
Block a user