This commit is contained in:
2024-10-02 14:03:15 +05:00
parent 87a7021482
commit cb3d3e5ab4
8 changed files with 523 additions and 50 deletions
+8
View File
@@ -16,10 +16,18 @@ const scheduledSessionSchema = new Schema(
type: Schema.Types.ObjectId,
ref: "User",
},
slot: {
type: Number,
required: true,
},
startAt: {
type: Date,
required: true,
},
duration: {
type: Number,
required: true,
},
endAt: {
type: Date,
required: true,
+6 -3
View File
@@ -75,12 +75,12 @@ router.get("/:buildId", async (req, res) => {
});
router.post("/", async (req, res) => {
const { buildId, startAt, client, duration } = req.body;
const { buildId, slot, startAt, client, duration } = req.body;
if (!buildId || !startAt) {
if (!buildId || !startAt || !slot) {
return res.json({
status: "error",
message: "Parameters `buildId`, `startAt` are required!", // Параметры `buildId`, `startAt` обязательны!
message: "Parameters `buildId`, `startAt`, `slot` are required!", // Параметры `buildId`, `startAt`, `slot` обязательны!
});
}
@@ -105,6 +105,7 @@ router.post("/", async (req, res) => {
if (duration) {
const scheduledSessions = await ScheduledSession.find({
buildId,
slot,
startAt: {
$gte: startOfDay(startAtISO),
$lte: endOfDay(startAtISO),
@@ -141,7 +142,9 @@ router.post("/", async (req, res) => {
const scheduledSession = await ScheduledSession.create({
buildId,
slot,
startAt: startAtISO,
duration,
endAt: endAtISO,
});