first commit
This commit is contained in:
commit
ec0dc019d8
|
@ -0,0 +1,37 @@
|
|||
HELP.md
|
||||
.gradle
|
||||
build/
|
||||
!gradle/wrapper/gradle-wrapper.jar
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
bin/
|
||||
!**/src/main/**/bin/
|
||||
!**/src/test/**/bin/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
out/
|
||||
!**/src/main/**/out/
|
||||
!**/src/test/**/out/
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
|
@ -0,0 +1,24 @@
|
|||
plugins {
|
||||
id 'org.springframework.boot' version '2.6.1'
|
||||
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
|
||||
id 'java'
|
||||
}
|
||||
|
||||
group = 'fr.cardon.simpleat'
|
||||
version = '0.0.1-SNAPSHOT'
|
||||
sourceCompatibility = '11'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||
runtimeOnly 'mysql:mysql-connector-java'
|
||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||
}
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,5 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
|
@ -0,0 +1,234 @@
|
|||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed 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.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=${0##*/}
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
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
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
|
@ -0,0 +1,89 @@
|
|||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem 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, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
|
@ -0,0 +1 @@
|
|||
rootProject.name = 'simpleat'
|
|
@ -0,0 +1,13 @@
|
|||
package fr.cardon.simpleat;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class SimpleatApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SimpleatApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
package fr.cardon.simpleat.controller;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import fr.cardon.simpleat.model.Personne;
|
||||
import fr.cardon.simpleat.model.Role;
|
||||
import fr.cardon.simpleat.repository.PersonneRepository;
|
||||
import fr.cardon.simpleat.repository.RoleRepository;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin("*")
|
||||
public class PersonneController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private PersonneRepository personneRepository;
|
||||
|
||||
@Autowired
|
||||
private RoleRepository roleRepository;
|
||||
|
||||
@GetMapping("/")
|
||||
@ResponseBody
|
||||
public String home(){
|
||||
|
||||
Personne p1 = new Personne();
|
||||
p1.setNom("Coco");
|
||||
p1.setPrenom("pouet");
|
||||
p1.setEmail("pouetcoco@gmail.com");
|
||||
p1.setPassword("hjfdzov");
|
||||
p1.setRoles(findRoleById(2));
|
||||
|
||||
//ajoutPersonne(p1);
|
||||
|
||||
|
||||
// Personne p2 = new Personne("coco","pouet","cocopouet@gmail.com","motdepasse");
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("<h1>Personne Enregistrée</h1>");
|
||||
sb.append("<a href='http://localhost:8080/users'>Voir la liste des personnes enregistrées</a>");
|
||||
return sb.toString();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@GetMapping("/users")
|
||||
public Collection<Personne> findAll(){
|
||||
|
||||
return personneRepository.findAll();
|
||||
}
|
||||
|
||||
@GetMapping("/user/{id}")
|
||||
public Personne findPersonneById(@PathVariable int id){
|
||||
|
||||
return personneRepository.findById(id);
|
||||
}
|
||||
|
||||
@PostMapping("/add-user")
|
||||
public ResponseEntity<?> ajoutPersonne(@RequestBody Personne personne){
|
||||
return ResponseEntity.status(HttpStatus.OK).body(personneRepository.save(personne));
|
||||
}
|
||||
|
||||
|
||||
@PutMapping(value = "/update-user/{id}")
|
||||
public ResponseEntity<?> modifPerso(@PathVariable int id, @RequestBody Personne personne){
|
||||
|
||||
// Personne persoAModif= null;
|
||||
// persoAModif = findById(id);
|
||||
// persoAModif.setNom(personne.getNom());
|
||||
// persoAModif.setPrenom(personne.getPrenom());
|
||||
// persoAModif.setEmail(personne.getEmail());
|
||||
// persoAModif.setPassword(personne.getPassword());
|
||||
return ResponseEntity.status(HttpStatus.OK).body(personneRepository.save(personne));
|
||||
}
|
||||
|
||||
@DeleteMapping(value = "/delete-user/{id}")
|
||||
public void suppressionPerso(@PathVariable int id){
|
||||
// Personne persoASuppr= new Personne();
|
||||
// persoASuppr = findById(id);
|
||||
|
||||
personneRepository.deleteById(id);
|
||||
}
|
||||
|
||||
|
||||
public Collection<Role> findRoleById(int idRole){
|
||||
return roleRepository.findCollectionById(idRole);
|
||||
}
|
||||
|
||||
// public Personne findById(int id) {
|
||||
// return personneRepository.getById(id);
|
||||
// }
|
||||
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package fr.cardon.simpleat.controller;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import fr.cardon.simpleat.model.Preference;
|
||||
import fr.cardon.simpleat.model.PreferencePK;
|
||||
import fr.cardon.simpleat.repository.PersonneRepository;
|
||||
import fr.cardon.simpleat.repository.PreferenceRepository;
|
||||
import fr.cardon.simpleat.repository.RestaurantRepository;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin("*")
|
||||
public class PreferenceController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private PreferenceRepository preferenceRepository;
|
||||
|
||||
@Autowired
|
||||
private PersonneRepository personneRepository;
|
||||
|
||||
@Autowired
|
||||
private RestaurantRepository restaurantRepository;
|
||||
|
||||
@GetMapping("/preferences")
|
||||
public Collection<Preference> findAll(){
|
||||
|
||||
return preferenceRepository.findAll();
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/preference/{iduser}/{idrestau}")
|
||||
public Optional<Preference> findPreferenceById(@PathVariable int iduser, @PathVariable int idrestau ){
|
||||
PreferencePK id = new PreferencePK(personneRepository.getById(iduser) ,restaurantRepository.getById(idrestau));
|
||||
System.out.println(iduser);
|
||||
return preferenceRepository.findById(id);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/add-preference")
|
||||
public ResponseEntity<?> ajoutPreference(@RequestBody Preference preference){
|
||||
return ResponseEntity.status(HttpStatus.OK).body(preferenceRepository.save(preference));
|
||||
}
|
||||
|
||||
|
||||
// @PutMapping(value = "/update-restaurant/{id}")
|
||||
// public ResponseEntity<?> modifPerso(@PathVariable int id, @RequestBody Restaurant personne){
|
||||
// return ResponseEntity.status(HttpStatus.OK).body(preferenceRepository.save(personne));
|
||||
// }
|
||||
//
|
||||
// @DeleteMapping(value = "/delete-restaurant/{id}")
|
||||
// public void suppressionPerso(@PathVariable int id){
|
||||
//
|
||||
// preferenceRepository.deleteById(id);
|
||||
// }
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package fr.cardon.simpleat.controller;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import fr.cardon.simpleat.model.Restaurant;
|
||||
import fr.cardon.simpleat.repository.RestaurantRepository;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin("*")
|
||||
public class RestaurantController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private RestaurantRepository restaurantRepository;
|
||||
|
||||
@GetMapping("/restaurants")
|
||||
public Collection<Restaurant> findAll(){
|
||||
|
||||
return restaurantRepository.findAll();
|
||||
}
|
||||
|
||||
@GetMapping("/restaurant/{id}")
|
||||
public Restaurant findRestaurantById(@PathVariable int id){
|
||||
return restaurantRepository.findById(id);
|
||||
}
|
||||
|
||||
@PostMapping("/add-restaurant")
|
||||
public ResponseEntity<?> ajoutRestaurant(@RequestBody Restaurant personne){
|
||||
return ResponseEntity.status(HttpStatus.OK).body(restaurantRepository.save(personne));
|
||||
}
|
||||
|
||||
|
||||
@PutMapping(value = "/update-restaurant/{id}")
|
||||
public ResponseEntity<?> modifRestaurant(@PathVariable int id, @RequestBody Restaurant personne){
|
||||
return ResponseEntity.status(HttpStatus.OK).body(restaurantRepository.save(personne));
|
||||
}
|
||||
|
||||
@DeleteMapping(value = "/delete-restaurant/{id}")
|
||||
public void suppressionRestaurant(@PathVariable int id){
|
||||
|
||||
restaurantRepository.deleteById(id);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package fr.cardon.simpleat.controller;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import fr.cardon.simpleat.model.TypeRestau;
|
||||
import fr.cardon.simpleat.repository.TypeRestauRepository;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin("*")
|
||||
public class TypeRestauController {
|
||||
|
||||
@Autowired
|
||||
private TypeRestauRepository typeRestauRepository;
|
||||
|
||||
@GetMapping("/types")
|
||||
public Collection<TypeRestau> findAll(){
|
||||
|
||||
return typeRestauRepository.findAll();
|
||||
}
|
||||
|
||||
@GetMapping("/type/{id}")
|
||||
public TypeRestau findTypetById(@PathVariable int id){
|
||||
return typeRestauRepository.findById(id);
|
||||
}
|
||||
|
||||
@PostMapping("/add-type")
|
||||
public ResponseEntity<?> ajoutType(@RequestBody TypeRestau type){
|
||||
return ResponseEntity.status(HttpStatus.OK).body(typeRestauRepository.save(type));
|
||||
}
|
||||
|
||||
|
||||
@PutMapping(value = "/update-type/{id}")
|
||||
public ResponseEntity<?> modifType(@PathVariable int id, @RequestBody TypeRestau type){
|
||||
return ResponseEntity.status(HttpStatus.OK).body(typeRestauRepository.save(type));
|
||||
}
|
||||
|
||||
@DeleteMapping(value = "/delete-type/{id}")
|
||||
public void suppressionType(@PathVariable int id){
|
||||
|
||||
typeRestauRepository.deleteById(id);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,110 @@
|
|||
package fr.cardon.simpleat.model;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.ManyToMany;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
@Entity
|
||||
public class Personne {
|
||||
|
||||
private int id;
|
||||
private String nom;
|
||||
private String prenom;
|
||||
private String email;
|
||||
private String password;
|
||||
private Collection<Role> roles = new ArrayList<Role>();
|
||||
|
||||
|
||||
public Personne() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
|
||||
public Personne(String nom, String prenom, String email, String password) {
|
||||
super();
|
||||
this.nom = nom;
|
||||
this.prenom = prenom;
|
||||
this.email = email;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public Personne(String nom, String prenom, String email, String password, Collection<Role> roles) {
|
||||
super();
|
||||
this.nom = nom;
|
||||
this.prenom = prenom;
|
||||
this.email = email;
|
||||
this.password = password;
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id_personne")
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Column(nullable = false)
|
||||
public String getNom() {
|
||||
return nom;
|
||||
}
|
||||
public void setNom(String nom) {
|
||||
this.nom = nom;
|
||||
}
|
||||
|
||||
@Column(nullable = false)
|
||||
public String getPrenom() {
|
||||
return prenom;
|
||||
}
|
||||
public void setPrenom(String prenom) {
|
||||
this.prenom = prenom;
|
||||
}
|
||||
|
||||
@Column(nullable = false)
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
@Column(nullable = false)
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
@ManyToMany
|
||||
@JoinTable(name="role_personne",
|
||||
joinColumns = @JoinColumn(name = "id_perso"/*nom créé dans table asso*/,referencedColumnName = "id_personne" /*classe en cours*/) )
|
||||
@JsonIgnoreProperties("roles")
|
||||
public Collection<Role> getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
|
||||
public void setRoles(Collection<Role> roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package fr.cardon.simpleat.model;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.EmbeddedId;
|
||||
import javax.persistence.Entity;
|
||||
|
||||
@Entity
|
||||
public class Preference {
|
||||
|
||||
private PreferencePK preferencePK;
|
||||
private int note;
|
||||
private boolean favoris;
|
||||
|
||||
|
||||
|
||||
public Preference() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
|
||||
public Preference(PreferencePK preferencePK, int note, boolean favoris) {
|
||||
super();
|
||||
this.preferencePK = preferencePK;
|
||||
this.note = note;
|
||||
this.favoris = favoris;
|
||||
}
|
||||
|
||||
|
||||
@EmbeddedId
|
||||
public PreferencePK getPreferencePK() {
|
||||
return preferencePK;
|
||||
}
|
||||
public void setPreferencePK(PreferencePK preferencePK) {
|
||||
this.preferencePK = preferencePK;
|
||||
}
|
||||
@Column(nullable = true)
|
||||
public int getNote() {
|
||||
return note;
|
||||
}
|
||||
public void setNote(int note) {
|
||||
this.note = note;
|
||||
}
|
||||
@Column(nullable = true)
|
||||
public boolean isFavori() {
|
||||
return favoris;
|
||||
}
|
||||
public void setFavori(boolean favoris) {
|
||||
this.favoris = favoris;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package fr.cardon.simpleat.model;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
|
||||
@Embeddable
|
||||
public class PreferencePK implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Personne personne;
|
||||
private Restaurant restau;
|
||||
|
||||
|
||||
public PreferencePK() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
|
||||
public PreferencePK(Personne personne, Restaurant restau) {
|
||||
super();
|
||||
this.personne = personne;
|
||||
this.restau = restau;
|
||||
}
|
||||
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name="id_personne", referencedColumnName ="id_personne" )
|
||||
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
|
||||
public Personne getPersonne() {
|
||||
return personne;
|
||||
}
|
||||
|
||||
|
||||
public void setPersonne(Personne personne) {
|
||||
this.personne = personne;
|
||||
}
|
||||
|
||||
|
||||
@ManyToOne // TODO mappedBy preferences dans restaurant
|
||||
@JoinColumn(name="id_restau",referencedColumnName ="id_restau" )
|
||||
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
|
||||
public Restaurant getRestau() {
|
||||
return restau;
|
||||
}
|
||||
|
||||
|
||||
public void setRestau(Restaurant restau) {
|
||||
this.restau = restau;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package fr.cardon.simpleat.model;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.EmbeddedId;
|
||||
import javax.persistence.Entity;
|
||||
|
||||
@Entity
|
||||
public class Reservation {
|
||||
|
||||
|
||||
private ReservationPK reservationpk;
|
||||
private int nbPersonne;
|
||||
|
||||
public Reservation() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
public Reservation(ReservationPK reservationpk, int nbPersonne) {
|
||||
super();
|
||||
this.reservationpk = reservationpk;
|
||||
this.nbPersonne = nbPersonne;
|
||||
}
|
||||
@EmbeddedId
|
||||
public ReservationPK getReservationpk() {
|
||||
return reservationpk;
|
||||
}
|
||||
public void setReservationpk(ReservationPK reservationpk) {
|
||||
this.reservationpk = reservationpk;
|
||||
}
|
||||
@Column(nullable = false)
|
||||
public int getNbPersonne() {
|
||||
return nbPersonne;
|
||||
}
|
||||
public void setNbPersonne(int nbPersonne) {
|
||||
this.nbPersonne = nbPersonne;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package fr.cardon.simpleat.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
|
||||
|
||||
@Embeddable
|
||||
public class ReservationPK implements Serializable{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Personne personne;
|
||||
private Restaurant restau;
|
||||
private Date date;
|
||||
|
||||
|
||||
public ReservationPK() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
public ReservationPK(Personne personne, Restaurant restau, Date date) {
|
||||
super();
|
||||
this.personne = personne;
|
||||
this.restau = restau;
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name="id_personne", referencedColumnName ="id_personne" )
|
||||
public Personne getPersonne() {
|
||||
return personne;
|
||||
}
|
||||
public void setPersonne(Personne personne) {
|
||||
this.personne = personne;
|
||||
}
|
||||
@ManyToOne
|
||||
@JoinColumn(name="id_restau",referencedColumnName ="id_restau" )
|
||||
public Restaurant getRestau() {
|
||||
return restau;
|
||||
}
|
||||
public void setRestau(Restaurant restau) {
|
||||
this.restau = restau;
|
||||
}
|
||||
@Column(name="date_resa")
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,154 @@
|
|||
package fr.cardon.simpleat.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.ManyToMany;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
|
||||
@Entity
|
||||
public class Restaurant {
|
||||
|
||||
private int id;
|
||||
private String nom;
|
||||
private String adresse;
|
||||
private String telephone;
|
||||
private boolean aEmporter;
|
||||
private boolean surPlace;
|
||||
private double prix;
|
||||
private boolean accesPMR;
|
||||
private String latitude;
|
||||
private String longitude;
|
||||
private String website;
|
||||
private Collection<TypeRestau> typerestaus = new ArrayList<TypeRestau>();
|
||||
|
||||
//TODO @OneToMany relier avec une collec de preferences
|
||||
|
||||
public Restaurant() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
|
||||
public Restaurant(String nom, String adresse, String telephone, boolean aEmporter, boolean surPlace, double prix,
|
||||
boolean accesPMR, String latitude, String longitude, String website, Collection<TypeRestau> typerestaus) {
|
||||
super();
|
||||
this.nom = nom;
|
||||
this.adresse = adresse;
|
||||
this.telephone = telephone;
|
||||
this.aEmporter = aEmporter;
|
||||
this.surPlace = surPlace;
|
||||
this.prix = prix;
|
||||
this.accesPMR = accesPMR;
|
||||
this.latitude = latitude;
|
||||
this.longitude = longitude;
|
||||
this.website = website;
|
||||
this.typerestaus = typerestaus;
|
||||
}
|
||||
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id_restau")
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Column(nullable = false)
|
||||
public String getNom() {
|
||||
return nom;
|
||||
}
|
||||
public void setNom(String nom) {
|
||||
this.nom = nom;
|
||||
}
|
||||
@Column(nullable = false)
|
||||
public String getAdresse() {
|
||||
return adresse;
|
||||
}
|
||||
public void setAdresse(String adresse) {
|
||||
this.adresse = adresse;
|
||||
}
|
||||
@Column(nullable = true)
|
||||
public String getTelephone() {
|
||||
return telephone;
|
||||
}
|
||||
public void setTelephone(String telephone) {
|
||||
this.telephone = telephone;
|
||||
}
|
||||
@Column(nullable = true)
|
||||
public boolean isaEmporter() {
|
||||
return aEmporter;
|
||||
}
|
||||
public void setaEmporter(boolean aEmporter) {
|
||||
this.aEmporter = aEmporter;
|
||||
}
|
||||
@Column(nullable = true)
|
||||
public boolean isSurPlace() {
|
||||
return surPlace;
|
||||
}
|
||||
public void setSurPlace(boolean surPlace) {
|
||||
this.surPlace = surPlace;
|
||||
}
|
||||
@Column(nullable = true)
|
||||
public double getPrix() {
|
||||
return prix;
|
||||
}
|
||||
public void setPrix(double prixMin) {
|
||||
this.prix = prixMin;
|
||||
}
|
||||
@Column(nullable = true)
|
||||
public boolean isAccesPMR() {
|
||||
return accesPMR;
|
||||
}
|
||||
public void setAccesPMR(boolean accesPMR) {
|
||||
this.accesPMR = accesPMR;
|
||||
}
|
||||
@Column(nullable = false)
|
||||
public String getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
public void setLatitude(String latitude) {
|
||||
this.latitude = latitude;
|
||||
}
|
||||
@Column(nullable = false)
|
||||
public String getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
public void setLongitude(String longitude) {
|
||||
this.longitude = longitude;
|
||||
}
|
||||
@Column(nullable = true)
|
||||
public String getWebsite() {
|
||||
return website;
|
||||
}
|
||||
public void setWebsite(String website) {
|
||||
this.website = website;
|
||||
}
|
||||
|
||||
@ManyToMany
|
||||
@JoinTable(name="type_restau",
|
||||
joinColumns = @JoinColumn(name = "id_restau"/*classe en cours*/,referencedColumnName = "id_restau" /*classe reliée*/) ,
|
||||
inverseJoinColumns = @JoinColumn(name = "id_type",referencedColumnName = "id_type"))
|
||||
@JsonIgnoreProperties("typerestaus")
|
||||
public Collection<TypeRestau> getTyperestaus() {
|
||||
return typerestaus;
|
||||
}
|
||||
|
||||
public void setTyperestaus(Collection<TypeRestau> typerestaus) {
|
||||
this.typerestaus = typerestaus;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package fr.cardon.simpleat.model;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
||||
@Entity
|
||||
public class Role {
|
||||
|
||||
private int id;
|
||||
private String intitule;
|
||||
|
||||
|
||||
public Role() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public Role(int id, String intitule) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.intitule = intitule;
|
||||
}
|
||||
|
||||
@Id
|
||||
@Column(name = "id_role")
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
@Column(nullable = false)
|
||||
public String getIntitule() {
|
||||
return intitule;
|
||||
}
|
||||
public void setIntitule(String intitule) {
|
||||
this.intitule = intitule;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package fr.cardon.simpleat.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name="type")
|
||||
public class TypeRestau {
|
||||
|
||||
private int id;
|
||||
private String libelle;
|
||||
private List<Restaurant> restaurants;
|
||||
|
||||
public TypeRestau() {
|
||||
super();
|
||||
}
|
||||
|
||||
public TypeRestau(int id, String libelle) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.libelle = libelle;
|
||||
}
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id_type")
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
@Column(nullable = false)
|
||||
public String getLibelle() {
|
||||
return libelle;
|
||||
}
|
||||
public void setLibelle(String libelle) {
|
||||
this.libelle = libelle;
|
||||
}
|
||||
|
||||
@ManyToMany(mappedBy="typerestaus")
|
||||
@JsonIgnoreProperties("typerestaus")
|
||||
public List<Restaurant> getRestaurants() {
|
||||
return restaurants;
|
||||
}
|
||||
|
||||
public void setRestaurants(List<Restaurant> restaurants) {
|
||||
this.restaurants = restaurants;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package fr.cardon.simpleat.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import fr.cardon.simpleat.model.Personne;
|
||||
|
||||
@Repository
|
||||
public interface PersonneRepository extends JpaRepository<Personne, Integer> {
|
||||
|
||||
Personne findById(int id);
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package fr.cardon.simpleat.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import fr.cardon.simpleat.model.Preference;
|
||||
import fr.cardon.simpleat.model.PreferencePK;
|
||||
|
||||
@Repository
|
||||
public interface PreferenceRepository extends JpaRepository<Preference, PreferencePK> {
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package fr.cardon.simpleat.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import fr.cardon.simpleat.model.Reservation;
|
||||
import fr.cardon.simpleat.model.ReservationPK;
|
||||
|
||||
@Repository
|
||||
public interface ReservationRepository extends JpaRepository<Reservation, ReservationPK> {
|
||||
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package fr.cardon.simpleat.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import fr.cardon.simpleat.model.Restaurant;
|
||||
|
||||
@Repository
|
||||
public interface RestaurantRepository extends JpaRepository<Restaurant, Integer> {
|
||||
|
||||
Restaurant findById(int id);
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package fr.cardon.simpleat.repository;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import fr.cardon.simpleat.model.Role;
|
||||
|
||||
@Repository
|
||||
public interface RoleRepository extends JpaRepository<Role, Integer> {
|
||||
|
||||
|
||||
Collection<Role> findCollectionById(int id);
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package fr.cardon.simpleat.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import fr.cardon.simpleat.model.TypeRestau;
|
||||
|
||||
@Repository
|
||||
public interface TypeRestauRepository extends JpaRepository<TypeRestau, Integer> {
|
||||
|
||||
|
||||
TypeRestau findById(int id);
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
# ===============================
|
||||
# base de données MySQL
|
||||
# ===============================
|
||||
spring.datasource.url=jdbc:mysql://localhost:3308/simpleat?useSSL=false&zeroDateTimeBehavior=CONVERT_TO_NULL&serverTimezone=CET
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=root
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
# log
|
||||
#logging.level.root=INFO
|
||||
#logging.file=d:/data/log-hibernate-jpa.log
|
||||
#logging.level.org.springframework.jdbc.core.JdbcTemplate=debug
|
||||
# ===============================
|
||||
# JPA / HIBERNATE
|
||||
# ===============================
|
||||
spring.jpa.show-sql=true
|
||||
spring.jpa.hibernate.ddl-auto=update
|
||||
##spring.jpa.hibernate.ddl-auto=create-drop
|
||||
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect
|
||||
# ===============================
|
||||
# Permet d'exécuter le data.sql
|
||||
# ===============================
|
||||
##spring.sql.init.mode=always
|
|
@ -0,0 +1,64 @@
|
|||
|
||||
insert into personne (nom, prenom, email, password) values ('Harmond', 'Ludvig', 'lharmond0@moonfruit.com', 'pjKxIN');
|
||||
insert into personne (nom, prenom, email, password) values ('Fisbey', 'Jammal', 'jfisbey1@apache.org', 'YY0TuY6JH0di');
|
||||
insert into personne (nom, prenom, email, password) values ('Scrivener', 'Anatol', 'ascrivener2@jugem.jp', 'C4sfAW4');
|
||||
insert into personne (nom, prenom, email, password) values ('Berthelet', 'Oralla', 'oberthelet3@cnbc.com', 'ACdXxMr');
|
||||
insert into personne (nom, prenom, email, password) values ('Towe', 'Homerus', 'htowe4@home.pl', 'pQGi41q5JHY');
|
||||
insert into personne (nom, prenom, email, password) values ('Viggers', 'Gaby', 'gviggers5@xing.com', 'Gbr2M5UU');
|
||||
insert into personne (nom, prenom, email, password) values ('Willshere', 'Sheba', 'swillshere6@tinyurl.com', 'yVJmjda');
|
||||
insert into personne (nom, prenom, email, password) values ('Docksey', 'Eula', 'edocksey7@mozilla.com', '6yS7lkFpuY');
|
||||
insert into personne (nom, prenom, email, password) values ('Iglesias', 'Christen', 'ciglesias8@ebay.com', 'ottn7Qb');
|
||||
insert into personne (nom, prenom, email, password) values ('Crick', 'Andris', 'acrick9@etsy.com', 'nkmUVBeKr');
|
||||
|
||||
insert into role (id_role, intitule) values (1, 'Admin');
|
||||
insert into role (id_role, intitule) values (2, 'User');
|
||||
|
||||
insert into restaurant (nom, adresse, telephone, a_emporter, sur_place, prix_min, prix_max, accespmr, latitude, longitude) values ('L Perrigo Company', '301 Thierer Trail', '3092096786', false, true, 10, 16, false, '2.1961772', '22.4708685');
|
||||
insert into restaurant (nom, adresse, telephone, a_emporter, sur_place, prix_min, prix_max, accespmr, latitude, longitude) values ('Sanofi Pasteur Inc.', '9 Barnett Terrace', '6809964349', false, true, 1, 17, false, '31.45571', '34.43719');
|
||||
insert into restaurant (nom, adresse, telephone, a_emporter, sur_place, prix_min, prix_max, accespmr, latitude, longitude) values ('REMEDYREPACK INC.', '3 West Park', '4565542193', true, false, 2, 20, true, '49.817777', '19.785536');
|
||||
insert into restaurant (nom, adresse, telephone, a_emporter, sur_place, prix_min, prix_max, accespmr, latitude, longitude) values ('Physicians Total Care, Inc.', '462 Mosinee Lane', '8521719889', false, false, 1, 22, true, '-13.5', '48.86667');
|
||||
insert into restaurant (nom, adresse, telephone, a_emporter, sur_place, prix_min, prix_max, accespmr, latitude, longitude) values ('Triweld Industries, Inc.', '2482 Corscot Way', '7513208452', false, true, 5, 13, true, '34.326903', '108.117456');
|
||||
|
||||
insert into preference (id_restau, id_personne, note, favori) values (2, 9, 1, false);
|
||||
insert into preference (id_restau, id_personne, note, favori) values (3, 1, 5, false);
|
||||
insert into preference (id_restau, id_personne, note, favori) values (1, 9, 3, true);
|
||||
insert into preference (id_restau, id_personne, note, favori) values (4, 6, 2, false);
|
||||
insert into preference (id_restau, id_personne, note, favori) values (5, 5, 5, false);
|
||||
insert into preference (id_restau, id_personne, note, favori) values (1, 10, 1, false);
|
||||
insert into preference (id_restau, id_personne, note, favori) values (5, 3, 5, false);
|
||||
insert into preference (id_restau, id_personne, note, favori) values (1, 7, 1, true);
|
||||
insert into preference (id_restau, id_personne, note, favori) values (4, 2, 1, false);
|
||||
insert into preference (id_restau, id_personne, note, favori) values (1, 3, 5, false);
|
||||
insert into preference (id_restau, id_personne, note, favori) values (3, 10, 4, false);
|
||||
insert into preference (id_restau, id_personne, note, favori) values (3, 3, 4, true);
|
||||
insert into preference (id_restau, id_personne, note, favori) values (2, 3, 3, false);
|
||||
insert into preference (id_restau, id_personne, note, favori) values (2, 8, 3, false);
|
||||
|
||||
insert into type (id_type, libelle) values (1, 'Kebab');
|
||||
insert into type (id_type, libelle) values (2, 'Supermarché');
|
||||
insert into type (id_type, libelle) values (3, 'Boulangerie');
|
||||
insert into type (id_type, libelle) values (4, 'Thaï');
|
||||
insert into type (id_type, libelle) values (5, 'Français');
|
||||
insert into type (id_type, libelle) values (6, 'Pizza');
|
||||
insert into type (id_type, libelle) values (7, 'Brasserie');
|
||||
insert into type (id_type, libelle) values (8, 'Americain');
|
||||
insert into type (id_type, libelle) values (9, 'Japonais');
|
||||
insert into type (id_type, libelle) values (10, 'Asiatique');
|
||||
insert into type (id_type, libelle) values (11, 'Italien');
|
||||
insert into type (id_type, libelle) values (12, 'Sushis');
|
||||
insert into type (id_type, libelle) values (13, 'Chinois');
|
||||
insert into type (id_type, libelle) values (14, 'Crêperie');
|
||||
insert into type (id_type, libelle) values (15, 'Hamburger');
|
||||
insert into type (id_type, libelle) values (16, 'Indien');
|
||||
insert into type (id_type, libelle) values (17, 'Marocain');
|
||||
insert into type (id_type, libelle) values (18, 'Fruits de Mer');
|
||||
insert into type (id_type, libelle) values (19, 'Steack');
|
||||
insert into type (id_type, libelle) values (20, 'Vietnamien');
|
||||
|
||||
|
||||
insert into type_restau (id_restau, id_type) values (1, 3);
|
||||
insert into type_restau (id_restau, id_type) values (2, 1);
|
||||
insert into type_restau (id_restau, id_type) values (3, 1);
|
||||
insert into type_restau (id_restau, id_type) values (4, 2);
|
||||
insert into type_restau (id_restau, id_type) values (5, 4);
|
||||
insert into type_restau (id_restau, id_type) values (1, 2);
|
|
@ -0,0 +1,13 @@
|
|||
package fr.cardon.simpleat;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class SimpleatApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue