feat: make the time of the master to be taken from the body
This commit is contained in:
		
							parent
							
								
									78b72b0edc
								
							
						
					
					
						commit
						775f24cffa
					
				@ -3,20 +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 masters = await MasterModel.find({});
 | 
			
		||||
    const { startDate, endDate } = req.body;
 | 
			
		||||
 | 
			
		||||
    // Создаем объекты для начала и конца текущего дня
 | 
			
		||||
    const today = new Date();
 | 
			
		||||
    today.setHours(0, 0, 0, 0);
 | 
			
		||||
    const tomorrow = new Date(today);
 | 
			
		||||
    tomorrow.setDate(tomorrow.getDate() + 1);
 | 
			
		||||
    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 orders = await OrderModel.find({
 | 
			
		||||
      startWashTime: {
 | 
			
		||||
        $gte: today,
 | 
			
		||||
        $lt: tomorrow,
 | 
			
		||||
        $gte: start,
 | 
			
		||||
        $lt: end,
 | 
			
		||||
      },
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user