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