Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 22750ba07e | |||
| 49876339bf | |||
| eeb087ea76 | |||
| 7ad70c4525 |
@@ -4,32 +4,16 @@
|
|||||||
|
|
||||||
import * as $_apps_layout from "./routes/(apps)/_layout.tsx";
|
import * as $_apps_layout from "./routes/(apps)/_layout.tsx";
|
||||||
import * as $_apps_middleware from "./routes/(apps)/_middleware.ts";
|
import * as $_apps_middleware from "./routes/(apps)/_middleware.ts";
|
||||||
import * as $_apps_admin_api_example from "./routes/(apps)/admin/api/example.ts";
|
|
||||||
import * as $_apps_admin_api_modules from "./routes/(apps)/admin/api/modules.ts";
|
|
||||||
import * as $_apps_admin_api_modules_idModule_ from "./routes/(apps)/admin/api/modules/[idModule].ts";
|
|
||||||
import * as $_apps_admin_api_permissions from "./routes/(apps)/admin/api/permissions.ts";
|
|
||||||
import * as $_apps_admin_api_roles from "./routes/(apps)/admin/api/roles.ts";
|
|
||||||
import * as $_apps_admin_api_roles_idRole_ from "./routes/(apps)/admin/api/roles/[idRole].ts";
|
|
||||||
import * as $_apps_admin_api_users from "./routes/(apps)/admin/api/users.ts";
|
|
||||||
import * as $_apps_admin_api_users_id_ from "./routes/(apps)/admin/api/users/[id].ts";
|
|
||||||
import * as $_apps_admin_index from "./routes/(apps)/admin/index.tsx";
|
|
||||||
import * as $_apps_admin_partials_index from "./routes/(apps)/admin/partials/index.tsx";
|
|
||||||
import * as $_apps_mobility_api_insert_mobility from "./routes/(apps)/mobility/api/insert_mobility.ts";
|
import * as $_apps_mobility_api_insert_mobility from "./routes/(apps)/mobility/api/insert_mobility.ts";
|
||||||
import * as $_apps_mobility_index from "./routes/(apps)/mobility/index.tsx";
|
import * as $_apps_mobility_index from "./routes/(apps)/mobility/index.tsx";
|
||||||
import * as $_apps_mobility_partials_admin_edit_mobility from "./routes/(apps)/mobility/partials/(admin)/edit_mobility.tsx";
|
import * as $_apps_mobility_partials_admin_edit_mobility from "./routes/(apps)/mobility/partials/(admin)/edit_mobility.tsx";
|
||||||
import * as $_apps_mobility_partials_index from "./routes/(apps)/mobility/partials/index.tsx";
|
import * as $_apps_mobility_partials_index from "./routes/(apps)/mobility/partials/index.tsx";
|
||||||
import * as $_apps_mobility_partials_overview from "./routes/(apps)/mobility/partials/overview.tsx";
|
import * as $_apps_mobility_partials_overview from "./routes/(apps)/mobility/partials/overview.tsx";
|
||||||
import * as $_apps_notes_api_notes from "./routes/(apps)/notes/api/notes.ts";
|
|
||||||
import * as $_apps_notes_api_ues from "./routes/(apps)/notes/api/ues.ts";
|
|
||||||
import * as $_apps_notes_index from "./routes/(apps)/notes/index.tsx";
|
import * as $_apps_notes_index from "./routes/(apps)/notes/index.tsx";
|
||||||
import * as $_apps_notes_partials_admin_courses from "./routes/(apps)/notes/partials/(admin)/courses.tsx";
|
import * as $_apps_notes_partials_admin_courses from "./routes/(apps)/notes/partials/(admin)/courses.tsx";
|
||||||
import * as $_apps_notes_partials_index from "./routes/(apps)/notes/partials/index.tsx";
|
import * as $_apps_notes_partials_index from "./routes/(apps)/notes/partials/index.tsx";
|
||||||
import * as $_apps_notes_partials_notes from "./routes/(apps)/notes/partials/notes.tsx";
|
import * as $_apps_notes_partials_notes from "./routes/(apps)/notes/partials/notes.tsx";
|
||||||
import * as $_apps_students_api_promotions from "./routes/(apps)/students/api/promotions.ts";
|
|
||||||
import * as $_apps_students_api_promotions_idPromo_ from "./routes/(apps)/students/api/promotions/[idPromo].ts";
|
|
||||||
import * as $_apps_students_api_students from "./routes/(apps)/students/api/students.ts";
|
import * as $_apps_students_api_students from "./routes/(apps)/students/api/students.ts";
|
||||||
import * as $_apps_students_api_students_numEtud_ from "./routes/(apps)/students/api/students/[numEtud].ts";
|
|
||||||
import * as $_apps_students_api_students_import_csv from "./routes/(apps)/students/api/students/import-csv.ts";
|
|
||||||
import * as $_apps_students_index from "./routes/(apps)/students/index.tsx";
|
import * as $_apps_students_index from "./routes/(apps)/students/index.tsx";
|
||||||
import * as $_apps_students_partials_admin_consult from "./routes/(apps)/students/partials/(admin)/consult.tsx";
|
import * as $_apps_students_partials_admin_consult from "./routes/(apps)/students/partials/(admin)/consult.tsx";
|
||||||
import * as $_apps_students_partials_admin_upload from "./routes/(apps)/students/partials/(admin)/upload.tsx";
|
import * as $_apps_students_partials_admin_upload from "./routes/(apps)/students/partials/(admin)/upload.tsx";
|
||||||
@@ -57,18 +41,6 @@ const manifest = {
|
|||||||
routes: {
|
routes: {
|
||||||
"./routes/(apps)/_layout.tsx": $_apps_layout,
|
"./routes/(apps)/_layout.tsx": $_apps_layout,
|
||||||
"./routes/(apps)/_middleware.ts": $_apps_middleware,
|
"./routes/(apps)/_middleware.ts": $_apps_middleware,
|
||||||
"./routes/(apps)/admin/api/example.ts": $_apps_admin_api_example,
|
|
||||||
"./routes/(apps)/admin/api/modules.ts": $_apps_admin_api_modules,
|
|
||||||
"./routes/(apps)/admin/api/modules/[idModule].ts":
|
|
||||||
$_apps_admin_api_modules_idModule_,
|
|
||||||
"./routes/(apps)/admin/api/permissions.ts": $_apps_admin_api_permissions,
|
|
||||||
"./routes/(apps)/admin/api/roles.ts": $_apps_admin_api_roles,
|
|
||||||
"./routes/(apps)/admin/api/roles/[idRole].ts":
|
|
||||||
$_apps_admin_api_roles_idRole_,
|
|
||||||
"./routes/(apps)/admin/api/users.ts": $_apps_admin_api_users,
|
|
||||||
"./routes/(apps)/admin/api/users/[id].ts": $_apps_admin_api_users_id_,
|
|
||||||
"./routes/(apps)/admin/index.tsx": $_apps_admin_index,
|
|
||||||
"./routes/(apps)/admin/partials/index.tsx": $_apps_admin_partials_index,
|
|
||||||
"./routes/(apps)/mobility/api/insert_mobility.ts":
|
"./routes/(apps)/mobility/api/insert_mobility.ts":
|
||||||
$_apps_mobility_api_insert_mobility,
|
$_apps_mobility_api_insert_mobility,
|
||||||
"./routes/(apps)/mobility/index.tsx": $_apps_mobility_index,
|
"./routes/(apps)/mobility/index.tsx": $_apps_mobility_index,
|
||||||
@@ -78,22 +50,12 @@ const manifest = {
|
|||||||
$_apps_mobility_partials_index,
|
$_apps_mobility_partials_index,
|
||||||
"./routes/(apps)/mobility/partials/overview.tsx":
|
"./routes/(apps)/mobility/partials/overview.tsx":
|
||||||
$_apps_mobility_partials_overview,
|
$_apps_mobility_partials_overview,
|
||||||
"./routes/(apps)/notes/api/notes.ts": $_apps_notes_api_notes,
|
|
||||||
"./routes/(apps)/notes/api/ues.ts": $_apps_notes_api_ues,
|
|
||||||
"./routes/(apps)/notes/index.tsx": $_apps_notes_index,
|
"./routes/(apps)/notes/index.tsx": $_apps_notes_index,
|
||||||
"./routes/(apps)/notes/partials/(admin)/courses.tsx":
|
"./routes/(apps)/notes/partials/(admin)/courses.tsx":
|
||||||
$_apps_notes_partials_admin_courses,
|
$_apps_notes_partials_admin_courses,
|
||||||
"./routes/(apps)/notes/partials/index.tsx": $_apps_notes_partials_index,
|
"./routes/(apps)/notes/partials/index.tsx": $_apps_notes_partials_index,
|
||||||
"./routes/(apps)/notes/partials/notes.tsx": $_apps_notes_partials_notes,
|
"./routes/(apps)/notes/partials/notes.tsx": $_apps_notes_partials_notes,
|
||||||
"./routes/(apps)/students/api/promotions.ts":
|
|
||||||
$_apps_students_api_promotions,
|
|
||||||
"./routes/(apps)/students/api/promotions/[idPromo].ts":
|
|
||||||
$_apps_students_api_promotions_idPromo_,
|
|
||||||
"./routes/(apps)/students/api/students.ts": $_apps_students_api_students,
|
"./routes/(apps)/students/api/students.ts": $_apps_students_api_students,
|
||||||
"./routes/(apps)/students/api/students/[numEtud].ts":
|
|
||||||
$_apps_students_api_students_numEtud_,
|
|
||||||
"./routes/(apps)/students/api/students/import-csv.ts":
|
|
||||||
$_apps_students_api_students_import_csv,
|
|
||||||
"./routes/(apps)/students/index.tsx": $_apps_students_index,
|
"./routes/(apps)/students/index.tsx": $_apps_students_index,
|
||||||
"./routes/(apps)/students/partials/(admin)/consult.tsx":
|
"./routes/(apps)/students/partials/(admin)/consult.tsx":
|
||||||
$_apps_students_partials_admin_consult,
|
$_apps_students_partials_admin_consult,
|
||||||
|
|||||||
@@ -40,4 +40,68 @@ export const handler: Handlers<null, AuthenticatedState> = {
|
|||||||
headers: { "content-type": "application/json" },
|
headers: { "content-type": "application/json" },
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// #51 PUT /ajustements/{numEtud}/{idUE}
|
||||||
|
async PUT(
|
||||||
|
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 body: { valeur: number } = await request.json();
|
||||||
|
|
||||||
|
if (body.valeur === undefined) {
|
||||||
|
return new Response(JSON.stringify({ error: "Champ requis: valeur" }), {
|
||||||
|
status: 400,
|
||||||
|
headers: { "content-type": "application/json" },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const [updated] = await db
|
||||||
|
.update(ajustements)
|
||||||
|
.set({ valeur: body.valeur })
|
||||||
|
.where(eq(ajustements.numEtud, numEtud), eq(ajustements.idUE, idUE))
|
||||||
|
.returning();
|
||||||
|
|
||||||
|
if (!updated) return NOT_FOUND;
|
||||||
|
|
||||||
|
return new Response(JSON.stringify(updated), {
|
||||||
|
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 });
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
import { Handlers } from "$fresh/server.ts";
|
||||||
|
import { db } from "../../../../../../databases/db.ts";
|
||||||
|
import { notes } from "../../../../../../databases/schema.ts";
|
||||||
|
import { and, eq } from "npm:drizzle-orm";
|
||||||
|
|
||||||
|
export const handler: Handlers = {
|
||||||
|
// #45 GET /notes/:numEtud/:idModule
|
||||||
|
async GET(_request, context) {
|
||||||
|
try {
|
||||||
|
const numEtud = parseInt(context.params.numEtud);
|
||||||
|
const { idModule } = context.params;
|
||||||
|
|
||||||
|
if (isNaN(numEtud)) {
|
||||||
|
return new Response(JSON.stringify({ error: "Paramètre numEtud invalide" }), {
|
||||||
|
status: 400,
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = await db.select().from(notes).where(
|
||||||
|
and(
|
||||||
|
eq(notes.numEtud, numEtud),
|
||||||
|
eq(notes.idModule, idModule),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (result.length === 0) {
|
||||||
|
return new Response(JSON.stringify({ error: "Ressource introuvable" }), {
|
||||||
|
status: 404,
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Response(JSON.stringify(result[0]), {
|
||||||
|
status: 200,
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching note:", error);
|
||||||
|
return new Response("Failed to fetch data", { status: 500 });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -4,6 +4,36 @@ import { ueModules } from "../../../../databases/schema.ts";
|
|||||||
import { and, eq } from "npm:drizzle-orm";
|
import { and, eq } from "npm:drizzle-orm";
|
||||||
|
|
||||||
export const handler: Handlers = {
|
export const handler: Handlers = {
|
||||||
|
// #37 GET /ue-modules
|
||||||
|
async GET(request) {
|
||||||
|
try {
|
||||||
|
const url = new URL(request.url);
|
||||||
|
const idPromo = url.searchParams.get("idPromo");
|
||||||
|
const idUEParam = url.searchParams.get("idUE");
|
||||||
|
|
||||||
|
const idUE = idUEParam ? parseInt(idUEParam) : null;
|
||||||
|
|
||||||
|
if (idUEParam && isNaN(idUE!)) {
|
||||||
|
return new Response("Paramètre idUE invalide", { status: 400 });
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = await db.select().from(ueModules).where(
|
||||||
|
and(
|
||||||
|
idPromo ? eq(ueModules.idPromo, idPromo) : undefined,
|
||||||
|
idUE ? eq(ueModules.idUE, idUE) : undefined,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
return new Response(JSON.stringify(result), {
|
||||||
|
status: 200,
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching UE-modules:", error);
|
||||||
|
return new Response("Failed to fetch data", { status: 500 });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// #38 POST /ue-modules
|
// #38 POST /ue-modules
|
||||||
async POST(request) {
|
async POST(request) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -34,4 +34,70 @@ export const handler: Handlers = {
|
|||||||
return new Response("Failed to fetch data", { status: 500 });
|
return new Response("Failed to fetch data", { status: 500 });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// #35 PUT /ues/:idUE
|
||||||
|
async PUT(request, context) {
|
||||||
|
try {
|
||||||
|
const idUE = parseInt(context.params.idUE);
|
||||||
|
|
||||||
|
if (isNaN(idUE)) {
|
||||||
|
return new Response(JSON.stringify({ error: "Paramètre idUE invalide" }), {
|
||||||
|
status: 400,
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const body = await request.json();
|
||||||
|
const { nom } = body;
|
||||||
|
|
||||||
|
if (!nom) {
|
||||||
|
return new Response("Champ 'nom' manquant", { status: 400 });
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = await db.update(ues).set({ nom }).where(eq(ues.id, idUE)).returning();
|
||||||
|
|
||||||
|
if (result.length === 0) {
|
||||||
|
return new Response(JSON.stringify({ error: "Ressource introuvable" }), {
|
||||||
|
status: 404,
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Response(JSON.stringify(result[0]), {
|
||||||
|
status: 200,
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error updating UE:", error);
|
||||||
|
return new Response("Failed to update UE", { status: 500 });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// #36 DELETE /ues/:idUE
|
||||||
|
async DELETE(_request, context) {
|
||||||
|
try {
|
||||||
|
const idUE = parseInt(context.params.idUE);
|
||||||
|
|
||||||
|
if (isNaN(idUE)) {
|
||||||
|
return new Response(JSON.stringify({ error: "Paramètre idUE invalide" }), {
|
||||||
|
status: 400,
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = await db.delete(ues).where(eq(ues.id, idUE)).returning();
|
||||||
|
|
||||||
|
if (result.length === 0) {
|
||||||
|
return new Response(JSON.stringify({ error: "Ressource introuvable" }), {
|
||||||
|
status: 404,
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Response(null, { status: 204 });
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error deleting UE:", error);
|
||||||
|
return new Response("Failed to delete UE", { status: 500 });
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user