Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 22750ba07e |
@@ -78,4 +78,30 @@ export const handler: Handlers<null, AuthenticatedState> = {
|
|||||||
headers: { "content-type": "application/json" },
|
headers: { "content-type": "application/json" },
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// #52 DELETE /ajustements/{numEtud}/{idUE}
|
||||||
|
async DELETE(
|
||||||
|
_request: Request,
|
||||||
|
context: FreshContext<AuthenticatedState>,
|
||||||
|
): Promise<Response> {
|
||||||
|
if (context.state.session.eduPersonPrimaryAffiliation !== "employee") {
|
||||||
|
return FORBIDDEN;
|
||||||
|
}
|
||||||
|
|
||||||
|
const numEtud = Number(context.params.numEtud);
|
||||||
|
const idUE = Number(context.params.idUE);
|
||||||
|
|
||||||
|
if (isNaN(numEtud) || isNaN(idUE)) {
|
||||||
|
return new Response("Paramètres invalides", { status: 400 });
|
||||||
|
}
|
||||||
|
|
||||||
|
const [deleted] = await db
|
||||||
|
.delete(ajustements)
|
||||||
|
.where(eq(ajustements.numEtud, numEtud), eq(ajustements.idUE, idUE))
|
||||||
|
.returning();
|
||||||
|
|
||||||
|
if (!deleted) return NOT_FOUND;
|
||||||
|
|
||||||
|
return new Response(null, { status: 204 });
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user