Compare commits

...

1 Commits
main ... thomas

Author SHA1 Message Date
Thomas Cardon daf75e53d7 modif preference 2022-03-22 17:19:47 +01:00
3 changed files with 21 additions and 15 deletions

View File

@ -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)));
//System.out.println("hello");
Preference preference = new Preference(new PreferencePK(personneRepository.getById(iduser) ,restaurantRepository.getById(idrestau)),true);
return ResponseEntity.status(HttpStatus.OK).body(preferenceRepository.save(preference));
}

View File

@ -26,6 +26,12 @@ 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;

View File

@ -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, 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 (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 (1, 9, 3, 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 (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 (1, 7, 1, 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 (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 (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 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 type (id_type, libelle) values (1, 'Kebab');
insert into type (id_type, libelle) values (2, 'Supermarché');