Skip to content

Commit

Permalink
#2 Nouvelle route d'exportation
Browse files Browse the repository at this point in the history
  • Loading branch information
bfoujols committed Oct 12, 2023
1 parent 96ddaaf commit a09aa21
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Insomnia.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"_type":"export","__export_format":4,"__export_date":"2023-05-20T20:40:31.494Z","__export_source":"insomnia.desktop.app:v2023.2.1","resources":[{"_id":"req_f76fef108bc34f9b8c5e0894182ade73","parentId":"wrk_8b88eed40d18448594eb2ca1c852227e","modified":1684613331771,"created":1684613090752,"url":"{{ _.base_url }}/login","name":"AUTH","description":"","method":"POST","body":{"mimeType":"text/plain","text":"data={\"identifiant\":\"{% prompt 'Login', 'Login', '', '', false, true %}\",\"motdepasse\":\"{% prompt 'Password', 'Password', '', '', false, true %}\"}"},"parameters":[],"headers":[{"id":"pair_bee54c9f90a0457496c9867f51e5827c","name":"User-Agent","value":"{{ _.userAgent }}","description":""},{"name":"Content-Type","value":"text/plain","id":"pair_7e017438bdb341479dd693b79b630048"}],"authentication":{"type":"basic","useISO88591":false,"disabled":false,"username":"","password":""},"metaSortKey":-1677642375217.75,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"wrk_8b88eed40d18448594eb2ca1c852227e","parentId":null,"modified":1684613090743,"created":1684613090743,"name":"[Mock] API Ecole directe","description":"","scope":"collection","_type":"workspace"},{"_id":"req_e0dfbd1e3be94402a3941e817a592005","parentId":"fld_5c938e65e9be45bda8694b8da4b9e272","modified":1684615179620,"created":1684613090749,"url":"{{ _.base_url }}/eleves/{% prompt 'ID Etudiant', 'ID Etudiant', '', '', false, true %}/viescolaire","name":"VIE-SCOLAIRE","description":"","method":"POST","body":{"mimeType":"text/plain","text":"data={}"},"parameters":[],"headers":[{"name":"Content-Type","value":"text/plain","id":"pair_da6e720040bb4431bb15a67b641916fd"},{"id":"pair_95df22947d88461baaca60aa205db67f","name":"X-Token","value":"{{ _.token }}","description":""},{"id":"pair_997347b40daf4ff6819055cf8da2ce66","name":"User-Agent","value":"{{ _.userAgent }}","description":""}],"authentication":{},"metaSortKey":-1677696694751.875,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"fld_5c938e65e9be45bda8694b8da4b9e272","parentId":"wrk_8b88eed40d18448594eb2ca1c852227e","modified":1684613090748,"created":1684613090748,"name":"ETUDIANTS","description":"","environment":{},"environmentPropertyOrder":null,"metaSortKey":-1677629788426.875,"_type":"request_group"},{"_id":"req_cc705a1d7f924e729fc89c3b799a7e04","parentId":"fld_5aa0e4b2e1564040a1e231a446572cfb","modified":1684614987076,"created":1684613090751,"url":"{{ _.base_url }}/classes/{% prompt 'ID CLASSE', 'ID CLASSE', '', '', false, true %}/eleves","name":"LISTE DES ETUDIANTS","description":"","method":"POST","body":{"mimeType":"text/plain","text":"data={}"},"parameters":[],"headers":[{"id":"pair_b37126573c854406b85e983c77284fd9","name":"X-Token","value":"{{ _.token }}","description":""},{"id":"pair_99d38edcf3c849dbb3b8be616bca3eca","name":"User-Agent","value":"{{ _.userAgent }}","description":""},{"name":"Content-Type","value":"text/plain","id":"pair_fd3f6e0637384d6e83c31b3639709a60"}],"authentication":{},"metaSortKey":-1679944295730,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"fld_5aa0e4b2e1564040a1e231a446572cfb","parentId":"wrk_8b88eed40d18448594eb2ca1c852227e","modified":1684613090750,"created":1684613090750,"name":"PROFESSEUR","description":"","environment":{},"environmentPropertyOrder":null,"metaSortKey":-1677629788401.875,"_type":"request_group"},{"_id":"env_c86073e7e91344a0b2d45a71d145ee44","parentId":"wrk_8b88eed40d18448594eb2ca1c852227e","modified":1684614768759,"created":1684613090744,"name":"Base Environment","data":{"base_url":"{{ _.protocol }}://{{ _.domain }}{{ _.path }}","protocol":"http","domain":"localhost:9042","path":"/v3","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36","token":"{% response 'body', 'req_f76fef108bc34f9b8c5e0894182ade73', 'b64::JC50b2tlbg==::46b', 'when-expired', 60 %}"},"dataPropertyOrder":{"&":["base_url","protocol","domain","path","userAgent","token"]},"color":null,"isPrivate":false,"metaSortKey":1677616649078,"_type":"environment"},{"_id":"jar_e9e9b6b35c3b4d90a5145f07deeb76c6","parentId":"wrk_8b88eed40d18448594eb2ca1c852227e","modified":1684613142826,"created":1684613090745,"name":"Default Jar","cookies":[{"key":"PHPSESSID","value":"empc08h39h98f6h6fk8j9tfrd0","domain":"localhost","path":"/","hostOnly":true,"creation":"2023-05-20T20:05:42.825Z","lastAccessed":"2023-05-20T20:05:42.825Z","id":"2986582957181614"}],"_type":"cookie_jar"},{"_id":"spc_0f7734a76e19414a9e6d3515ba3781bc","parentId":"wrk_8b88eed40d18448594eb2ca1c852227e","modified":1684613090755,"created":1684613090746,"fileName":"[Mock] API Ecole directe","contents":"","contentType":"yaml","_type":"api_spec"}]}
{"_type":"export","__export_format":4,"__export_date":"2023-10-12T14:17:51.738Z","__export_source":"insomnia.desktop.app:v8.2.0","resources":[{"_id":"req_06083037e4e14496a02f2faa755b9168","parentId":"wrk_9e80fda306104119b8e2e665d2eddb1e","modified":1697120188374,"created":1697118847636,"url":"http://localhost:9042/dataset/profs","name":"DATASET PROFS","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/8.2.0"}],"authentication":{},"metaSortKey":-1697118847636,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"wrk_9e80fda306104119b8e2e665d2eddb1e","parentId":null,"modified":1681383240922,"created":1681383240922,"name":"Mock API Ecole Directe","description":"","scope":"collection","_type":"workspace"},{"_id":"req_d67ed6f5c06446358e1ed66f62c2a11b","parentId":"wrk_9e80fda306104119b8e2e665d2eddb1e","modified":1697120156017,"created":1697120150273,"url":"http://localhost:9042/dataset/etudiants","name":"DATASET ETUDIANTS","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/8.2.0"}],"authentication":{},"metaSortKey":-1696862822785.5,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_eaedb5c0d0a5405385e2e79947361ee8","parentId":"wrk_9e80fda306104119b8e2e665d2eddb1e","modified":1697120194084,"created":1697120182749,"url":"http://localhost:9042/dataset/classes","name":"DATASET CLASSES","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/8.2.0"}],"authentication":{},"metaSortKey":-1696734810360.25,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_4276619706334739b397a880d8d76e17","parentId":"wrk_9e80fda306104119b8e2e665d2eddb1e","modified":1696606872779,"created":1696606797935,"url":"http://localhost:9042/init","name":"INIT","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/8.2.0"}],"authentication":{},"metaSortKey":-1696606797935,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_51d08a58b665460dbf867d962403c913","parentId":"wrk_9e80fda306104119b8e2e665d2eddb1e","modified":1696610741054,"created":1684303208342,"url":"http://localhost:9042/v3/classes/{% prompt 'id', 'id', '', '', false, true %}/eleves","name":"CLASSE","description":"","method":"POST","body":{},"parameters":[],"headers":[{"id":"pair_983dd164565f44e9b66542fa4f81d500","name":"X-Token","value":"e9cd1a5abe69b9e01fa0015dc0def07ef36d9567e3cdf60d20d3","description":""}],"authentication":{},"metaSortKey":-1684303208342,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_66b0b30b48e2441c8d51c4fca6409b92","parentId":"wrk_9e80fda306104119b8e2e665d2eddb1e","modified":1696610710540,"created":1681383248003,"url":"http://localhost:9042/v3/login","name":"AUTH","description":"","method":"POST","body":{"mimeType":"text/plain","text":"data={\"identifiant\":\"{% prompt 'Login', 'Login', '', '', false, true %}\",\"motdepasse\":\"{% prompt 'Password', 'Password', '', '', false, true %}\"}"},"parameters":[],"headers":[{"name":"Content-Type","value":"text/plain"}],"authentication":{},"metaSortKey":-1681383248003,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"env_08a1b82f717c1ad5425d2279ef144cc067a1c261","parentId":"wrk_9e80fda306104119b8e2e665d2eddb1e","modified":1681383240924,"created":1681383240924,"name":"Base Environment","data":{},"dataPropertyOrder":null,"color":null,"isPrivate":false,"metaSortKey":1681383240924,"_type":"environment"},{"_id":"jar_08a1b82f717c1ad5425d2279ef144cc067a1c261","parentId":"wrk_9e80fda306104119b8e2e665d2eddb1e","modified":1684611502035,"created":1681383240925,"name":"Default Jar","cookies":[{"key":"PHPSESSID","value":"kut4a64nfh8mfogiug456o2lsd","domain":"localhost","path":"/","hostOnly":true,"creation":"2023-05-20T19:38:22.035Z","lastAccessed":"2023-05-20T19:38:22.035Z","id":"031894855197976524"}],"_type":"cookie_jar"},{"_id":"spc_0214a1ff9d82431f96dd9f65e12e7faf","parentId":"wrk_9e80fda306104119b8e2e665d2eddb1e","modified":1681383240922,"created":1681383240922,"fileName":"Mock API Ecole Directe","contents":"","contentType":"yaml","_type":"api_spec"}]}
12 changes: 12 additions & 0 deletions app/Config/routes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@ index:
uri: /
controller: Controller\WelcomeController
httpMethod: [GET]
datasetclasses:
uri: /dataset/classes
controller: Controller\DataSetClassesController
httpMethod: [GET]
datasetetudiants:
uri: /dataset/etudiants
controller: Controller\DataSetEtudiantsController
httpMethod: [GET]
datasetprof:
uri: /dataset/profs
controller: Controller\DataSetProfController
httpMethod: [GET]
init:
uri: /init
controller: Controller\InitController
Expand Down
30 changes: 30 additions & 0 deletions app/Controller/DataSetClassesController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/*
* Ce fichier fait partie du mock-ecole-directe-api.
*
* (c) redbull
*
* Pour les informations complètes sur les droits d'auteur et la licence,
* veuillez consulter le fichier LICENSE qui a été distribué avec ce code source.
*/


