atteindre Preferences dans Personne

This commit is contained in:
Thomas Cardon 2022-03-02 14:05:02 +01:00
parent 820aabcaa1
commit 656899ea4c
5 changed files with 9 additions and 5 deletions

View File

@ -75,7 +75,7 @@ public class PersonneController {
}
@GetMapping("/user/{id}")
@PreAuthorize("hasRole('ROLE_ADMIN')")
//@PreAuthorize("hasRole('ROLE_ADMIN')")
public Personne findPersonneById(@PathVariable int id){
return personneRepository.findById(id);
@ -113,7 +113,7 @@ public class PersonneController {
return roleRepository.findCollectionById(idRole);
}
@PostMapping("/sign-in")
@PostMapping("/signin")
public ResponseEntity<JsonWebToken> signIn(@RequestBody Personne personne) {
try {
// ici on créé un JWT en passant l'email et le mot de passe

View File

@ -38,7 +38,7 @@ public class RestaurantController {
}
@PostMapping("/add-restaurant")
@PreAuthorize("hasRole('ROLE_ADMIN')")
//@PreAuthorize("hasRole('ROLE_ADMIN')")
public ResponseEntity<?> ajoutRestaurant(@RequestBody Restaurant personne){
return ResponseEntity.status(HttpStatus.OK).body(restaurantRepository.save(personne));
}

View File

@ -148,7 +148,7 @@ public Personne(String email, String password, List<EnumRole> roleList) {
@OneToMany(mappedBy = "preferencePK.personne", cascade = CascadeType.REMOVE)
@JsonIgnore
//@JsonIgnore
public Collection<Preference> getPreference() {
return preference;
}

View File

@ -10,6 +10,7 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@ -39,7 +40,7 @@ public class PreferencePK implements Serializable {
@ManyToOne
@PrimaryKeyJoinColumn(name="id_personne", referencedColumnName ="id_personne" )
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
@JsonIgnore
public Personne getPersonne() {
return personne;
}

View File

@ -12,6 +12,7 @@ insert into personne (nom, prenom, email, password) values ('Rinquin', 'Aline',
insert into personne (nom, prenom, email, password) values ('Keddar', 'Noreddine', 'noredinne.keddar@gmail.com', 'ACdXxMr');
insert into personne (nom, prenom, email, password) values ('Tomczyk', 'Julian', 'julian.tomczyk@gmail.com', 'pjKxIN');
insert into personne (nom, prenom, email, password) values ('MJID', 'Hedi', 'hedi.mjid@gmail.com', 'YY0TuY6JH0di');
insert into personne (nom, prenom, email, password) values ('BIDEN', 'Joe', 'joe@biden.fr', '$2a$10$NNfAnATNZf/MzIjrUFi5K.xqWizxv1Hil4/PyRAabKWK5DxsLPE6.');
insert into role (id_role, intitule) values (1, 'Admin');
insert into role (id_role, intitule) values (2, 'User');
@ -75,6 +76,8 @@ insert into preference (restau_id_restau, personne_id_personne, note, favori) va
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, 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é');