forked from tom.biard/ScienceQuest
Compare commits
182 Commits
master
...
Springboot
@ -0,0 +1,84 @@
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: ScienceQuestAPI
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- Springboot
|
||||
event:
|
||||
- push
|
||||
|
||||
steps:
|
||||
- name: deploy-container-postgresql
|
||||
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
|
||||
environment:
|
||||
IMAGENAME: postgres:16-alpine
|
||||
CONTAINERNAME: postgres_server
|
||||
COMMAND: create
|
||||
OVERWRITE: true
|
||||
PRIVATE: true
|
||||
CODEFIRST_CLIENTDRONE_ENV_POSTGRES_PASSWORD:
|
||||
from_secret: postgres_password_secret
|
||||
CODEFIRST_CLIENTDRONE_ENV_POSTGRES_DB: ScienceQuest
|
||||
CODEFIRST_CLIENTDRONE_ENV_POSTGRES_USER: ScienceQuest
|
||||
ADMINS: alixjeudi--lemoine,victorsoulier,gwenaelplanchon
|
||||
|
||||
- name: build-app
|
||||
image: maven:3-eclipse-temurin-21-alpine
|
||||
depends_on: [deploy-container-postgresql]
|
||||
commands:
|
||||
- cd SpringBootProject/
|
||||
- sed -i -e "s/localhost/tombiard-postgres_server/g" src/main/resources/application.properties
|
||||
- echo -e "\nserver.port=443\nserver.forward-headers-strategy=framework" >> src/main/resources/application.properties
|
||||
- mvn clean package
|
||||
environment:
|
||||
SPRING_DATASOURCE_URL: jdbc:postgresql://tombiard-postgres_server:5432/ScienceQuest
|
||||
SPRING_DATASOURCE_USERNAME: ScienceQuest
|
||||
SPRING_DATASOURCE_PASSWORD:
|
||||
from_secret: postgres_password_secret
|
||||
|
||||
# - name: deploy-container-adminer
|
||||
# image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
|
||||
# environment:
|
||||
# IMAGENAME: adminer:latest
|
||||
# CONTAINERNAME: adminer
|
||||
# COMMAND: create
|
||||
# OVERWRITE: true
|
||||
# CODEFIRST_CLIENTDRONE_ENV_ADMINER_DEFAULT_SERVER: postgres_server
|
||||
# ADMINS: alixjeudi--lemoine,victorsoulier,gwenaelplanchon
|
||||
|
||||
- name: build-container-app-image
|
||||
image: plugins/docker
|
||||
depends_on: [build-app]
|
||||
settings:
|
||||
dockerfile: Dockerfile
|
||||
registry: hub.codefirst.iut.uca.fr
|
||||
repo: hub.codefirst.iut.uca.fr/alix.jeudi--lemoine/api
|
||||
username:
|
||||
from_secret: SECRET_REGISTRY_USERNAME
|
||||
password:
|
||||
from_secret: SECRET_REGISTRY_PASSWORD
|
||||
|
||||
- name: deploy-container-app
|
||||
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
|
||||
depends_on: [build-container-app-image,deploy-container-postgresql]
|
||||
environment:
|
||||
IMAGENAME: hub.codefirst.iut.uca.fr/alix.jeudi--lemoine/api:latest
|
||||
CONTAINERNAME: api
|
||||
COMMAND: create
|
||||
OVERWRITE: true
|
||||
CODEFIRST_CLIENTDRONE_ENV_SPRING_DATASOURCE_URL: jdbc:postgresql://tombiard-postgres_server:5432/ScienceQuest
|
||||
CODEFIRST_CLIENTDRONE_ENV_SPRING_DATASOURCE_USERNAME: ScienceQuest
|
||||
CODEFIRST_CLIENTDRONE_ENV_SPRING_DATASOURCE_PASSWORD:
|
||||
from_secret: postgres_password_secret
|
||||
ADMINS: alixjeudi--lemoine,victorsoulier,gwenaelplanchon
|
||||
|
||||
- name: code-analysis-api
|
||||
image: aosapps/drone-sonar-plugin
|
||||
depends_on: [deploy-container-app]
|
||||
settings:
|
||||
sonar_host:
|
||||
from_secret: sonar_host
|
||||
sonar_token:
|
||||
from_secret: sonar_sae_token
|
||||
exclusions: "**.java"
|
@ -0,0 +1,5 @@
|
||||
FROM openjdk:21-slim
|
||||
EXPOSE 443
|
||||
WORKDIR /app
|
||||
COPY "SpringBootProject/target/sae-0.0.1-SNAPSHOT.jar" "/app/sae-0.0.1-SNAPSHOT.jar"
|
||||
CMD ["java", "-jar", "sae-0.0.1-SNAPSHOT.jar"]
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
@ -0,0 +1,33 @@
|
||||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
Binary file not shown.
@ -0,0 +1,2 @@
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip
|
||||
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
|
@ -0,0 +1,24 @@
|
||||
version: '3.9'
|
||||
|
||||
services:
|
||||
|
||||
postgres_server:
|
||||
image: postgres:16-alpine
|
||||
container_name: postgres_server
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "5432:5432"
|
||||
|
||||
environment:
|
||||
POSTGRES_PASSWORD: 94gg98mFnp269JY98P2pZtVnEd8UkWPm
|
||||
POSTGRES_USER: ScienceQuest
|
||||
POSTGRES_DB: ScienceQuest
|
||||
|
||||
adminer:
|
||||
image: adminer
|
||||
depends_on: [postgres_server]
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
ADMINER_DEFAULT_SERVER: postgres_server
|
||||
ports:
|
||||
- "8081:8080"
|
@ -0,0 +1,308 @@
|
||||
#!/bin/sh
|
||||
# ----------------------------------------------------------------------------
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Apache Maven Wrapper startup batch script, version 3.2.0
|
||||
#
|
||||
# Required ENV vars:
|
||||
# ------------------
|
||||
# JAVA_HOME - location of a JDK home dir
|
||||
#
|
||||
# Optional ENV vars
|
||||
# -----------------
|
||||
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
# e.g. to debug Maven itself, use
|
||||
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
if [ -z "$MAVEN_SKIP_RC" ] ; then
|
||||
|
||||
if [ -f /usr/local/etc/mavenrc ] ; then
|
||||
. /usr/local/etc/mavenrc
|
||||
fi
|
||||
|
||||
if [ -f /etc/mavenrc ] ; then
|
||||
. /etc/mavenrc
|
||||
fi
|
||||
|
||||
if [ -f "$HOME/.mavenrc" ] ; then
|
||||
. "$HOME/.mavenrc"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# OS specific support. $var _must_ be set to either true or false.
|
||||
cygwin=false;
|
||||
darwin=false;
|
||||
mingw=false
|
||||
case "$(uname)" in
|
||||
CYGWIN*) cygwin=true ;;
|
||||
MINGW*) mingw=true;;
|
||||
Darwin*) darwin=true
|
||||
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
|
||||
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
if [ -x "/usr/libexec/java_home" ]; then
|
||||
JAVA_HOME="$(/usr/libexec/java_home)"; export JAVA_HOME
|
||||
else
|
||||
JAVA_HOME="/Library/Java/Home"; export JAVA_HOME
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
if [ -r /etc/gentoo-release ] ; then
|
||||
JAVA_HOME=$(java-config --jre-home)
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched
|
||||
if $cygwin ; then
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=$(cygpath --unix "$JAVA_HOME")
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=$(cygpath --path --unix "$CLASSPATH")
|
||||
fi
|
||||
|
||||
# For Mingw, ensure paths are in UNIX format before anything is touched
|
||||
if $mingw ; then
|
||||
[ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] &&
|
||||
JAVA_HOME="$(cd "$JAVA_HOME" || (echo "cannot cd into $JAVA_HOME."; exit 1); pwd)"
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
javaExecutable="$(which javac)"
|
||||
if [ -n "$javaExecutable" ] && ! [ "$(expr "\"$javaExecutable\"" : '\([^ ]*\)')" = "no" ]; then
|
||||
# readlink(1) is not available as standard on Solaris 10.
|
||||
readLink=$(which readlink)
|
||||
if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then
|
||||
if $darwin ; then
|
||||
javaHome="$(dirname "\"$javaExecutable\"")"
|
||||
javaExecutable="$(cd "\"$javaHome\"" && pwd -P)/javac"
|
||||
else
|
||||
javaExecutable="$(readlink -f "\"$javaExecutable\"")"
|
||||
fi
|
||||
javaHome="$(dirname "\"$javaExecutable\"")"
|
||||
javaHome=$(expr "$javaHome" : '\(.*\)/bin')
|
||||
JAVA_HOME="$javaHome"
|
||||
export JAVA_HOME
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$JAVACMD" ] ; then
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
else
|
||||
JAVACMD="$(\unset -f command 2>/dev/null; \command -v java)"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
echo "Error: JAVA_HOME is not defined correctly." >&2
|
||||
echo " We cannot execute $JAVACMD" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
echo "Warning: JAVA_HOME environment variable is not set."
|
||||
fi
|
||||
|
||||
# traverses directory structure from process work directory to filesystem root
|
||||
# first directory with .mvn subdirectory is considered project base directory
|
||||
find_maven_basedir() {
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
echo "Path not specified to find_maven_basedir"
|
||||
return 1
|
||||
fi
|
||||
|
||||
basedir="$1"
|
||||
wdir="$1"
|
||||
while [ "$wdir" != '/' ] ; do
|
||||
if [ -d "$wdir"/.mvn ] ; then
|
||||
basedir=$wdir
|
||||
break
|
||||
fi
|
||||
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
|
||||
if [ -d "${wdir}" ]; then
|
||||
wdir=$(cd "$wdir/.." || exit 1; pwd)
|
||||
fi
|
||||
# end of workaround
|
||||
done
|
||||
printf '%s' "$(cd "$basedir" || exit 1; pwd)"
|
||||
}
|
||||
|
||||
# concatenates all lines of a file
|
||||
concat_lines() {
|
||||
if [ -f "$1" ]; then
|
||||
# Remove \r in case we run on Windows within Git Bash
|
||||
# and check out the repository with auto CRLF management
|
||||
# enabled. Otherwise, we may read lines that are delimited with
|
||||
# \r\n and produce $'-Xarg\r' rather than -Xarg due to word
|
||||
# splitting rules.
|
||||
tr -s '\r\n' ' ' < "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
log() {
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
printf '%s\n' "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
BASE_DIR=$(find_maven_basedir "$(dirname "$0")")
|
||||
if [ -z "$BASE_DIR" ]; then
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR
|
||||
log "$MAVEN_PROJECTBASEDIR"
|
||||
|
||||
##########################################################################################
|
||||
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||
# This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||
##########################################################################################
|
||||
wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar"
|
||||
if [ -r "$wrapperJarPath" ]; then
|
||||
log "Found $wrapperJarPath"
|
||||
else
|
||||
log "Couldn't find $wrapperJarPath, downloading it ..."
|
||||
|
||||
if [ -n "$MVNW_REPOURL" ]; then
|
||||
wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
|
||||
else
|
||||
wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
|
||||
fi
|
||||
while IFS="=" read -r key value; do
|
||||
# Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' )
|
||||
safeValue=$(echo "$value" | tr -d '\r')
|
||||
case "$key" in (wrapperUrl) wrapperUrl="$safeValue"; break ;;
|
||||
esac
|
||||
done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties"
|
||||
log "Downloading from: $wrapperUrl"
|
||||
|
||||
if $cygwin; then
|
||||
wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath")
|
||||
fi
|
||||
|
||||
if command -v wget > /dev/null; then
|
||||
log "Found wget ... using wget"
|
||||
[ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet"
|
||||
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
|
||||
wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
|
||||
else
|
||||
wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
|
||||
fi
|
||||
elif command -v curl > /dev/null; then
|
||||
log "Found curl ... using curl"
|
||||
[ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent"
|
||||
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
|
||||
curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath"
|
||||
else
|
||||
curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath"
|
||||
fi
|
||||
else
|
||||
log "Falling back to using Java to download"
|
||||
javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java"
|
||||
javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class"
|
||||
# For Cygwin, switch paths to Windows format before running javac
|
||||
if $cygwin; then
|
||||
javaSource=$(cygpath --path --windows "$javaSource")
|
||||
javaClass=$(cygpath --path --windows "$javaClass")
|
||||
fi
|
||||
if [ -e "$javaSource" ]; then
|
||||
if [ ! -e "$javaClass" ]; then
|
||||
log " - Compiling MavenWrapperDownloader.java ..."
|
||||
("$JAVA_HOME/bin/javac" "$javaSource")
|
||||
fi
|
||||
if [ -e "$javaClass" ]; then
|
||||
log " - Running MavenWrapperDownloader.java ..."
|
||||
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
##########################################################################################
|
||||
# End of extension
|
||||
##########################################################################################
|
||||
|
||||
# If specified, validate the SHA-256 sum of the Maven wrapper jar file
|
||||
wrapperSha256Sum=""
|
||||
while IFS="=" read -r key value; do
|
||||
case "$key" in (wrapperSha256Sum) wrapperSha256Sum=$value; break ;;
|
||||
esac
|
||||
done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties"
|
||||
if [ -n "$wrapperSha256Sum" ]; then
|
||||
wrapperSha256Result=false
|
||||
if command -v sha256sum > /dev/null; then
|
||||
if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c > /dev/null 2>&1; then
|
||||
wrapperSha256Result=true
|
||||
fi
|
||||
elif command -v shasum > /dev/null; then
|
||||
if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c > /dev/null 2>&1; then
|
||||
wrapperSha256Result=true
|
||||
fi
|
||||
else
|
||||
echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available."
|
||||
echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties."
|
||||
exit 1
|
||||
fi
|
||||
if [ $wrapperSha256Result = false ]; then
|
||||
echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2
|
||||
echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2
|
||||
echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin; then
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME")
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=$(cygpath --path --windows "$CLASSPATH")
|
||||
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
|
||||
MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR")
|
||||
fi
|
||||
|
||||
# Provide a "standardized" way to retrieve the CLI args that will
|
||||
# work with both Windows and non-Windows executions.
|
||||
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*"
|
||||
export MAVEN_CMD_LINE_ARGS
|
||||
|
||||
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
# shellcheck disable=SC2086 # safe args
|
||||
exec "$JAVACMD" \
|
||||
$MAVEN_OPTS \
|
||||
$MAVEN_DEBUG_OPTS \
|
||||
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||
"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
@ -0,0 +1,205 @@
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Licensed to the Apache Software Foundation (ASF) under one
|
||||
@REM or more contributor license agreements. See the NOTICE file
|
||||
@REM distributed with this work for additional information
|
||||
@REM regarding copyright ownership. The ASF licenses this file
|
||||
@REM to you under the Apache License, Version 2.0 (the
|
||||
@REM "License"); you may not use this file except in compliance
|
||||
@REM with the License. You may obtain a copy of the License at
|
||||
@REM
|
||||
@REM https://www.apache.org/licenses/LICENSE-2.0
|
||||
@REM
|
||||
@REM Unless required by applicable law or agreed to in writing,
|
||||
@REM software distributed under the License is distributed on an
|
||||
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
@REM KIND, either express or implied. See the License for the
|
||||
@REM specific language governing permissions and limitations
|
||||
@REM under the License.
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Apache Maven Wrapper startup batch script, version 3.2.0
|
||||
@REM
|
||||
@REM Required ENV vars:
|
||||
@REM JAVA_HOME - location of a JDK home dir
|
||||
@REM
|
||||
@REM Optional ENV vars
|
||||
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
|
||||
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
|
||||
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
@REM e.g. to debug Maven itself, use
|
||||
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
|
||||
@echo off
|
||||
@REM set title of command window
|
||||
title %0
|
||||
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
|
||||
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
|
||||
|
||||
@REM set %HOME% to equivalent of $HOME
|
||||
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
|
||||
|
||||
@REM Execute a user defined script before this one
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
|
||||
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
|
||||
if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
|
||||
:skipRcPre
|
||||
|
||||
@setlocal
|
||||
|
||||
set ERROR_CODE=0
|
||||
|
||||
@REM To isolate internal variables from possible post scripts, we use another setlocal
|
||||
@setlocal
|
||||
|
||||
@REM ==== START VALIDATION ====
|
||||
if not "%JAVA_HOME%" == "" goto OkJHome
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME not found in your environment. >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
:OkJHome
|
||||
if exist "%JAVA_HOME%\bin\java.exe" goto init
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME is set to an invalid directory. >&2
|
||||
echo JAVA_HOME = "%JAVA_HOME%" >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
@REM ==== END VALIDATION ====
|
||||
|
||||
:init
|
||||
|
||||
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
|
||||
@REM Fallback to current working directory if not found.
|
||||
|
||||
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
|
||||
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
|
||||
|
||||
set EXEC_DIR=%CD%
|
||||
set WDIR=%EXEC_DIR%
|
||||
:findBaseDir
|
||||
IF EXIST "%WDIR%"\.mvn goto baseDirFound
|
||||
cd ..
|
||||
IF "%WDIR%"=="%CD%" goto baseDirNotFound
|
||||
set WDIR=%CD%
|
||||
goto findBaseDir
|
||||
|
||||
:baseDirFound
|
||||
set MAVEN_PROJECTBASEDIR=%WDIR%
|
||||
cd "%EXEC_DIR%"
|
||||
goto endDetectBaseDir
|
||||
|
||||
:baseDirNotFound
|
||||
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
|
||||
cd "%EXEC_DIR%"
|
||||
|
||||
:endDetectBaseDir
|
||||
|
||||
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
|
||||
|
||||
@setlocal EnableExtensions EnableDelayedExpansion
|
||||
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
|
||||
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
|
||||
|
||||
:endReadAdditionalConfig
|
||||
|
||||
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
|
||||
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
|
||||
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
|
||||
|
||||
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
|
||||
IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B
|
||||
)
|
||||
|
||||
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||
if exist %WRAPPER_JAR% (
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Found %WRAPPER_JAR%
|
||||
)
|
||||
) else (
|
||||
if not "%MVNW_REPOURL%" == "" (
|
||||
SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
|
||||
)
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Couldn't find %WRAPPER_JAR%, downloading it ...
|
||||
echo Downloading from: %WRAPPER_URL%
|
||||
)
|
||||
|
||||
powershell -Command "&{"^
|
||||
"$webclient = new-object System.Net.WebClient;"^
|
||||
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
|
||||
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
|
||||
"}"^
|
||||
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^
|
||||
"}"
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Finished downloading %WRAPPER_JAR%
|
||||
)
|
||||
)
|
||||
@REM End of extension
|
||||
|
||||
@REM If specified, validate the SHA-256 sum of the Maven wrapper jar file
|
||||
SET WRAPPER_SHA_256_SUM=""
|
||||
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
|
||||
IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B
|
||||
)
|
||||
IF NOT %WRAPPER_SHA_256_SUM%=="" (
|
||||
powershell -Command "&{"^
|
||||
"$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^
|
||||
"If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^
|
||||
" Write-Output 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^
|
||||
" Write-Output 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^
|
||||
" Write-Output 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^
|
||||
" exit 1;"^
|
||||
"}"^
|
||||
"}"
|
||||
if ERRORLEVEL 1 goto error
|
||||
)
|
||||
|
||||
@REM Provide a "standardized" way to retrieve the CLI args that will
|
||||
@REM work with both Windows and non-Windows executions.
|
||||
set MAVEN_CMD_LINE_ARGS=%*
|
||||
|
||||
%MAVEN_JAVA_EXE% ^
|
||||
%JVM_CONFIG_MAVEN_PROPS% ^
|
||||
%MAVEN_OPTS% ^
|
||||
%MAVEN_DEBUG_OPTS% ^
|
||||
-classpath %WRAPPER_JAR% ^
|
||||
"-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
|
||||
%WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
|
||||
if ERRORLEVEL 1 goto error
|
||||
goto end
|
||||
|
||||
:error
|
||||
set ERROR_CODE=1
|
||||
|
||||
:end
|
||||
@endlocal & set ERROR_CODE=%ERROR_CODE%
|
||||
|
||||
if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
|
||||
@REM check for post script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
|
||||
if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
|
||||
:skipRcPost
|
||||
|
||||
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
|
||||
if "%MAVEN_BATCH_PAUSE%"=="on" pause
|
||||
|
||||
if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
|
||||
|
||||
cmd /C exit /B %ERROR_CODE%
|
@ -0,0 +1,82 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>3.2.3</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>fr.iut.sciencequest</groupId>
|
||||
<artifactId>sae</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>sae</name>
|
||||
<description>API SAE ScienceQuest</description>
|
||||
<properties>
|
||||
<java.version>21</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-hateoas</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.modelmapper</groupId>
|
||||
<artifactId>modelmapper</artifactId>
|
||||
<version>3.2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>1.16.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -0,0 +1,28 @@
|
||||
package fr.iut.sciencequest.sae;
|
||||
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.accept.FixedContentNegotiationStrategy;
|
||||
import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Configuration
|
||||
public class ApplicationConfig implements WebMvcConfigurer {
|
||||
public static final int DEFAULT_PAGEABLE_SIZE = 2;
|
||||
|
||||
@Bean
|
||||
public ModelMapper modelMapper() {
|
||||
return new ModelMapper();
|
||||
}
|
||||
|
||||
// Permet de forcer l'affichage des erreurs en JSON sans prendre en compte les headers du client
|
||||
@Override
|
||||
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
|
||||
configurer.strategies(List.of(new FixedContentNegotiationStrategy(MediaType.APPLICATION_JSON)));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
package fr.iut.sciencequest.sae;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
import org.springframework.web.util.ContentCachingResponseWrapper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
@Component
|
||||
@Order(1)
|
||||
public class ApplicationFilter extends OncePerRequestFilter {
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public ApplicationFilter(ObjectMapper objectMapper) {
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
protected void doFilterInternal(@Nullable HttpServletRequest request, @Nullable HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
|
||||
// Intercept and modify the JSON response
|
||||
assert response != null;
|
||||
ContentCachingResponseWrapper responseWrapper = new ContentCachingResponseWrapper(response);
|
||||
|
||||
filterChain.doFilter(request, responseWrapper);
|
||||
|
||||
if (responseWrapper.getContentType() != null && responseWrapper.getContentType().startsWith(MediaType.APPLICATION_JSON_VALUE)) {
|
||||
try {
|
||||
// Parse JSON
|
||||
JsonNode root = objectMapper.readTree(new String(responseWrapper.getContentAsByteArray(), StandardCharsets.UTF_8));
|
||||
|
||||
// Vérification de l'existance du node _embedded && s'il contient un node enfant
|
||||
JsonNode embeddedNode = root.get("_embedded");
|
||||
if (embeddedNode != null && embeddedNode.isObject() && embeddedNode.size() == 1) {
|
||||
JsonNode subNode = embeddedNode.elements().next(); // Récupération node enfant
|
||||
if (subNode != null && subNode.isArray()) {
|
||||
ArrayNode subNodeArr = (ArrayNode) subNode;
|
||||
|
||||
// Correction de la profondeur
|
||||
((ObjectNode) root).remove("_embedded");
|
||||
((ObjectNode) root).set("_embedded", subNodeArr);
|
||||
}
|
||||
}
|
||||
|
||||
// Retour du JSON dans l'objectMapper en String
|
||||
String modifiedResponseBody = objectMapper.writeValueAsString(root);
|
||||
|
||||
// Ecriture du JSON dans la réponse
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
|
||||
response.getOutputStream().write(modifiedResponseBody.getBytes(StandardCharsets.UTF_8));
|
||||
} catch (IOException e) { System.err.println("ApplicationFilter (_embedded) : " + e.getMessage()); }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package fr.iut.sciencequest.sae;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@SpringBootApplication
|
||||
public class SaeApplication {
|
||||
@Bean
|
||||
public WebMvcConfigurer corsConfigurer() {
|
||||
return new WebMvcConfigurer() {
|
||||
@Override
|
||||
@NonNull
|
||||
public void addCorsMappings(@Nullable CorsRegistry registry) {
|
||||
assert registry != null;
|
||||
registry.addMapping("/**").allowedOrigins("*");
|
||||
}
|
||||
};
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SaeApplication.class, args);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package fr.iut.sciencequest.sae;
|
||||
|
||||
/*
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
public class SecurityConfig {
|
||||
|
||||
@Bean
|
||||
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
||||
http.authorizeHttpRequests(auth -> auth.anyRequest().permitAll());
|
||||
|
||||
return http.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PasswordEncoder encoder() {
|
||||
return new BCryptPasswordEncoder();
|
||||
}
|
||||
|
||||
}*/
|
@ -0,0 +1,26 @@
|
||||
package fr.iut.sciencequest.sae.assemblers;
|
||||
|
||||
import fr.iut.sciencequest.sae.dto.difficulte.DifficulteDTO;
|
||||
import fr.iut.sciencequest.sae.dto.difficulte.DifficulteSimpleDTO;
|
||||
import fr.iut.sciencequest.sae.entities.Difficulte;
|
||||
import jakarta.annotation.Nullable;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class DifficulteModelAssembler extends RepresentationModelAssemblerSupport<Difficulte, DifficulteSimpleDTO> {
|
||||
public DifficulteModelAssembler() {
|
||||
super(Difficulte.class, DifficulteSimpleDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public DifficulteSimpleDTO toModel(@Nullable Difficulte entity) {
|
||||
ModelMapper mapper = new ModelMapper();
|
||||
return mapper.map(entity, DifficulteSimpleDTO.class);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package fr.iut.sciencequest.sae.assemblers;
|
||||
|
||||
|
||||
import fr.iut.sciencequest.sae.controllers.ScientifiqueController;
|
||||
import org.springframework.hateoas.CollectionModel;
|
||||
import fr.iut.sciencequest.sae.dto.indice.IndiceSimpleWithScientifiquesIdDTO;
|
||||
import fr.iut.sciencequest.sae.entities.Indice;
|
||||
import jakarta.annotation.Nullable;
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
|
||||
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
|
||||
|
||||
@Component
|
||||
public class IndiceModelAssembler extends RepresentationModelAssemblerSupport<Indice, IndiceSimpleWithScientifiquesIdDTO> {
|
||||
public IndiceModelAssembler() {
|
||||
super(Indice.class, IndiceSimpleWithScientifiquesIdDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public IndiceSimpleWithScientifiquesIdDTO toModel(@Nullable Indice entity) {
|
||||
ModelMapper mapper = new ModelMapper();
|
||||
return mapper.map(entity, IndiceSimpleWithScientifiquesIdDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public CollectionModel<IndiceSimpleWithScientifiquesIdDTO> toCollectionModel(@Nullable Iterable<? extends Indice> entities) {
|
||||
assert entities != null;
|
||||
CollectionModel<IndiceSimpleWithScientifiquesIdDTO> collectionModel = super.toCollectionModel(entities);
|
||||
// Le lien n'est pas ajouté automatiquement si l'on utilise pas la pagination /!\
|
||||
if(collectionModel.iterator().hasNext())
|
||||
collectionModel.add(linkTo(methodOn(ScientifiqueController.class).getScientistHints(collectionModel.iterator().next().getScientifique().getId())).withSelfRel());
|
||||
|
||||
return collectionModel;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package fr.iut.sciencequest.sae.assemblers;
|
||||
|
||||
import fr.iut.sciencequest.sae.controllers.PartieKahootController;
|
||||
import fr.iut.sciencequest.sae.entities.Partie;
|
||||
import fr.iut.sciencequest.sae.dto.partie.PartieDTO;
|
||||
import jakarta.annotation.Nullable;
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class PartieModelAssembler extends RepresentationModelAssemblerSupport<Partie, PartieDTO> {
|
||||
public PartieModelAssembler() {
|
||||
super(PartieKahootController.class, PartieDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public PartieDTO toModel(@Nullable Partie entity) {
|
||||
ModelMapper mapper = new ModelMapper();
|
||||
return mapper.map(entity, PartieDTO.class);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package fr.iut.sciencequest.sae.assemblers;
|
||||
|
||||
import fr.iut.sciencequest.sae.controllers.QuestionController;
|
||||
import fr.iut.sciencequest.sae.entities.Question;
|
||||
import fr.iut.sciencequest.sae.dto.question.QuestionDTO;
|
||||
import jakarta.annotation.Nullable;
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class QuestionModelAssembler extends RepresentationModelAssemblerSupport<Question, QuestionDTO> {
|
||||
|
||||
public QuestionModelAssembler() {
|
||||
super(QuestionController.class, QuestionDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public QuestionDTO toModel(@Nullable Question entity) {
|
||||
ModelMapper mapper = new ModelMapper();
|
||||
return mapper.map(entity, QuestionDTO.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package fr.iut.sciencequest.sae.assemblers;
|
||||
|
||||
import fr.iut.sciencequest.sae.controllers.ScientifiqueController;
|
||||
import fr.iut.sciencequest.sae.dto.scientifique.ScientifiqueDTO;
|
||||
import fr.iut.sciencequest.sae.entities.Scientifique;
|
||||
import jakarta.annotation.Nullable;
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
|
||||
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
|
||||
|
||||
@Component
|
||||
public class ScientifiqueModelAssembler extends RepresentationModelAssemblerSupport<Scientifique, ScientifiqueDTO> {
|
||||
public ScientifiqueModelAssembler() {
|
||||
super(ScientifiqueController.class, ScientifiqueDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public ScientifiqueDTO toModel(@Nullable Scientifique entity) {
|
||||
ModelMapper mapper = new ModelMapper();
|
||||
ScientifiqueDTO scientifiqueDTO = mapper.map(entity, ScientifiqueDTO.class);
|
||||
scientifiqueDTO.add(linkTo(methodOn(ScientifiqueController.class).getScientistHints(scientifiqueDTO.getId())).withRel("indices"));
|
||||
scientifiqueDTO.add(linkTo(methodOn(ScientifiqueController.class).getScientistById(scientifiqueDTO.getId())).withSelfRel());
|
||||
return scientifiqueDTO;
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package fr.iut.sciencequest.sae.assemblers;
|
||||
|
||||
import fr.iut.sciencequest.sae.dto.thematique.ThematiqueDTO;
|
||||
import fr.iut.sciencequest.sae.entities.Thematique;
|
||||
import jakarta.annotation.Nullable;
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class ThematiqueModelAssembler extends RepresentationModelAssemblerSupport<Thematique, ThematiqueDTO> {
|
||||
public ThematiqueModelAssembler() {
|
||||
super(Thematique.class, ThematiqueDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public ThematiqueDTO toModel(@Nullable Thematique entity) {
|
||||
ModelMapper mapper = new ModelMapper();
|
||||
return mapper.map(entity, ThematiqueDTO.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package fr.iut.sciencequest.sae.assemblers;
|
||||
|
||||
import fr.iut.sciencequest.sae.dto.thematique.ThematiqueSimpleDTO;
|
||||
import fr.iut.sciencequest.sae.entities.Thematique;
|
||||
import jakarta.annotation.Nullable;
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class ThematiqueSimpleModelAssembler extends RepresentationModelAssemblerSupport<Thematique, ThematiqueSimpleDTO> {
|
||||
public ThematiqueSimpleModelAssembler() {
|
||||
super(Thematique.class, ThematiqueSimpleDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public ThematiqueSimpleDTO toModel(@Nullable Thematique entity) {
|
||||
ModelMapper mapper = new ModelMapper();
|
||||
return mapper.map(entity, ThematiqueSimpleDTO.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package fr.iut.sciencequest.sae.controllers;
|
||||
|
||||
|
||||
import fr.iut.sciencequest.sae.ApplicationConfig;
|
||||
import fr.iut.sciencequest.sae.assemblers.DifficulteModelAssembler;
|
||||
import fr.iut.sciencequest.sae.dto.difficulte.DifficulteSimpleDTO;
|
||||
import fr.iut.sciencequest.sae.entities.Difficulte;
|
||||
import fr.iut.sciencequest.sae.services.DifficulteService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.web.PageableDefault;
|
||||
import org.springframework.data.web.PagedResourcesAssembler;
|
||||
import org.springframework.hateoas.PagedModel;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/api/v1/difficultes")
|
||||
public class DifficulteController {
|
||||
private final DifficulteModelAssembler difficulteModelAssembler;
|
||||
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
|
||||
private final PagedResourcesAssembler<Difficulte> pagedResourcesAssembler;
|
||||
public final DifficulteService difficulteService;
|
||||
|
||||
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public PagedModel<DifficulteSimpleDTO> getAllDifficultes(@PageableDefault(size = ApplicationConfig.DEFAULT_PAGEABLE_SIZE) Pageable p) {
|
||||
Page<Difficulte> difficultePage = this.difficulteService.findAll(p);
|
||||
return pagedResourcesAssembler.toModel(difficultePage, difficulteModelAssembler);
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package fr.iut.sciencequest.sae.controllers;
|
||||
|
||||
import fr.iut.sciencequest.sae.dto.indice.IndiceDTO;
|
||||
import fr.iut.sciencequest.sae.dto.indice.IndiceSimpleWithScientifiquesIdDTO;
|
||||
import fr.iut.sciencequest.sae.dto.indice.IndiceWithoutIdAndScientifiqueIdOnlyForPatchDTO;
|
||||
import fr.iut.sciencequest.sae.entities.Indice;
|
||||
import fr.iut.sciencequest.sae.services.IndiceService;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.Validator;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.validation.BeanPropertyBindingResult;
|
||||
import org.springframework.validation.beanvalidation.SpringValidatorAdapter;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/api/v1/indices")
|
||||
public class IndiceController {
|
||||
private final IndiceService indiceService;
|
||||
private final ModelMapper modelMapper;
|
||||
private final Validator validator;
|
||||
|
||||
@PatchMapping(value="/{id}", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public IndiceSimpleWithScientifiquesIdDTO patchIndice(@PathVariable("id") int id, @RequestBody @Valid IndiceWithoutIdAndScientifiqueIdOnlyForPatchDTO indicePartial) throws NoSuchMethodException, MethodArgumentNotValidException {
|
||||
IndiceDTO indicedto = this.modelMapper.map(indicePartial, IndiceDTO.class);
|
||||
indicedto.setId(id);
|
||||
BeanPropertyBindingResult errors = new BeanPropertyBindingResult(indicedto, "indice");;
|
||||
SpringValidatorAdapter adapter = new SpringValidatorAdapter(this.validator);
|
||||
adapter.validate(indicedto, errors);
|
||||
if(errors.hasErrors()){
|
||||
throw new MethodArgumentNotValidException(null, errors); }
|
||||
|
||||
|
||||
Indice indice = this.modelMapper.map(indicedto, Indice.class);
|
||||
return this.modelMapper.map(this.indiceService.update(indice), IndiceSimpleWithScientifiquesIdDTO.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package fr.iut.sciencequest.sae.controllers;
|
||||
|
||||
import fr.iut.sciencequest.sae.dto.invite.InviteSimpleDTO;
|
||||
import fr.iut.sciencequest.sae.dto.invite.InviteWithPseudoOnlyDTO;
|
||||
import fr.iut.sciencequest.sae.entities.Invite;
|
||||
import fr.iut.sciencequest.sae.services.InviteService;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import static org.springframework.data.jpa.domain.AbstractPersistable_.id;
|
||||
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/api/v1/invite")
|
||||
public class InviteController {
|
||||
private final InviteService inviteService;
|
||||
private final ModelMapper modelMapper;
|
||||
|
||||
@PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public InviteSimpleDTO createInvite(@RequestBody @Valid InviteWithPseudoOnlyDTO inviteRequest){
|
||||
Invite invite = this.modelMapper.map(inviteRequest, Invite.class);
|
||||
return this.modelMapper.map(this.inviteService.create(invite), InviteSimpleDTO.class);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public InviteSimpleDTO getInvite(@PathVariable int id){
|
||||
return this.modelMapper.map(this.inviteService.findById(id), InviteSimpleDTO.class);
|
||||
}
|
||||
|
||||
@PatchMapping(value = "/{id}", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public InviteSimpleDTO updateInvite(@PathVariable int id, @RequestBody @Valid InviteWithPseudoOnlyDTO updatedInvite){
|
||||
Invite invite = this.inviteService.findById(id);
|
||||
invite.setPseudo(updatedInvite.getPseudo());
|
||||
return this.modelMapper.map(this.inviteService.update(invite), InviteSimpleDTO.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package fr.iut.sciencequest.sae.controllers;
|
||||
|
||||
import fr.iut.sciencequest.sae.dto.jeu.JeuDTO;
|
||||
import fr.iut.sciencequest.sae.entities.Jeu;
|
||||
import fr.iut.sciencequest.sae.exceptions.notFound.JeuNotFoundException;
|
||||
import fr.iut.sciencequest.sae.repositories.JeuRepository;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
|
||||
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/api/v1/jeux")
|
||||
public class JeuController {
|
||||
private final JeuRepository jeuRepository;
|
||||
private final ModelMapper modelMapper;
|
||||
|
||||
@RequestMapping(value = "/{id}",method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public Jeu getJeu(@PathVariable int id) {
|
||||
return this.jeuRepository.findById(id).orElseThrow(() -> new JeuNotFoundException(id));
|
||||
}
|
||||
|
||||
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public Iterable<JeuDTO> getJeux() {
|
||||
List<JeuDTO> jeuDTOList = new ArrayList<>();
|
||||
for(Jeu jeu : this.jeuRepository.findAll()) {
|
||||
jeuDTOList.add(this.modelMapper.map(jeu, JeuDTO.class).add(
|
||||
linkTo(JeuController.class).slash(jeu.getId()).withRel("self")
|
||||
));
|
||||
}
|
||||
return jeuDTOList;
|
||||
}
|
||||
}
|
@ -0,0 +1,195 @@
|
||||
package fr.iut.sciencequest.sae.controllers;
|
||||
|
||||
import fr.iut.sciencequest.sae.controllers.request.PartieAddJoueurRequest;
|
||||
import fr.iut.sciencequest.sae.controllers.request.PartieReponse;
|
||||
import fr.iut.sciencequest.sae.controllers.request.PartieRequest;
|
||||
import fr.iut.sciencequest.sae.dto.partieKahoot.PartieKahootDTO;
|
||||
import fr.iut.sciencequest.sae.dto.partieKahoot.PartieKahootQuestionDTO;
|
||||
import fr.iut.sciencequest.sae.dto.partieKahoot.PartieKahootStatusDTO;
|
||||
import fr.iut.sciencequest.sae.dto.reponse.ReponseValideDTO;
|
||||
import fr.iut.sciencequest.sae.entities.*;
|
||||
import fr.iut.sciencequest.sae.exceptions.notFound.ScorePartieKahootJoueurNotFound;
|
||||
import fr.iut.sciencequest.sae.exceptions.partie.*;
|
||||
import fr.iut.sciencequest.sae.repositories.QuestionPartieKahootRepository;
|
||||
import fr.iut.sciencequest.sae.repositories.ReponsePartieKahootRepository;
|
||||
import fr.iut.sciencequest.sae.repositories.ScorePartieKahootJoueurRepository;
|
||||
import fr.iut.sciencequest.sae.services.*;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/api/v1/partie/kahoot")
|
||||
public class PartieKahootController {
|
||||
private static final int NOMBRE_QUESTION = 2;
|
||||
|
||||
private final QuestionPartieKahootRepository questionPartieKahootRepository;
|
||||
private final ScorePartieKahootJoueurRepository scorePartieKahootJoueurRepository;
|
||||
private final PartieKahootService partieKahootService;
|
||||
private final JoueurService joueurService;
|
||||
private final QuestionService questionService;
|
||||
private final ReponseService reponseService;
|
||||
private final ThematiqueService thematiqueService;
|
||||
private final DifficulteService difficulteService;
|
||||
private final ModelMapper modelMapper;
|
||||
private final ReponsePartieKahootRepository reponsePartieKahootRepository;
|
||||
|
||||
@RequestMapping(value = "/{codeInvitation}",method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public PartieKahootDTO getPartie(@PathVariable String codeInvitation) {
|
||||
PartieKahoot partieKahoot = this.partieKahootService.getPartieKahootByIdOrCodeInvitation(codeInvitation);
|
||||
partieKahoot = this.partieKahootService.maintenirAJourQuestionActuel(partieKahoot);
|
||||
return this.modelMapper.map(partieKahoot, PartieKahootDTO.class);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public PartieKahootDTO createPartie(@RequestBody @Valid PartieRequest request) {
|
||||
PartieKahoot partie = new PartieKahoot();
|
||||
Joueur joueur = this.joueurService.findById(request.getIdJoueur());
|
||||
partie.setJoueurs(List.of(joueur));
|
||||
partie.setThematiques(new ArrayList<>());
|
||||
for(int idThematique: request.getThematiques()){
|
||||
partie.getThematiques().add(this.thematiqueService.findById(idThematique));
|
||||
}
|
||||
|
||||
partie.setDifficulte(this.difficulteService.findById(request.getIdDifficulte()));
|
||||
partie = this.partieKahootService.create(partie);
|
||||
|
||||
//setup score
|
||||
ScorePartieKahootJoueur score = new ScorePartieKahootJoueur();
|
||||
score.setId(new ScorePartieKahootJoueurKey(joueur.getId(), partie.getId()));
|
||||
score.setJoueur(joueur);
|
||||
score.setPartie(partie);
|
||||
this.scorePartieKahootJoueurRepository.save(score);
|
||||
|
||||
//setup question
|
||||
List<Question> questions = this.questionService.getRandomQuestions(NOMBRE_QUESTION, partie.getThematiques(), partie.getDifficulte());
|
||||
for(Question question: questions){
|
||||
QuestionPartieKahoot questionPartie = new QuestionPartieKahoot();
|
||||
questionPartie.setId(new QuestionPartieKahootKey(question.getId(), partie.getId()));
|
||||
questionPartie.setQuestion(question);
|
||||
questionPartie.setPartie(partie);
|
||||
this.questionPartieKahootRepository.save(questionPartie);
|
||||
}
|
||||
|
||||
partie = this.partieKahootService.findById(partie.getId());
|
||||
|
||||
return this.modelMapper.map(partie, PartieKahootDTO.class);
|
||||
}
|
||||
|
||||
@PostMapping(value= "/{codeInvitation}", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public PartieKahootDTO addPlayerToPartie(@PathVariable String codeInvitation, @RequestBody @Valid PartieAddJoueurRequest request){
|
||||
Joueur joueur = this.joueurService.findById(request.getIdJoueur());
|
||||
PartieKahoot partie = this.partieKahootService.getPartieKahootByIdOrCodeInvitation(codeInvitation);
|
||||
if(!partie.getStatus().equals(Status.Pending)) throw new PartyAlreadyStartedException();
|
||||
if(!partie.getJoueurs().stream().anyMatch(j -> j.getId() == joueur.getId())){
|
||||
ScorePartieKahootJoueur score = new ScorePartieKahootJoueur();
|
||||
score.setId(new ScorePartieKahootJoueurKey(joueur.getId(), partie.getId()));
|
||||
score.setJoueur(joueur);
|
||||
score.setPartie(partie);
|
||||
partie.getScores().add(score);
|
||||
partie.getJoueurs().add(joueur);
|
||||
this.scorePartieKahootJoueurRepository.save(score);
|
||||
}
|
||||
return this.modelMapper.map(this.partieKahootService.update(partie), PartieKahootDTO.class);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/{codeInvitation}/demarrer", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public PartieKahootStatusDTO demarrerPartie(@PathVariable String codeInvitation){
|
||||
PartieKahoot partieKahoot = this.partieKahootService.getPartieKahootByIdOrCodeInvitation(codeInvitation);
|
||||
|
||||
if(partieKahoot.getStatus() == Status.Started || partieKahoot.getStatus() == Status.DisplayingScore){
|
||||
throw new PartyAlreadyStartedException();
|
||||
}
|
||||
partieKahoot.setStatus(Status.Started);
|
||||
|
||||
partieKahoot = this.partieKahootService.questionSuivante(partieKahoot);
|
||||
return this.modelMapper.map(partieKahoot, PartieKahootStatusDTO.class);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/{codeInvitation}/status", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public PartieKahootStatusDTO getStatusPartie(@PathVariable String codeInvitation){
|
||||
PartieKahoot partieKahoot = this.partieKahootService.getPartieKahootByIdOrCodeInvitation(codeInvitation);
|
||||
partieKahoot = this.partieKahootService.maintenirAJourQuestionActuel(partieKahoot);
|
||||
return this.modelMapper.map(partieKahoot, PartieKahootStatusDTO.class);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/{codeInvitation}/question", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public PartieKahootQuestionDTO getQuestionActuel(@PathVariable String codeInvitation){
|
||||
PartieKahoot partieKahoot = this.partieKahootService.getPartieKahootByIdOrCodeInvitation(codeInvitation);
|
||||
partieKahoot = this.partieKahootService.maintenirAJourQuestionActuel(partieKahoot);
|
||||
if(partieKahoot.getStatus() == Status.Pending){
|
||||
throw new PartyNotStartedException();
|
||||
}
|
||||
if(partieKahoot.getStatus() == Status.Ended){
|
||||
throw new PartyIsEndedException();
|
||||
}
|
||||
return this.modelMapper.map(partieKahoot, PartieKahootQuestionDTO.class);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/{codeInvitation}/reponse", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ReponseValideDTO repondre(@PathVariable String codeInvitation, @RequestBody @Valid PartieReponse request){
|
||||
PartieKahoot partieKahoot = this.partieKahootService.getPartieKahootByIdOrCodeInvitation(codeInvitation);
|
||||
partieKahoot = this.partieKahootService.maintenirAJourQuestionActuel(partieKahoot);
|
||||
Joueur joueur = this.joueurService.findById(request.getIdJoueur());
|
||||
|
||||
if(partieKahoot.getStatus() == Status.Pending){
|
||||
throw new PartyNotStartedException();
|
||||
}
|
||||
if(partieKahoot.getStatus() == Status.Ended){
|
||||
throw new PartyIsEndedException();
|
||||
}
|
||||
|
||||
if(partieKahoot.getJoueurs().stream().noneMatch(joueur1 -> Objects.equals(joueur1.getId(), joueur.getId()))){
|
||||
throw new JoueurPasDansPartieException();
|
||||
}
|
||||
|
||||
Question questionActuel = partieKahoot.getQuestionActuel();
|
||||
if(partieKahoot.getReponses().stream()
|
||||
.filter(partieReponse -> Objects.equals(partieReponse.getJoueur().getId(), joueur.getId()))
|
||||
.anyMatch(partieReponse -> Objects.equals(partieReponse.getQuestion().getId(), questionActuel.getId()))){
|
||||
throw new QuestionDejaReponduException();
|
||||
}
|
||||
|
||||
|
||||
Reponse reponse = reponseService.findById(request.getIdReponse());
|
||||
if(!Objects.equals(reponse.getQuestion().getId(), partieKahoot.getQuestionActuel().getId())){
|
||||
throw new ReponseIncoherenteException();
|
||||
}
|
||||
|
||||
Calendar actualDate = Calendar.getInstance();
|
||||
actualDate.setTime(new Date());
|
||||
if(actualDate.after(partieKahoot.getTempsLimiteReponse())){
|
||||
throw new ReponseTempsLimiteDepasseException();
|
||||
}
|
||||
|
||||
ReponsePartieKahoot reponsePartie = new ReponsePartieKahoot();
|
||||
reponsePartie.setId(new ReponsePartieKahootKey(reponse.getQuestion().getId(), partieKahoot.getId(), joueur.getId()));
|
||||
reponsePartie.setQuestion(reponse.getQuestion());
|
||||
reponsePartie.setPartie(partieKahoot);
|
||||
reponsePartie.setReponse(reponse);
|
||||
reponsePartie.setJoueur(joueur);
|
||||
this.reponsePartieKahootRepository.save(reponsePartie);
|
||||
|
||||
ScorePartieKahootJoueur scorePartieKahootJoueur = partieKahoot.getScores().stream().filter(socre -> socre.getJoueur().getId() == joueur.getId())
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new ScorePartieKahootJoueurNotFound(joueur.getId()));
|
||||
|
||||
scorePartieKahootJoueur.setScore(scorePartieKahootJoueur.getScore() + this.partieKahootService.getScore(partieKahoot.getTempsLimiteReponse(), reponse));
|
||||
this.scorePartieKahootJoueurRepository.save(scorePartieKahootJoueur);
|
||||
|
||||
return this.modelMapper.map(reponse, ReponseValideDTO.class);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package fr.iut.sciencequest.sae.controllers;
|
||||
|
||||
import fr.iut.sciencequest.sae.ApplicationConfig;
|
||||
import fr.iut.sciencequest.sae.assemblers.QuestionModelAssembler;
|
||||
import fr.iut.sciencequest.sae.dto.question.QuestionDTO;
|
||||
import fr.iut.sciencequest.sae.entities.Question;
|
||||
import fr.iut.sciencequest.sae.services.QuestionService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.web.PageableDefault;
|
||||
import org.springframework.data.web.PagedResourcesAssembler;
|
||||
import org.springframework.hateoas.PagedModel;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/api/v1/questions")
|
||||
public class QuestionController {
|
||||
private final QuestionService questionService;
|
||||
private final QuestionModelAssembler questionModelAssembler;
|
||||
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
|
||||
private final PagedResourcesAssembler<Question> pagedResourcesAssembler;
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public PagedModel<QuestionDTO> getAllQuestions(@PageableDefault(size = ApplicationConfig.DEFAULT_PAGEABLE_SIZE) Pageable p,
|
||||
@RequestParam(value = "scientifiqueId", defaultValue = "") Integer scientifiqueId) {
|
||||
|
||||
Page<Question> questionPage = (scientifiqueId == null ? questionService.findAll(p) : questionService.findWithCriteria(p, scientifiqueId)); //TEMPORAIRE NE PAS ENLEVER
|
||||
return pagedResourcesAssembler.toModel(questionPage, questionModelAssembler);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,72 @@
|
||||
package fr.iut.sciencequest.sae.controllers;
|
||||
|
||||
import fr.iut.sciencequest.sae.ApplicationConfig;
|
||||
import fr.iut.sciencequest.sae.assemblers.IndiceModelAssembler;
|
||||
import fr.iut.sciencequest.sae.assemblers.ScientifiqueModelAssembler;
|
||||
import fr.iut.sciencequest.sae.dto.indice.IndiceLibelleOnlyDTO;
|
||||
import fr.iut.sciencequest.sae.dto.indice.IndiceSimpleWithScientifiquesIdDTO;
|
||||
import fr.iut.sciencequest.sae.dto.scientifique.ScientifiqueDTO;
|
||||
import fr.iut.sciencequest.sae.entities.Indice;
|
||||
import fr.iut.sciencequest.sae.entities.Scientifique;
|
||||
import fr.iut.sciencequest.sae.services.IndiceService;
|
||||
import fr.iut.sciencequest.sae.services.ScientifiqueService;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.web.PageableDefault;
|
||||
import org.springframework.data.web.PagedResourcesAssembler;
|
||||
import org.springframework.hateoas.CollectionModel;
|
||||
import org.springframework.hateoas.PagedModel;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/api/v1/scientifiques")
|
||||
public class ScientifiqueController {
|
||||
|
||||
private final ScientifiqueService scientifiqueService;
|
||||
private final ScientifiqueModelAssembler scientifiqueModelAssembler;
|
||||
private final IndiceModelAssembler indiceModelAssembler;
|
||||
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
|
||||
private final PagedResourcesAssembler<Scientifique> pagedResourcesAssembler;
|
||||
private final IndiceService indiceService;
|
||||
private final ModelMapper modelMapper;
|
||||
|
||||
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public PagedModel<ScientifiqueDTO> getAllScientists(@PageableDefault(size = ApplicationConfig.DEFAULT_PAGEABLE_SIZE) Pageable p,
|
||||
@RequestParam(value = "thematiqueId", defaultValue = "") Integer thematiqueId,
|
||||
@RequestParam(value = "difficulteId", defaultValue = "") Integer difficulteId) {
|
||||
|
||||
Page<Scientifique> page = (thematiqueId == null && difficulteId == null ? this.scientifiqueService.findAll(p) : this.scientifiqueService.findAllWithCriteria(p, thematiqueId, difficulteId));
|
||||
return pagedResourcesAssembler.toModel(page, scientifiqueModelAssembler);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ScientifiqueDTO getScientistById(@PathVariable Integer id) {
|
||||
return scientifiqueModelAssembler.toModel(this.scientifiqueService.findById(id));
|
||||
}
|
||||
|
||||
@GetMapping(value="/{id}/indices", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public CollectionModel<IndiceSimpleWithScientifiquesIdDTO> getScientistHints(@PathVariable Integer id) {
|
||||
return indiceModelAssembler.toCollectionModel(this.scientifiqueService.getLinkedIndicesByScientifiqueId(id));
|
||||
}
|
||||
|
||||
@PostMapping(value="/{id}/indices", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public IndiceSimpleWithScientifiquesIdDTO postIndice(@PathVariable Integer id, @Valid @RequestBody IndiceLibelleOnlyDTO indiceWithLibelleOnly) {
|
||||
Indice indice = this.modelMapper.map(indiceWithLibelleOnly, Indice.class);
|
||||
indice.setScientifique(this.scientifiqueService.findById(id));
|
||||
return this.modelMapper.map(this.indiceService.create(indice), IndiceSimpleWithScientifiquesIdDTO.class);
|
||||
}
|
||||
|
||||
@DeleteMapping(value="/{id}/indices/{indiceId}")
|
||||
@ResponseStatus(HttpStatus.ACCEPTED)
|
||||
public void deleteIndice(@PathVariable Integer id, @PathVariable Integer indiceId) {
|
||||
this.indiceService.delete(indiceId);
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package fr.iut.sciencequest.sae.controllers;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import fr.iut.sciencequest.sae.ApplicationConfig;
|
||||
import fr.iut.sciencequest.sae.assemblers.ThematiqueModelAssembler;
|
||||
import fr.iut.sciencequest.sae.assemblers.ThematiqueSimpleModelAssembler;
|
||||
import fr.iut.sciencequest.sae.dto.thematique.ThematiqueLibelleOnlyDTO;
|
||||
import fr.iut.sciencequest.sae.dto.thematique.ThematiqueSimpleDTO;
|
||||
import fr.iut.sciencequest.sae.entities.Thematique;
|
||||
import fr.iut.sciencequest.sae.services.ScientifiqueService;
|
||||
import fr.iut.sciencequest.sae.services.ThematiqueService;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.web.PageableDefault;
|
||||
import org.springframework.data.web.PagedResourcesAssembler;
|
||||
import org.springframework.hateoas.PagedModel;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/api/v1/thematiques")
|
||||
public class ThematiqueController {
|
||||
private final ThematiqueService thematiqueService;
|
||||
private final ScientifiqueService scientifiqueService;
|
||||
private final ThematiqueModelAssembler thematiqueModelAssembler;
|
||||
private final ThematiqueSimpleModelAssembler thematiqueSimpleModelAssembler;
|
||||
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
|
||||
private final PagedResourcesAssembler<Thematique> pagedResourcesAssembler;
|
||||
private final ModelMapper modelMapper;
|
||||
|
||||
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public PagedModel<ThematiqueSimpleDTO> getAllThematiques(@PageableDefault(size = ApplicationConfig.DEFAULT_PAGEABLE_SIZE) Pageable p) {
|
||||
return pagedResourcesAssembler.toModel(this.thematiqueService.findAll(p), thematiqueSimpleModelAssembler);
|
||||
}
|
||||
|
||||
@PostMapping(produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public ThematiqueSimpleDTO createThematique(@Valid @RequestBody ThematiqueLibelleOnlyDTO thematique) {
|
||||
return thematiqueSimpleModelAssembler.toModel(this.thematiqueService.create(this.modelMapper.map(thematique, Thematique.class)));
|
||||
}
|
||||
|
||||
@PatchMapping(path = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public ThematiqueSimpleDTO updateThematique(@PathVariable("id") int id, @Valid @RequestBody ThematiqueLibelleOnlyDTO partialThematique) {
|
||||
Thematique dstThematique = this.thematiqueService.findById(id);
|
||||
if(partialThematique.getLibelle() != null){
|
||||
dstThematique.setLibelle(partialThematique.getLibelle());
|
||||
}
|
||||
return thematiqueSimpleModelAssembler.toModel(this.thematiqueService.update(dstThematique));
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package fr.iut.sciencequest.sae.controllers;
|
||||
|
||||
import fr.iut.sciencequest.sae.assemblers.ScientifiqueModelAssembler;
|
||||
import fr.iut.sciencequest.sae.dto.utilisateur.UtilisateurDTO;
|
||||
import fr.iut.sciencequest.sae.dto.utilisateur.UtilisateurWithPasswordDTO;
|
||||
import fr.iut.sciencequest.sae.services.ScientifiqueService;
|
||||
import fr.iut.sciencequest.sae.services.UtilisateurService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@AllArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/utilisateur")
|
||||
public class UtilisateurController {
|
||||
private final UtilisateurService utilisateurService;
|
||||
private final ModelMapper modelMapper;
|
||||
|
||||
@PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public UtilisateurDTO register(@RequestBody UtilisateurWithPasswordDTO user) {
|
||||
return utilisateurService.save(user);
|
||||
}
|
||||
|
||||
@PostMapping(path = "/connexion", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public UtilisateurDTO login(@RequestBody UtilisateurWithPasswordDTO user) {
|
||||
return utilisateurService.login(user);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public UtilisateurDTO getUser(@PathVariable Integer id) {
|
||||
return modelMapper.map(this.utilisateurService.findUserById(id), UtilisateurDTO.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package fr.iut.sciencequest.sae.controllers.request;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class PartieAddJoueurRequest {
|
||||
@NotNull
|
||||
private int idJoueur;
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package fr.iut.sciencequest.sae.controllers.request;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class PartieReponse {
|
||||
@NotNull
|
||||
private int idReponse;
|
||||
@NotNull
|
||||
private int idJoueur;
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package fr.iut.sciencequest.sae.controllers.request;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class PartieRequest {
|
||||
@NotNull
|
||||
private int idJoueur;
|
||||
|
||||
@NotEmpty
|
||||
private List<Integer> thematiques;
|
||||
|
||||
@NotNull
|
||||
private Integer idDifficulte;
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package fr.iut.sciencequest.sae.dto.admin;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import jakarta.validation.constraints.Email;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.*;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class AdminWithPasswordDTO extends RepresentationModel<AdminWithPasswordDTO> {
|
||||
@NotNull
|
||||
private Integer id;
|
||||
|
||||
@Email
|
||||
@NotNull
|
||||
@NotBlank
|
||||
private String email;
|
||||
|
||||
@NotNull
|
||||
@NotBlank
|
||||
private String password;
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package fr.iut.sciencequest.sae.dto.difficulte;
|
||||
|
||||
import fr.iut.sciencequest.sae.entities.Scientifique;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.*;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class DifficulteDTO extends RepresentationModel<DifficulteDTO> {
|
||||
@NotNull
|
||||
private Integer id;
|
||||
|
||||
@NotBlank
|
||||
private String libelle;
|
||||
|
||||
private Iterable<Scientifique> scientifiques;
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package fr.iut.sciencequest.sae.dto.difficulte;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.*;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class DifficulteIdOnlyDTO extends RepresentationModel<DifficulteIdOnlyDTO> {
|
||||
@NotNull
|
||||
private Integer id;
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package fr.iut.sciencequest.sae.dto.difficulte;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.*;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class DifficulteSimpleDTO extends RepresentationModel<DifficulteSimpleDTO> {
|
||||
@NotNull
|
||||
private Integer id;
|
||||
|
||||
@NotBlank
|
||||
private String libelle;
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package fr.iut.sciencequest.sae.dto.indice;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import fr.iut.sciencequest.sae.dto.scientifique.ScientifiqueDTO;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.*;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class IndiceDTO extends RepresentationModel<IndiceDTO> {
|
||||
@NotNull
|
||||
private Integer id;
|
||||
|
||||
@NotBlank
|
||||
private String libelle;
|
||||
|
||||
@NotNull
|
||||
private ScientifiqueDTO scientifique;
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package fr.iut.sciencequest.sae.dto.indice;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.*;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class IndiceLibelleOnlyDTO extends RepresentationModel<IndiceLibelleOnlyDTO> {
|
||||
@NotBlank
|
||||
private String libelle;
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package fr.iut.sciencequest.sae.dto.indice;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import fr.iut.sciencequest.sae.dto.scientifique.ScientifiqueIdOnlyDTO;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.*;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class IndiceSimpleWithScientifiquesIdDTO extends RepresentationModel<IndiceSimpleWithScientifiquesIdDTO> {
|
||||
@NotNull
|
||||
private Integer id;
|
||||
|
||||
@NotBlank
|
||||
private String libelle;
|
||||
|
||||
@NotNull
|
||||
private ScientifiqueIdOnlyDTO scientifique;
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package fr.iut.sciencequest.sae.dto.indice;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import fr.iut.sciencequest.sae.dto.scientifique.ScientifiqueIdOnlyDTO;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.*;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class IndiceWithoutIdAndScientifiqueIdOnlyForPatchDTO extends RepresentationModel<IndiceWithoutIdAndScientifiqueIdOnlyForPatchDTO> {
|
||||
|
||||
private String libelle;
|
||||
|
||||
@Valid
|
||||
private ScientifiqueIdOnlyDTO scientifique;
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package fr.iut.sciencequest.sae.dto.invite;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import fr.iut.sciencequest.sae.dto.partie.PartieDTO;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.*;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class InviteDTO extends RepresentationModel<InviteDTO> {
|
||||
@NotNull
|
||||
private Integer id;
|
||||
|
||||
@NotBlank
|
||||
private String pseudo;
|
||||
|
||||
private PartieDTO partie;
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package fr.iut.sciencequest.sae.dto.invite;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import fr.iut.sciencequest.sae.dto.partie.PartieDTO;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.*;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class InviteSimpleDTO extends RepresentationModel<InviteSimpleDTO> {
|
||||
@NotNull
|
||||
private Integer id;
|
||||
|
||||
@NotBlank
|
||||
private String pseudo;
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package fr.iut.sciencequest.sae.dto.invite;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import fr.iut.sciencequest.sae.dto.partie.PartieDTO;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.*;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class InviteWithPseudoOnlyDTO extends RepresentationModel<InviteWithPseudoOnlyDTO> {
|
||||
@NotBlank
|
||||
private String pseudo;
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package fr.iut.sciencequest.sae.dto.jeu;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.*;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class JeuDTO extends RepresentationModel<JeuDTO> {
|
||||
@NotNull
|
||||
private Integer id;
|
||||
|
||||
@NotBlank
|
||||
private String nom;
|
||||
|
||||
@Min(0)
|
||||
private Integer nbrParties;
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package fr.iut.sciencequest.sae.dto.joueur;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import fr.iut.sciencequest.sae.dto.partie.PartieDTO;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.*;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class JoueurDTO extends RepresentationModel<JoueurDTO> {
|
||||
@NotNull
|
||||
private Integer id;
|
||||
|
||||
@NotBlank
|
||||
private String pseudo;
|
||||
|
||||
private PartieDTO partieEnCours;
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package fr.iut.sciencequest.sae.dto.joueur;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import fr.iut.sciencequest.sae.dto.partie.PartieDTO;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.*;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class JoueurSimpleDTO extends RepresentationModel<JoueurSimpleDTO> {
|
||||
@NotNull
|
||||
private Integer id;
|
||||
|
||||
@NotBlank
|
||||
private String pseudo;
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package fr.iut.sciencequest.sae.dto.partie;
|
||||
|
||||
import fr.iut.sciencequest.sae.dto.difficulte.DifficulteSimpleDTO;
|
||||
import fr.iut.sciencequest.sae.dto.jeu.JeuDTO;
|
||||
import fr.iut.sciencequest.sae.dto.joueur.JoueurSimpleDTO;
|
||||
import fr.iut.sciencequest.sae.dto.thematique.ThematiqueSimpleDTO;
|
||||
import fr.iut.sciencequest.sae.entities.Status;
|
||||
import fr.iut.sciencequest.sae.entities.Thematique;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.*;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class PartieDTO extends RepresentationModel<PartieDTO> {
|
||||
@NotNull
|
||||
private Integer id;
|
||||
@NotEmpty
|
||||
private String codeInvitation;
|
||||
@NotEmpty
|
||||
private List<JoueurSimpleDTO> joueurs;
|
||||
@NotEmpty
|
||||
private List<ThematiqueSimpleDTO> thematiques;
|
||||
@NotNull
|
||||
private DifficulteSimpleDTO difficulte;
|
||||
@NotNull
|
||||
private Status status;
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package fr.iut.sciencequest.sae.dto.partieKahoot;
|
||||
|
||||
import fr.iut.sciencequest.sae.dto.difficulte.DifficulteSimpleDTO;
|
||||
import fr.iut.sciencequest.sae.dto.jeu.JeuDTO;
|
||||
import fr.iut.sciencequest.sae.dto.joueur.JoueurSimpleDTO;
|
||||
import fr.iut.sciencequest.sae.dto.question.QuestionDTO;
|
||||
import fr.iut.sciencequest.sae.dto.thematique.ThematiqueSimpleDTO;
|
||||
import fr.iut.sciencequest.sae.entities.Status;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.*;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class PartieKahootDTO extends RepresentationModel<PartieKahootDTO> {
|
||||
@NotNull
|
||||
private Integer id;
|
||||
@NotEmpty
|
||||
private String codeInvitation;
|
||||
@NotEmpty
|
||||
private List<JoueurSimpleDTO> joueurs;
|
||||
@NotEmpty
|
||||
private List<ThematiqueSimpleDTO> thematiques;
|
||||
@NotNull
|
||||
private DifficulteSimpleDTO difficulte;
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package fr.iut.sciencequest.sae.dto.partieKahoot;
|
||||
|
||||
import fr.iut.sciencequest.sae.dto.question.QuestionDTO;
|
||||
import fr.iut.sciencequest.sae.dto.reponse.ReponseSimpleDTO;
|
||||
import fr.iut.sciencequest.sae.dto.scorePartieJoueur.ScorePartieKahootJoueurDTO;
|
||||
import fr.iut.sciencequest.sae.entities.Reponse;
|
||||
import fr.iut.sciencequest.sae.entities.Status;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.*;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class PartieKahootQuestionDTO extends RepresentationModel<PartieKahootQuestionDTO> {
|
||||
private QuestionDTO questionActuel;
|
||||
private Calendar tempsLimiteReponse;
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package fr.iut.sciencequest.sae.dto.partieKahoot;
|
||||
|
||||
import fr.iut.sciencequest.sae.dto.scorePartieJoueur.ScorePartieKahootJoueurDTO;
|
||||
import fr.iut.sciencequest.sae.entities.Status;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.*;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class PartieKahootStatusDTO extends RepresentationModel<PartieKahootStatusDTO> {
|
||||
@NotNull
|
||||
private Status status;
|
||||
|
||||
private List<ScorePartieKahootJoueurDTO> scores;
|
||||
|
||||
private Calendar tempsAffichageScore;
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package fr.iut.sciencequest.sae.dto.question;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import fr.iut.sciencequest.sae.dto.reponse.ReponseSimpleDTO;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.*;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class QuestionDTO extends RepresentationModel<QuestionDTO> {
|
||||
@NotNull
|
||||
private Integer id;
|
||||
@NotBlank
|
||||
private String question;
|
||||
|
||||
@NotEmpty
|
||||
private List<ReponseSimpleDTO> reponses;
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package fr.iut.sciencequest.sae.dto.reponse;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import fr.iut.sciencequest.sae.dto.question.QuestionDTO;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.*;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ReponseDTO extends RepresentationModel<ReponseDTO> {
|
||||
@NotNull
|
||||
private Integer id;
|
||||
|
||||
@NotNull
|
||||
@NotBlank
|
||||
private String reponse;
|
||||
|
||||
@NotEmpty
|
||||
private QuestionDTO question;
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package fr.iut.sciencequest.sae.dto.reponse;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.*;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ReponseSimpleDTO extends RepresentationModel<ReponseSimpleDTO> {
|
||||
@NotNull
|
||||
private Integer id;
|
||||
|
||||
@NotNull
|
||||
@NotBlank
|
||||
private String reponse;
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package fr.iut.sciencequest.sae.dto.reponse;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.*;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ReponseValideDTO extends RepresentationModel<ReponseValideDTO> {
|
||||
@NotNull
|
||||
@NotBlank
|
||||
private boolean estValide;
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package fr.iut.sciencequest.sae.dto.scientifique;
|
||||
|
||||
import fr.iut.sciencequest.sae.dto.difficulte.DifficulteSimpleDTO;
|
||||
import fr.iut.sciencequest.sae.dto.thematique.ThematiqueSimpleDTO;
|
||||
import fr.iut.sciencequest.sae.entities.Sexe;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.*;
|
||||
import org.hibernate.validator.constraints.URL;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class ScientifiqueDTO extends RepresentationModel<ScientifiqueDTO> {
|
||||
@NotNull
|
||||
private Integer id;
|
||||
|
||||
@NotNull
|
||||
private DifficulteSimpleDTO difficulte;
|
||||
|
||||
@NotNull
|
||||
private ThematiqueSimpleDTO thematique;
|
||||
|
||||
@URL
|
||||
private String pathToPhoto;
|
||||
|
||||
@NotBlank
|
||||
private String nom;
|
||||
|
||||
@NotBlank
|
||||
private String prenom;
|
||||
|
||||
@NotBlank
|
||||
private String descriptif;
|
||||
|
||||
@NotEmpty
|
||||
private Date dateNaissance;
|
||||
|
||||
@NotBlank
|
||||
private Sexe sexe;
|
||||
|
||||
@Size(max=1)
|
||||
private BigDecimal ratioTrouve;
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package fr.iut.sciencequest.sae.dto.scientifique;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.*;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
import org.springframework.lang.NonNull;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class ScientifiqueIdOnlyDTO extends RepresentationModel<ScientifiqueIdOnlyDTO> {
|
||||
@NotNull
|
||||
private Integer id;
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package fr.iut.sciencequest.sae.dto.scientifique;
|
||||
|
||||
import fr.iut.sciencequest.sae.dto.difficulte.DifficulteSimpleDTO;
|
||||
import fr.iut.sciencequest.sae.dto.thematique.ThematiqueSimpleDTO;
|
||||
import fr.iut.sciencequest.sae.entities.Sexe;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.*;
|
||||
import org.hibernate.validator.constraints.URL;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class ScientifiqueSimpleDTO extends RepresentationModel<ScientifiqueSimpleDTO> {
|
||||
@NotNull
|
||||
private Integer id;
|
||||
|
||||
@NotNull
|
||||
private DifficulteSimpleDTO difficulte;
|
||||
|
||||
@NotNull
|
||||
private ThematiqueSimpleDTO thematique;
|
||||
|
||||
@URL
|
||||
private String pathToPhoto;
|
||||
|
||||
@NotBlank
|
||||
private String nom;
|
||||
|
||||
@NotBlank
|
||||
private String prenom;
|
||||
|
||||
@NotBlank
|
||||
private String descriptif;
|
||||
|
||||
@NotEmpty
|
||||
private Date dateNaissance;
|
||||
|
||||
@NotBlank
|
||||
private Sexe sexe;
|
||||
|
||||
@Size(max=1)
|
||||
private BigDecimal ratioTrouve;
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package fr.iut.sciencequest.sae.dto.scorePartieJoueur;
|
||||
|
||||
import fr.iut.sciencequest.sae.dto.joueur.JoueurSimpleDTO;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.*;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class ScorePartieKahootJoueurDTO extends RepresentationModel<ScorePartieKahootJoueurDTO> {
|
||||
@NotNull
|
||||
private JoueurSimpleDTO joueur;
|
||||
|
||||
private Integer score;
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package fr.iut.sciencequest.sae.dto.thematique;
|
||||
|
||||
import fr.iut.sciencequest.sae.entities.Scientifique;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.*;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class ThematiqueDTO extends RepresentationModel<ThematiqueDTO> {
|
||||
@NotNull
|
||||
private Integer id;
|
||||
|
||||
@NotBlank
|
||||
private String libelle;
|
||||
|
||||
private Iterable<Scientifique> scientifiques;
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package fr.iut.sciencequest.sae.dto.thematique;
|
||||
|
||||
import fr.iut.sciencequest.sae.entities.Scientifique;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.*;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class ThematiqueIdOnlyDTO extends RepresentationModel<ThematiqueIdOnlyDTO> {
|
||||
@NotNull
|
||||
private Integer id;
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package fr.iut.sciencequest.sae.dto.thematique;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.*;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class ThematiqueLibelleOnlyDTO extends RepresentationModel<ThematiqueLibelleOnlyDTO> {
|
||||
@NotBlank
|
||||
private String libelle;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package fr.iut.sciencequest.sae.dto.thematique;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.*;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class ThematiqueSimpleDTO extends RepresentationModel<ThematiqueSimpleDTO> {
|
||||
@NotNull
|
||||
private Integer id;
|
||||
|
||||
@NotBlank
|
||||
private String libelle;
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package fr.iut.sciencequest.sae.dto.utilisateur;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import jakarta.validation.constraints.Email;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.*;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class UtilisateurDTO extends RepresentationModel<UtilisateurDTO> {
|
||||
@NotNull
|
||||
private Integer id;
|
||||
|
||||
@Email
|
||||
@NotNull
|
||||
private String email;
|
||||
|
||||
@NotBlank
|
||||
private String pseudo;
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package fr.iut.sciencequest.sae.dto.utilisateur;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import jakarta.validation.constraints.Email;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.*;
|
||||
import org.springframework.hateoas.RepresentationModel;
|
||||
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class UtilisateurWithPasswordDTO extends RepresentationModel<UtilisateurWithPasswordDTO> {
|
||||
@NotNull
|
||||
private Integer id;
|
||||
|
||||
@Email
|
||||
@NotNull
|
||||
private String email;
|
||||
|
||||
@NotBlank
|
||||
private String motDePasse;
|
||||
|
||||
@NotBlank
|
||||
private String pseudo;
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package fr.iut.sciencequest.sae.entities;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.validation.constraints.Email;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name="admin")
|
||||
public class Admin {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
@Column(unique = true)
|
||||
private String email;
|
||||
|
||||
@Column
|
||||
private String password;
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package fr.iut.sciencequest.sae.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.annotations.Fetch;
|
||||
import org.hibernate.annotations.FetchMode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name="difficulte")
|
||||
@JsonIdentityInfo(
|
||||
generator = ObjectIdGenerators.PropertyGenerator.class,
|
||||
property = "id")
|
||||
public class Difficulte {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
@Column(unique = true)
|
||||
private String libelle;
|
||||
|
||||
@JsonManagedReference
|
||||
@OneToMany(mappedBy = "difficulte")
|
||||
@Fetch(FetchMode.JOIN)
|
||||
private List<Scientifique> scientifiques;
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package fr.iut.sciencequest.sae.entities;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name="indice")
|
||||
public class Indice {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String libelle;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name="idscientifique", nullable = false)
|
||||
private Scientifique scientifique;
|
||||
}
|
||||
|
@ -0,0 +1,16 @@
|
||||
package fr.iut.sciencequest.sae.entities;
|
||||
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = "invite")
|
||||
@PrimaryKeyJoinColumn(name = "idjoueur")
|
||||
public class Invite extends Joueur {
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package fr.iut.sciencequest.sae.entities;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name="jeu")
|
||||
public class Jeu {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
@Column(unique = true)
|
||||
private String nom;
|
||||
|
||||
@Column(name = "nbrparties")
|
||||
private Integer nbrParties = 0;
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package fr.iut.sciencequest.sae.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.annotations.Fetch;
|
||||
import org.hibernate.annotations.FetchMode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@Inheritance(strategy = InheritanceType.JOINED)
|
||||
@Entity
|
||||
@Table(name="joueur")
|
||||
public class Joueur {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
@Column(unique = true)
|
||||
private String pseudo;
|
||||
|
||||
@JsonBackReference
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "idpartieencours")
|
||||
@Fetch(FetchMode.JOIN)
|
||||
@EqualsAndHashCode.Exclude
|
||||
private Partie partieEnCours;
|
||||
|
||||
@OneToMany(mappedBy = "joueur")
|
||||
private List<ScorePartieKahootJoueur> scores;
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package fr.iut.sciencequest.sae.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@Inheritance(strategy = InheritanceType.JOINED)
|
||||
@Entity
|
||||
@Table(name="partie")
|
||||
public class Partie {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
@Column(name = "codeinvitation", unique = true, nullable = false) //default value : see Schema.sql
|
||||
private String codeInvitation;
|
||||
|
||||
@JsonManagedReference
|
||||
@OneToMany(cascade = CascadeType.MERGE, fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "idpartieencours")
|
||||
private List<Joueur> joueurs;
|
||||
|
||||
@Column(name = "datecreation") //default value : see Schema.sql
|
||||
private Date dateCreation;
|
||||
|
||||
@ManyToMany(fetch = FetchType.EAGER)
|
||||
@JoinTable(
|
||||
name = "thematiqueselectionnee",
|
||||
joinColumns = @JoinColumn(name = "idpartie"),
|
||||
inverseJoinColumns = @JoinColumn(name="idthematique")
|
||||
)
|
||||
private List<Thematique> thematiques;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name="iddifficulte", nullable = false)
|
||||
private Difficulte difficulte;
|
||||
|
||||
@Column(name = "status", nullable = false)
|
||||
@Enumerated(EnumType.STRING)
|
||||
private Status status = Status.Pending;
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package fr.iut.sciencequest.sae.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name="partiekahoot")
|
||||
@PrimaryKeyJoinColumn(name = "idpartie")
|
||||
public class PartieKahoot extends Partie {
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name="idquestionactuel")
|
||||
private Question questionActuel;
|
||||
|
||||
@Column(name = "tempslimitereponse")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Calendar tempsLimiteReponse;
|
||||
|
||||
@Column(name = "tempsaffichagescore")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Calendar tempsAffichageScore;
|
||||
|
||||
@JsonManagedReference
|
||||
@OneToMany(mappedBy = "partie", fetch = FetchType.EAGER)
|
||||
private List<QuestionPartieKahoot> questions;
|
||||
|
||||
@JsonManagedReference
|
||||
@OneToMany(mappedBy = "partie", fetch = FetchType.EAGER)
|
||||
private List<ReponsePartieKahoot> reponses;
|
||||
|
||||
@JsonManagedReference
|
||||
@OneToMany(mappedBy = "partie", fetch = FetchType.EAGER)
|
||||
private List<ScorePartieKahootJoueur> scores;
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package fr.iut.sciencequest.sae.entities;
|
||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.annotations.Fetch;
|
||||
import org.hibernate.annotations.FetchMode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name="question")
|
||||
public class Question {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
private String question;
|
||||
|
||||
@JsonManagedReference
|
||||
@OneToMany(mappedBy = "question")
|
||||
@Fetch(FetchMode.JOIN) // Sinon crash (Could not write JSON: failed to lazily initialize a collection of T)
|
||||
private List<Reponse> reponses;
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
package fr.iut.sciencequest.sae.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name="questionpartiekahoot")
|
||||
public class QuestionPartieKahoot {
|
||||
@EmbeddedId
|
||||
private QuestionPartieKahootKey id = new QuestionPartieKahootKey();
|
||||
|
||||
@JsonBackReference
|
||||
@ManyToOne
|
||||
@MapsId("idQuestion")
|
||||
@JoinColumn(name = "idquestion")
|
||||
private Question question;
|
||||
|
||||
@JsonBackReference
|
||||
@ManyToOne
|
||||
@MapsId("idPartieKahoot")
|
||||
@JoinColumn(name="idpartiekahoot")
|
||||
private PartieKahoot partie;
|
||||
|
||||
@Column(name = "aetepose")
|
||||
private boolean aEtePose = false;
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package fr.iut.sciencequest.sae.entities;
|
||||
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Embeddable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@Embeddable
|
||||
public class QuestionPartieKahootKey implements Serializable {
|
||||
@Column(name="idquestion")
|
||||
private Integer idQuestion;
|
||||
|
||||
@Column(name="idpartiekahoot")
|
||||
private Integer idPartieKahoot;
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package fr.iut.sciencequest.sae.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name="reponse")
|
||||
public class Reponse{
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
private String reponse;
|
||||
|
||||
@Column(name = "estvalide")
|
||||
private Boolean estValide;
|
||||
|
||||
@JsonBackReference
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "idquestion", nullable = false)
|
||||
private Question question;
|
||||
|
||||
@JsonBackReference
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "idscientifique", nullable = false)
|
||||
private Scientifique scientifique;
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package fr.iut.sciencequest.sae.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name="reponsepartiekahootjoueur")
|
||||
public class ReponsePartieKahoot {
|
||||
@EmbeddedId
|
||||
private ReponsePartieKahootKey id = new ReponsePartieKahootKey();
|
||||
|
||||
@JsonBackReference
|
||||
@ManyToOne
|
||||
@MapsId("idQuestion")
|
||||
@JoinColumn(name = "idquestion")
|
||||
private Question question;
|
||||
|
||||
@JsonBackReference
|
||||
@ManyToOne
|
||||
@MapsId("idPartie")
|
||||
@JoinColumn(name="idpartie")
|
||||
private PartieKahoot partie;
|
||||
|
||||
@JsonBackReference
|
||||
@ManyToOne
|
||||
@MapsId("idJoueur")
|
||||
@JoinColumn(name="idjoueur")
|
||||
private Joueur joueur;
|
||||
|
||||
@JsonBackReference
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "idreponse")
|
||||
private Reponse reponse;
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package fr.iut.sciencequest.sae.entities;
|
||||
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Embeddable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@Embeddable
|
||||
public class ReponsePartieKahootKey implements Serializable {
|
||||
@Column(name="idquestion")
|
||||
private Integer idQuestion;
|
||||
|
||||
@Column(name="idpartie")
|
||||
private Integer idPartie;
|
||||
|
||||
@Column(name="idjoueur")
|
||||
private Integer idJoueur;
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package fr.iut.sciencequest.sae.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
@AllArgsConstructor
|
||||
@RequiredArgsConstructor
|
||||
//@Relation(collectionRelation = "scientifiques", itemRelation = "scientifique")
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = "scientifique")
|
||||
@JsonIdentityInfo(
|
||||
generator = ObjectIdGenerators.PropertyGenerator.class,
|
||||
property = "id")
|
||||
public class Scientifique {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
@JsonBackReference
|
||||
@ManyToOne
|
||||
@JoinColumn(name="iddifficulte", nullable = false)
|
||||
private Difficulte difficulte;
|
||||
|
||||
@JsonBackReference
|
||||
@ManyToOne
|
||||
@JoinColumn(name="idthematique", nullable = false)
|
||||
private Thematique thematique;
|
||||
|
||||
@Column(name = "photo")
|
||||
private String pathToPhoto;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String nom;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String prenom;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String descriptif;
|
||||
|
||||
@Column(name = "datenaissance", nullable = false)
|
||||
private Date dateNaissance;
|
||||
|
||||
@Column(nullable = false)
|
||||
@Enumerated(EnumType.STRING)
|
||||
private Sexe sexe;
|
||||
|
||||
@Column(name = "ratiotrouvee")
|
||||
private BigDecimal ratioTrouve = BigDecimal.ZERO;
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package fr.iut.sciencequest.sae.entities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.annotations.Fetch;
|
||||
import org.hibernate.annotations.FetchMode;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name="scorepartiekahootjoueur")
|
||||
public class ScorePartieKahootJoueur {
|
||||
@EmbeddedId
|
||||
private ScorePartieKahootJoueurKey id = new ScorePartieKahootJoueurKey();
|
||||
|
||||
@ManyToOne
|
||||
@MapsId("idJoueur")
|
||||
@JoinColumn(name = "idjoueur")
|
||||
private Joueur joueur;
|
||||
|
||||
@ManyToOne
|
||||
@MapsId("idPartie")
|
||||
@JoinColumn(name="idpartie")
|
||||
private Partie partie;
|
||||
|
||||
private Integer score = 0;
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package fr.iut.sciencequest.sae.entities;
|
||||
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Embeddable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@Embeddable
|
||||
public class ScorePartieKahootJoueurKey implements Serializable {
|
||||
@Column(name="idjoueur")
|
||||
private Integer idJoueur;
|
||||
|
||||
@Column(name="idpartie")
|
||||
private Integer idPartie;
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package fr.iut.sciencequest.sae.entities;
|
||||
|
||||
public enum Sexe {
|
||||
F,
|
||||
H
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package fr.iut.sciencequest.sae.entities;
|
||||
|
||||
public enum Status {
|
||||
Pending,
|
||||
Started,
|
||||
DisplayingScore,
|
||||
Ended
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package fr.iut.sciencequest.sae.entities;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.annotations.Fetch;
|
||||
import org.hibernate.annotations.FetchMode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name="thematique")
|
||||
@JsonIdentityInfo(
|
||||
generator = ObjectIdGenerators.PropertyGenerator.class,
|
||||
property = "id")
|
||||
public class Thematique {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
@Column(unique = true)
|
||||
private String libelle;
|
||||
|
||||
@JsonManagedReference
|
||||
@OneToMany(mappedBy = "thematique")
|
||||
@Fetch(FetchMode.JOIN)
|
||||
private List<Scientifique> scientifiques;
|
||||
|
||||
@ManyToMany(mappedBy = "thematiques")
|
||||
List<Partie> parties;
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package fr.iut.sciencequest.sae.entities;
|
||||
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name="utilisateur")
|
||||
@PrimaryKeyJoinColumn(name = "idjoueur")
|
||||
public class Utilisateur extends Joueur {
|
||||
@Column(unique = true)
|
||||
private String email;
|
||||
|
||||
@Column(name = "password")
|
||||
private String motDePasse;
|
||||
}
|
||||
|
@ -0,0 +1,22 @@
|
||||
package fr.iut.sciencequest.sae.exceptions;
|
||||
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.hibernate.internal.util.collections.CollectionHelper.listOf;
|
||||
|
||||
@ResponseStatus(HttpStatus.CONFLICT)
|
||||
public class DuplicatedFieldException extends RuntimeException {
|
||||
|
||||
//TODO : retourner une erreur avec le msg + LA LISTE des fields concernés en format JSON
|
||||
public DuplicatedFieldException(String field){
|
||||
super("Unicity constraints broken on fields :" + listOf(field));
|
||||
}
|
||||
|
||||
public DuplicatedFieldException(List<String> fields){
|
||||
super("Unicity constraints broken on fields :" + fields);
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package fr.iut.sciencequest.sae.exceptions;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
@ResponseStatus(HttpStatus.CONFLICT)
|
||||
public class DuplicatedIdException extends RuntimeException{
|
||||
public DuplicatedIdException(){
|
||||
super("duplicated id");
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package fr.iut.sciencequest.sae.exceptions;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
@ResponseStatus(HttpStatus.NOT_ACCEPTABLE)
|
||||
public class IncorrectPageException extends RuntimeException {
|
||||
|
||||
public IncorrectPageException(String exception) {
|
||||
super(exception);
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package fr.iut.sciencequest.sae.exceptions;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
@ResponseStatus(HttpStatus.FORBIDDEN)
|
||||
public class IncorrectPasswordException extends RuntimeException {
|
||||
public IncorrectPasswordException() {
|
||||
super("Incorrect password");
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package fr.iut.sciencequest.sae.exceptions;
|
||||
|
||||
import jakarta.annotation.Nullable;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.HttpStatusCode;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.FieldError;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.context.request.WebRequest;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ControllerAdvice
|
||||
public class ValidationHandler extends ResponseEntityExceptionHandler {
|
||||
|
||||
@Override
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
public ResponseEntity<Object> handleMethodArgumentNotValid(MethodArgumentNotValidException ex, @Nullable HttpHeaders headers, @Nullable HttpStatusCode status, @Nullable WebRequest request) {
|
||||
Map<String, String> errors = new HashMap<>();
|
||||
ex.getBindingResult().getAllErrors().forEach((error) ->{
|
||||
|
||||
String fieldName = ((FieldError) error).getField();
|
||||
String message = error.getDefaultMessage();
|
||||
errors.put(fieldName, message);
|
||||
});
|
||||
return new ResponseEntity<>(errors, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package fr.iut.sciencequest.sae.exceptions.notFound;
|
||||
|
||||
public class DifficulteNotFoundException extends EntityNotFoundException{
|
||||
public DifficulteNotFoundException(int id) {
|
||||
super("Difficulté", id);
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package fr.iut.sciencequest.sae.exceptions.notFound;
|
||||
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
@ResponseStatus(HttpStatus.NOT_FOUND)
|
||||
public abstract class EntityNotFoundException extends RuntimeException {
|
||||
public EntityNotFoundException(){
|
||||
super("entity not found");
|
||||
}
|
||||
public EntityNotFoundException(String entityName, Object id){
|
||||
super(entityName + " not found with id : " + id);
|
||||
}
|
||||
|
||||
public EntityNotFoundException(String entityName, String fieldName, Object value){
|
||||
super(entityName + " not found with " + fieldName + " : " + value);
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package fr.iut.sciencequest.sae.exceptions.notFound;
|
||||
|
||||
public class IndiceNotFoundException extends EntityNotFoundException{
|
||||
public IndiceNotFoundException(int id){
|
||||
super("indice", id);
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package fr.iut.sciencequest.sae.exceptions.notFound;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
@ResponseStatus(HttpStatus.NOT_FOUND)
|
||||
public class InviteNotFoundException extends EntityNotFoundException{
|
||||
public InviteNotFoundException(int id) {
|
||||
super("Invite", id);
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package fr.iut.sciencequest.sae.exceptions.notFound;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
@ResponseStatus(HttpStatus.NOT_FOUND)
|
||||
public class JeuNotFoundException extends EntityNotFoundException{
|
||||
public JeuNotFoundException(int id) {
|
||||
super("Jeu", id);
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue