upd
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user