namespace Controller;

use Core\DatabaseService;
use PDO;
use Studoo\EduFramework\Core\Controller\ControllerInterface;
use Studoo\EduFramework\Core\Controller\Request;

class DataSetClassesController implements ControllerInterface
{

public function execute(Request $request): string|null
{
$db = DatabaseService::getConnect();
$stmt = $db->prepare("SELECT * FROM classes");
$stmt->execute();

return json_encode($stmt->fetchAll(PDO::FETCH_ASSOC), JSON_THROW_ON_ERROR);
}
}
30 changes: 30 additions & 0 deletions app/Controller/DataSetEtudiantsController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/*
* Ce fichier fait partie du mock-ecole-directe-api.
*
* (c) redbull
*
* Pour les informations complètes sur les droits d'auteur et la licence,
* veuillez consulter le fichier LICENSE qui a été distribué avec ce code source.
*/


namespace Controller;

use Core\DatabaseService;
use PDO;
use Studoo\EduFramework\Core\Controller\ControllerInterface;
use Studoo\EduFramework\Core\Controller\Request;

class DataSetEtudiantsController implements ControllerInterface
{

public function execute(Request $request): string|null
{
$db = DatabaseService::getConnect();
$stmt = $db->prepare("SELECT * FROM users WHERE typeCompte = 'E' ORDER BY classeId");
$stmt->execute();

return json_encode($stmt->fetchAll(PDO::FETCH_ASSOC), JSON_THROW_ON_ERROR);
}
}
30 changes: 30 additions & 0 deletions app/Controller/DataSetProfController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/*
* Ce fichier fait partie du mock-ecole-directe-api.
*
* (c) redbull
*
* Pour les informations complètes sur les droits d'auteur et la licence,
* veuillez consulter le fichier LICENSE qui a été distribué avec ce code source.
*/


