modif preferencePK + preferenceController
This commit is contained in:
parent
ced6a29d82
commit
b9ad367ed3
@ -1 +1 @@
|
||||
rootProject.name = 'simpleat-back'
|
||||
rootProject.name = 'simpleat'
|
||||
|
@ -125,7 +125,7 @@ public class PersonneController {
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/sign-up")
|
||||
@PostMapping("/signup")
|
||||
public ResponseEntity<JsonWebToken> signUp(@RequestBody Personne personne) {
|
||||
try {
|
||||
return ResponseEntity.ok(new JsonWebToken(personneService.signup(personne)));
|
||||
|
@ -49,8 +49,17 @@ public class PreferenceController {
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/add-preference")
|
||||
public ResponseEntity<?> ajoutPreference(@RequestBody Preference preference){
|
||||
// @PostMapping("/add-preference")
|
||||
// public ResponseEntity<?> ajoutPreference(@RequestBody Preference preference){
|
||||
// System.out.println(preference);
|
||||
// return ResponseEntity.status(HttpStatus.OK).body(preferenceRepository.save(preference));
|
||||
// }
|
||||
|
||||
@PostMapping("/add-preference/{iduser}/{idrestau}")
|
||||
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)));
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(preferenceRepository.save(preference));
|
||||
}
|
||||
|
||||
@ -60,7 +69,7 @@ public class PreferenceController {
|
||||
// return ResponseEntity.status(HttpStatus.OK).body(preferenceRepository.save(personne));
|
||||
// }
|
||||
//
|
||||
@DeleteMapping("/delete-preference/{idrestau}/{iduser}")
|
||||
@DeleteMapping("/delete-preference/{iduser}/{idrestau}")
|
||||
public void deletePreferenceById(@PathVariable int iduser, @PathVariable int idrestau ){
|
||||
PreferencePK id = new PreferencePK(personneRepository.getById(iduser) ,restaurantRepository.getById(idrestau));
|
||||
preferenceRepository.deleteById(id);
|
||||
|
@ -45,7 +45,7 @@ public class RestaurantController {
|
||||
|
||||
|
||||
@PutMapping(value = "/update-restaurant/{id}")
|
||||
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||
public ResponseEntity<?> modifRestaurant(@PathVariable int id, @RequestBody Restaurant personne){
|
||||
return ResponseEntity.status(HttpStatus.OK).body(restaurantRepository.save(personne));
|
||||
}
|
||||
|
@ -19,6 +19,13 @@ public class Preference {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public Preference(PreferencePK preferencePK) {
|
||||
super();
|
||||
this.preferencePK = preferencePK;
|
||||
}
|
||||
|
||||
public Preference(PreferencePK preferencePK, int note, boolean favoris) {
|
||||
super();
|
||||
this.preferencePK = preferencePK;
|
||||
|
@ -10,6 +10,7 @@ import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.PrimaryKeyJoinColumn;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
@ -40,7 +41,7 @@ public class PreferencePK implements Serializable {
|
||||
|
||||
@ManyToOne
|
||||
@PrimaryKeyJoinColumn(name="id_personne", referencedColumnName ="id_personne" )
|
||||
@JsonIgnore
|
||||
@JsonBackReference("personne")
|
||||
public Personne getPersonne() {
|
||||
return personne;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user