Compare commits
2 Commits
Author | SHA1 | Date |
---|---|---|
VincentRamiere | d69fb2a5c2 | |
Your Name | 254517f379 |
|
@ -1 +1 @@
|
|||
rootProject.name = 'simpleat'
|
||||
rootProject.name = 'simpleat-back'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package fr.cardon.simpleat;
|
||||
package fr.vincentRamiere.simpleatBack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -8,10 +8,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
|
||||
import fr.cardon.simpleat.exception.ExistingUsernameException;
|
||||
import fr.cardon.simpleat.model.EnumRole;
|
||||
import fr.cardon.simpleat.model.Personne;
|
||||
import fr.cardon.simpleat.service.PersonneService;
|
||||
import fr.vincentRamiere.simpleatBack.exception.ExistingUsernameException;
|
||||
import fr.vincentRamiere.simpleatBack.model.EnumRole;
|
||||
import fr.vincentRamiere.simpleatBack.model.Personne;
|
||||
import fr.vincentRamiere.simpleatBack.service.PersonneService;
|
||||
|
||||
@SpringBootApplication
|
||||
public class SimpleatApplication {
|
|
@ -1,4 +1,4 @@
|
|||
package fr.cardon.simpleat.controller;
|
||||
package fr.vincentRamiere.simpleatBack.controller;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
|
@ -17,12 +17,12 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import fr.cardon.simpleat.dto.JsonWebToken;
|
||||
import fr.cardon.simpleat.exception.ExistingUsernameException;
|
||||
import fr.cardon.simpleat.exception.InvalidCredentialsException;
|
||||
import fr.cardon.simpleat.model.Personne;
|
||||
import fr.cardon.simpleat.repository.PersonneRepository;
|
||||
import fr.cardon.simpleat.service.PersonneService;
|
||||
import fr.vincentRamiere.simpleatBack.dto.JsonWebToken;
|
||||
import fr.vincentRamiere.simpleatBack.exception.ExistingUsernameException;
|
||||
import fr.vincentRamiere.simpleatBack.exception.InvalidCredentialsException;
|
||||
import fr.vincentRamiere.simpleatBack.model.Personne;
|
||||
import fr.vincentRamiere.simpleatBack.repository.PersonneRepository;
|
||||
import fr.vincentRamiere.simpleatBack.service.PersonneService;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin("http://localhost:4200")
|
|
@ -1,4 +1,4 @@
|
|||
package fr.cardon.simpleat.controller;
|
||||
package fr.vincentRamiere.simpleatBack.controller;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
|
@ -15,11 +15,11 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||
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;
|
||||
import fr.vincentRamiere.simpleatBack.model.Preference;
|
||||
import fr.vincentRamiere.simpleatBack.model.PreferencePK;
|
||||
import fr.vincentRamiere.simpleatBack.repository.PersonneRepository;
|
||||
import fr.vincentRamiere.simpleatBack.repository.PreferenceRepository;
|
||||
import fr.vincentRamiere.simpleatBack.repository.RestaurantRepository;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin("*")
|
||||
|
@ -61,8 +61,8 @@ public class PreferenceController {
|
|||
@PostMapping("/add-preference/{iduser}/{idrestau}")
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_READER')")
|
||||
public ResponseEntity<?> ajoutPreference(@PathVariable int iduser, @PathVariable int idrestau ){
|
||||
//System.out.println("hello");
|
||||
Preference preference = new Preference(new PreferencePK(personneRepository.getById(iduser) ,restaurantRepository.getById(idrestau)),true);
|
||||
System.out.println("hello");
|
||||
Preference preference = new Preference(new PreferencePK(personneRepository.getById(iduser) ,restaurantRepository.getById(idrestau)));
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(preferenceRepository.save(preference));
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package fr.cardon.simpleat.controller;
|
||||
package fr.vincentRamiere.simpleatBack.controller;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
|
@ -15,8 +15,8 @@ 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;
|
||||
import fr.vincentRamiere.simpleatBack.model.Restaurant;
|
||||
import fr.vincentRamiere.simpleatBack.repository.RestaurantRepository;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin("*")
|
|
@ -1,4 +1,4 @@
|
|||
package fr.cardon.simpleat.controller;
|
||||
package fr.vincentRamiere.simpleatBack.controller;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
|
@ -17,9 +17,9 @@ 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.model.TypeRestau;
|
||||
import fr.cardon.simpleat.repository.TypeRestauRepository;
|
||||
import fr.vincentRamiere.simpleatBack.model.Restaurant;
|
||||
import fr.vincentRamiere.simpleatBack.model.TypeRestau;
|
||||
import fr.vincentRamiere.simpleatBack.repository.TypeRestauRepository;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin("*")
|
|
@ -1,4 +1,4 @@
|
|||
package fr.cardon.simpleat.dto;
|
||||
package fr.vincentRamiere.simpleatBack.dto;
|
||||
|
||||
/**
|
||||
* Classe spécifique DTO (Data Transfer Object) qui retourne un Jeton au format JSON (REST response)
|
|
@ -1,4 +1,4 @@
|
|||
package fr.cardon.simpleat.dto;
|
||||
package fr.vincentRamiere.simpleatBack.dto;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package fr.cardon.simpleat.exception;
|
||||
package fr.vincentRamiere.simpleatBack.exception;
|
||||
|
||||
/**
|
||||
* Classe personnalisée pour gérer un message si l'utilisateur (User) existe en Base de données
|
|
@ -1,4 +1,4 @@
|
|||
package fr.cardon.simpleat.exception;
|
||||
package fr.vincentRamiere.simpleatBack.exception;
|
||||
|
||||
/**
|
||||
* Specific exception that should be thrown when user credentials are not valid.
|
|
@ -1,4 +1,4 @@
|
|||
package fr.cardon.simpleat.exception;
|
||||
package fr.vincentRamiere.simpleatBack.exception;
|
||||
|
||||
/**
|
||||
* Specific exception that should be thrown when a JWT has an invalid format.
|
|
@ -1,4 +1,4 @@
|
|||
package fr.cardon.simpleat.model;
|
||||
package fr.vincentRamiere.simpleatBack.model;
|
||||
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package fr.cardon.simpleat.model;
|
||||
package fr.vincentRamiere.simpleatBack.model;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
|
@ -1,4 +1,4 @@
|
|||
package fr.cardon.simpleat.model;
|
||||
package fr.vincentRamiere.simpleatBack.model;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.EmbeddedId;
|
||||
|
@ -26,12 +26,6 @@ public class Preference {
|
|||
this.preferencePK = preferencePK;
|
||||
}
|
||||
|
||||
public Preference(PreferencePK preferencePK,boolean favoris) {
|
||||
super();
|
||||
this.preferencePK = preferencePK;
|
||||
this.favoris = favoris;
|
||||
}
|
||||
|
||||
public Preference(PreferencePK preferencePK, int note, boolean favoris) {
|
||||
super();
|
||||
this.preferencePK = preferencePK;
|
|
@ -1,4 +1,4 @@
|
|||
package fr.cardon.simpleat.model;
|
||||
package fr.vincentRamiere.simpleatBack.model;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
|
@ -1,4 +1,4 @@
|
|||
package fr.cardon.simpleat.model;
|
||||
package fr.vincentRamiere.simpleatBack.model;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.EmbeddedId;
|
|
@ -1,4 +1,4 @@
|
|||
package fr.cardon.simpleat.model;
|
||||
package fr.vincentRamiere.simpleatBack.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
|
@ -1,4 +1,4 @@
|
|||
package fr.cardon.simpleat.model;
|
||||
package fr.vincentRamiere.simpleatBack.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
|
@ -1,4 +1,4 @@
|
|||
package fr.cardon.simpleat.model;
|
||||
package fr.vincentRamiere.simpleatBack.model;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
package fr.cardon.simpleat.repository;
|
||||
package fr.vincentRamiere.simpleatBack.repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import fr.cardon.simpleat.model.Personne;
|
||||
import fr.vincentRamiere.simpleatBack.model.Personne;
|
||||
|
||||
@Repository
|
||||
public interface PersonneRepository extends JpaRepository<Personne, Integer> {
|
|
@ -1,10 +1,10 @@
|
|||
package fr.cardon.simpleat.repository;
|
||||
package fr.vincentRamiere.simpleatBack.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;
|
||||
import fr.vincentRamiere.simpleatBack.model.Preference;
|
||||
import fr.vincentRamiere.simpleatBack.model.PreferencePK;
|
||||
|
||||
@Repository
|
||||
public interface PreferenceRepository extends JpaRepository<Preference, PreferencePK> {
|
|
@ -1,10 +1,10 @@
|
|||
package fr.cardon.simpleat.repository;
|
||||
package fr.vincentRamiere.simpleatBack.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;
|
||||
import fr.vincentRamiere.simpleatBack.model.Reservation;
|
||||
import fr.vincentRamiere.simpleatBack.model.ReservationPK;
|
||||
|
||||
@Repository
|
||||
public interface ReservationRepository extends JpaRepository<Reservation, ReservationPK> {
|
|
@ -1,9 +1,9 @@
|
|||
package fr.cardon.simpleat.repository;
|
||||
package fr.vincentRamiere.simpleatBack.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import fr.cardon.simpleat.model.Restaurant;
|
||||
import fr.vincentRamiere.simpleatBack.model.Restaurant;
|
||||
|
||||
@Repository
|
||||
public interface RestaurantRepository extends JpaRepository<Restaurant, Integer> {
|
|
@ -1,9 +1,9 @@
|
|||
package fr.cardon.simpleat.repository;
|
||||
package fr.vincentRamiere.simpleatBack.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import fr.cardon.simpleat.model.TypeRestau;
|
||||
import fr.vincentRamiere.simpleatBack.model.TypeRestau;
|
||||
|
||||
@Repository
|
||||
public interface TypeRestauRepository extends JpaRepository<TypeRestau, Integer> {
|
|
@ -1,4 +1,4 @@
|
|||
package fr.cardon.simpleat.security;
|
||||
package fr.vincentRamiere.simpleatBack.security;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -12,7 +12,7 @@ import org.springframework.security.core.Authentication;
|
|||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
|
||||
import fr.cardon.simpleat.exception.InvalidJWTException;
|
||||
import fr.vincentRamiere.simpleatBack.exception.InvalidJWTException;
|
||||
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package fr.cardon.simpleat.security;
|
||||
package fr.vincentRamiere.simpleatBack.security;
|
||||
|
||||
import java.util.Base64;
|
||||
import java.util.Date;
|
||||
|
@ -20,9 +20,9 @@ import org.springframework.stereotype.Component;
|
|||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
||||
import fr.cardon.simpleat.exception.InvalidJWTException;
|
||||
import fr.cardon.simpleat.model.EnumRole;
|
||||
import fr.cardon.simpleat.repository.PersonneRepository;
|
||||
import fr.vincentRamiere.simpleatBack.exception.InvalidJWTException;
|
||||
import fr.vincentRamiere.simpleatBack.model.EnumRole;
|
||||
import fr.vincentRamiere.simpleatBack.repository.PersonneRepository;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import io.jsonwebtoken.JwtException;
|
||||
import io.jsonwebtoken.Jwts;
|
|
@ -1,4 +1,4 @@
|
|||
package fr.cardon.simpleat.security;
|
||||
package fr.vincentRamiere.simpleatBack.security;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
|
@ -1,13 +1,13 @@
|
|||
package fr.cardon.simpleat.service;
|
||||
package fr.vincentRamiere.simpleatBack.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import fr.cardon.simpleat.exception.ExistingUsernameException;
|
||||
import fr.cardon.simpleat.exception.InvalidCredentialsException;
|
||||
import fr.cardon.simpleat.model.Personne;
|
||||
import fr.vincentRamiere.simpleatBack.exception.ExistingUsernameException;
|
||||
import fr.vincentRamiere.simpleatBack.exception.InvalidCredentialsException;
|
||||
import fr.vincentRamiere.simpleatBack.model.Personne;
|
||||
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package fr.cardon.simpleat.service;
|
||||
package fr.vincentRamiere.simpleatBack.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
@ -11,13 +11,11 @@ import org.springframework.security.core.AuthenticationException;
|
|||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
|
||||
import fr.cardon.simpleat.exception.ExistingUsernameException;
|
||||
import fr.cardon.simpleat.exception.InvalidCredentialsException;
|
||||
import fr.cardon.simpleat.model.Personne;
|
||||
import fr.cardon.simpleat.repository.PersonneRepository;
|
||||
import fr.cardon.simpleat.security.JwtTokenProvider;
|
||||
import fr.vincentRamiere.simpleatBack.exception.ExistingUsernameException;
|
||||
import fr.vincentRamiere.simpleatBack.exception.InvalidCredentialsException;
|
||||
import fr.vincentRamiere.simpleatBack.model.Personne;
|
||||
import fr.vincentRamiere.simpleatBack.repository.PersonneRepository;
|
||||
import fr.vincentRamiere.simpleatBack.security.JwtTokenProvider;
|
||||
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package fr.cardon.simpleat.service;
|
||||
package fr.vincentRamiere.simpleatBack.service;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
@ -10,9 +10,8 @@ import org.springframework.security.core.userdetails.UserDetailsService;
|
|||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import fr.cardon.simpleat.model.Personne;
|
||||
|
||||
import fr.cardon.simpleat.repository.PersonneRepository;
|
||||
import fr.vincentRamiere.simpleatBack.model.Personne;
|
||||
import fr.vincentRamiere.simpleatBack.repository.PersonneRepository;
|
||||
|
||||
|
||||
@Service
|
|
@ -6,9 +6,9 @@ spring.main.allow-circular-references=true
|
|||
# ===============================
|
||||
# base de données MySQL
|
||||
# ===============================
|
||||
spring.datasource.url=jdbc:mysql://localhost:3308/simpleat?useSSL=false&zeroDateTimeBehavior=CONVERT_TO_NULL&serverTimezone=CET
|
||||
spring.datasource.url=jdbc:mysql://localhost:3306/simpleat?useSSL=false&zeroDateTimeBehavior=CONVERT_TO_NULL&serverTimezone=CET
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=root
|
||||
spring.datasource.password=bbLouis1+Noe2
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
# log
|
||||
#logging.level.root=INFO
|
||||
|
@ -19,10 +19,11 @@ spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
|||
# ===============================
|
||||
spring.jpa.show-sql=true
|
||||
##spring.jpa.hibernate.ddl-auto=update
|
||||
spring.jpa.hibernate.ddl-auto=create-drop
|
||||
spring.jpa.hibernate.ddl-auto=none
|
||||
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect
|
||||
# ===============================
|
||||
# Permet d'exécuter le data.sql
|
||||
# ===============================
|
||||
spring.sql.init.mode=always
|
||||
spring.jpa.defer-datasource-initialization=true
|
||||
# spring.sql.init.mode=always
|
||||
spring.jpa.defer-datasource-initialization=true
|
||||
server.port=8081
|
|
@ -88,22 +88,22 @@ INSERT INTO restaurant (`a_emporter`,`accespmr`,`adresse`,`latitude`,`longitude`
|
|||
|
||||
|
||||
|
||||
insert into preference (restau_id_restau, personne_id_personne, note, favori) values (2, 9, 1, true);
|
||||
insert into preference (restau_id_restau, personne_id_personne, note, favori) values (3, 1, 5, true);
|
||||
insert into preference (restau_id_restau, personne_id_personne, note, favori) values (2, 9, 1, false);
|
||||
insert into preference (restau_id_restau, personne_id_personne, note, favori) values (3, 1, 5, false);
|
||||
insert into preference (restau_id_restau, personne_id_personne, note, favori) values (1, 9, 3, true);
|
||||
insert into preference (restau_id_restau, personne_id_personne, note, favori) values (4, 6, 2, true);
|
||||
insert into preference (restau_id_restau, personne_id_personne, note, favori) values (5, 5, 5, true);
|
||||
insert into preference (restau_id_restau, personne_id_personne, note, favori) values (1, 10, 1, true);
|
||||
insert into preference (restau_id_restau, personne_id_personne, note, favori) values (5, 3, 5, true);
|
||||
insert into preference (restau_id_restau, personne_id_personne, note, favori) values (4, 6, 2, false);
|
||||
insert into preference (restau_id_restau, personne_id_personne, note, favori) values (5, 5, 5, false);
|
||||
insert into preference (restau_id_restau, personne_id_personne, note, favori) values (1, 10, 1, false);
|
||||
insert into preference (restau_id_restau, personne_id_personne, note, favori) values (5, 3, 5, false);
|
||||
insert into preference (restau_id_restau, personne_id_personne, note, favori) values (1, 7, 1, true);
|
||||
insert into preference (restau_id_restau, personne_id_personne, note, favori) values (4, 2, 1, true);
|
||||
insert into preference (restau_id_restau, personne_id_personne, note, favori) values (1, 3, 5, true);
|
||||
insert into preference (restau_id_restau, personne_id_personne, note, favori) values (3, 10, 4, true);
|
||||
insert into preference (restau_id_restau, personne_id_personne, note, favori) values (4, 2, 1, false);
|
||||
insert into preference (restau_id_restau, personne_id_personne, note, favori) values (1, 3, 5, false);
|
||||
insert into preference (restau_id_restau, personne_id_personne, note, favori) values (3, 10, 4, false);
|
||||
insert into preference (restau_id_restau, personne_id_personne, note, favori) values (3, 3, 4, true);
|
||||
insert into preference (restau_id_restau, personne_id_personne, note, favori) values (2, 3, 3, true);
|
||||
insert into preference (restau_id_restau, personne_id_personne, note, favori) values (2, 8, 3, true);
|
||||
insert into preference (restau_id_restau, personne_id_personne, note, favori) values (5, 15, 3, true);
|
||||
insert into preference (restau_id_restau, personne_id_personne, note, favori) values (8, 15, 3, true);
|
||||
insert into preference (restau_id_restau, personne_id_personne, note, favori) values (2, 3, 3, false);
|
||||
insert into preference (restau_id_restau, personne_id_personne, note, favori) values (2, 8, 3, false);
|
||||
insert into preference (restau_id_restau, personne_id_personne, note, favori) values (5, 15, 3, false);
|
||||
insert into preference (restau_id_restau, personne_id_personne, note, favori) values (8, 15, 3, false);
|
||||
|
||||
insert into type (id_type, libelle) values (1, 'Kebab');
|
||||
insert into type (id_type, libelle) values (2, 'Supermarché');
|
||||
|
|
Loading…
Reference in New Issue