namespace Controller;

use Core\DatabaseService;
use PDO;
use Studoo\EduFramework\Core\Controller\ControllerInterface;
use Studoo\EduFramework\Core\Controller\Request;

class DataSetProfController implements ControllerInterface
{

public function execute(Request $request): string|null
{
$db = DatabaseService::getConnect();
$stmt = $db->prepare("SELECT * FROM users WHERE typeCompte = 'P' ORDER BY classeId");
$stmt->execute();

return json_encode($stmt->fetchAll(PDO::FETCH_ASSOC), JSON_THROW_ON_ERROR);
}
}
7 changes: 6 additions & 1 deletion app/Controller/InitController.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public function execute(Request $request): string|null
$db->exec("CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY,
idLogin INTEGER,
idClasse INTERGER,
nom TEXT,
prenom TEXT,
telPortable TEXT,
Expand Down Expand Up @@ -79,6 +80,7 @@ classeId TEXT,
if (array_key_exists('etudiants', $classe)) {
foreach ($classe['etudiants'] as $etudiant)
$db->exec("INSERT INTO users ( idLogin,
idClasse,
nom,
prenom,
telPortable,
Expand All @@ -93,6 +95,7 @@ classeId,
lastConnexion,
anneeScolaireCourante)
VALUES ( '" . $etudiant['idLogin'] . "',
'" . $id . "',
'" . $etudiant['nom'] . "',
'" . $etudiant['prenom'] . "',
'" . $etudiant['telPortable'] . "',
Expand All @@ -119,7 +122,8 @@ classeId,
$prenom = $faker->firstName($genre[$posGenre]);
$sexe = strtoupper(substr($genre[$posGenre], 0, 1));
$login = (new \Core\StandardRaw)->normalizeSRString(substr($prenom, 0, 1)).(new \Core\StandardRaw)->normalizeSRString($nom).$faker->numberBetween(1000, 9999);
$db->exec("INSERT INTO users ( idLogin,
$db->exec("INSERT INTO users ( idLogin,
idClasse,
nom,
prenom,
telPortable,
Expand All @@ -135,6 +139,7 @@ classeId,
anneeScolaireCourante
)
VALUES ( " . $faker->numberBetween(1000, 999999) . ",
" . $id . ",
'$nom',
'$prenom',
'" . $faker->phoneNumber() . "',
Expand Down
Binary file modified var/ecoledirecte.db
Binary file not shown.

0 comments on commit a09aa21

Please sign in to comment.