diff --git a/readme.md b/readme.md index 0e3659a28a7b3827dd65a9e51979f2844a10a526..8c2749d709e8e59a60f0d105741b7d3aebb19608 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -# Mini projet Spring boot "TP-QUIZ" +# Spring boot "TP-QUIZ" ## Configuration du projet @@ -6,31 +6,16 @@ Le projet utilise les ressources suivantes situées dans le répertoire `src/mai - `docker-compose.yml` : Ce fichier permet de lancer deux conteneurs Docker, l'un pour MariaDB et l'autre pour phpMyAdmin. -- `quiz.sql` : Ce fichier contient le script SQL pour créer la BDD. - - `application.properties` : Ce fichier contient la configuration de Spring Boot . - spring.datasource.* => Configuration pour la connexion a la BDD - - server.servlet.context-path => permet de préfixe les routes par "/api" - -## Lancer le projet - -### Exécution de Docker Compose - -1. Exécutez la commande suivante pour démarrer les conteneurs MariaDB et phpMyAdmin : - - ```bash - docker-compose up - ``` - -2. Une fois les conteneurs démarrés, accédez à phpMyAdmin en ouvrant votre navigateur web et en accédant à l'URL : `http://localhost:8081`. Utilisez les informations de connexion suivantes : - - - Nom d'utilisateur : root - - - Mot de passe : root + - hepia.oauth2.* => Configuration Oauth + -3. Dans phpMyAdmin, importez le fichier `quiz.sql` pour créer votre schéma de base de données. +Avant de lancer ce projet il est important d'avoir déjà lancé les deux autres starter. +- Starter Oauth: https://gitedu.hesge.ch/repos.quentin.fasler/projet-semestre/starter-oauth +- Starter Quiz : https://gitedu.hesge.ch/repos.quentin.fasler/projet-semestre/starter-oauth ### Exécution de spring boot diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index b1a243c09b7d6facf51c694e793fd8d15a5c9a1f..3caf13d02a428ca91ed560ce16442fdd51a0c8ca 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,4 +1,4 @@ -spring.datasource.url=jdbc:mariadb://localhost:3307/quiz +spring.datasource.url=jdbc:mariadb://localhost:3308/quiz spring.datasource.username=root spring.datasource.password=root spring.datasource.driver-class-name=org.mariadb.jdbc.Driver diff --git a/src/main/resources/docker-compose.yml b/src/main/resources/docker-compose.yml index b389fae9a3ae620b21da1cac14059a3820c2fccd..d6adc8618e3b092de0cc8eee22372306904a1bfd 100644 --- a/src/main/resources/docker-compose.yml +++ b/src/main/resources/docker-compose.yml @@ -7,7 +7,7 @@ services: environment: MYSQL_ROOT_PASSWORD: root ports: - - 3307:3306 + - 3308:3306 phpmyadmin: image: phpmyadmin diff --git a/src/main/resources/quiz.sql b/src/main/resources/quiz.sql deleted file mode 100644 index cb3ec0f80596179c66073076376b5991d658dab7..0000000000000000000000000000000000000000 --- a/src/main/resources/quiz.sql +++ /dev/null @@ -1,88 +0,0 @@ -CREATE TABLE IF NOT EXISTS categories ( - id INTEGER PRIMARY KEY AUTO_INCREMENT, - name TEXT NOT NULL UNIQUE -); - -INSERT INTO categories (name) VALUES - ('Géographie'), - ('Histoire'), - ('Science'), - ('Cinéma'), - ('Musique'), - ('Sport'), - ('Informatique'), - ('Cuisine'), - ('Littérature'), - ('Art'); - -CREATE TABLE IF NOT EXISTS questions ( - id INTEGER PRIMARY KEY AUTO_INCREMENT, - question_text TEXT NOT NULL, - category_id INTEGER NOT NULL, - FOREIGN KEY (category_id) REFERENCES categories (id) -); - -CREATE TABLE IF NOT EXISTS answers ( - id INTEGER PRIMARY KEY AUTO_INCREMENT, - answer_text TEXT NOT NULL, - correct BOOLEAN DEFAULT FALSE, - question_id INTEGER NOT NULL, - FOREIGN KEY (question_id) REFERENCES questions (id) -); - -CREATE TABLE IF NOT EXISTS users ( - id INTEGER PRIMARY KEY AUTO_INCREMENT, - firstname TEXT NOT NULL, - lastname TEXT NOT NULL, - email TEXT NOT NULL UNIQUE -); - - -INSERT INTO questions (question_text, category_id) -VALUES - ('Question 1', 1), - ('Question 2', 2), - ('Question 3', 3), - ('Question 4', 1), - ('Question 5', 2), - ('Question 6', 3), - ('Question 7', 1), - ('Question 8', 2), - ('Question 9', 3), - ('Question 10', 1); - --- Insérer 30 réponses dans la table "answers" avec une réponse correcte par question -INSERT INTO answers (answer_text, correct, question_id) -VALUES - ('Réponse 1 Question 1', TRUE, 1), - ('Réponse 2 Question 1', FALSE, 1), - ('Réponse 3 Question 1', FALSE, 1), - ('Réponse 1 Question 2', FALSE, 2), - ('Réponse 2 Question 2', TRUE, 2), - ('Réponse 3 Question 2', FALSE, 2), - ('Réponse 1 Question 3', FALSE, 3), - ('Réponse 2 Question 3', FALSE, 3), - ('Réponse 3 Question 3', TRUE, 3), - ('Réponse 1 Question 4', TRUE, 4), - ('Réponse 2 Question 4', FALSE, 4), - ('Réponse 3 Question 4', FALSE, 4), - ('Réponse 1 Question 5', FALSE, 5), - ('Réponse 2 Question 5', TRUE, 5), - ('Réponse 3 Question 5', FALSE, 5), - ('Réponse 1 Question 6', FALSE, 6), - ('Réponse 2 Question 6', FALSE, 6), - ('Réponse 3 Question 6', TRUE, 6), - ('Réponse 1 Question 7', TRUE, 7), - ('Réponse 2 Question 7', FALSE, 7), - ('Réponse 3 Question 7', FALSE, 7), - ('Réponse 1 Question 8', FALSE, 8), - ('Réponse 2 Question 8', TRUE, 8), - ('Réponse 3 Question 8', FALSE, 8), - ('Réponse 1 Question 9', FALSE, 9), - ('Réponse 2 Question 9', FALSE, 9), - ('Réponse 3 Question 9', TRUE, 9), - ('Réponse 1 Question 10', TRUE, 10), - ('Réponse 2 Question 10', FALSE, 10), - ('Réponse 3 Question 10', FALSE, 10); - -