Compare commits
	
		
			3 Commits
		
	
	
		
			7a23dcc96a
			...
			a80fb2b297
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| a80fb2b297 | |||
| f484fb095e | |||
| 2fb6aef67c | 
@ -6,6 +6,7 @@ import org.springframework.web.bind.annotation.*;
 | 
				
			|||||||
import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
 | 
					import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
 | 
				
			||||||
import ovh.herisson.Clyde.Services.AuthenticatorService;
 | 
					import ovh.herisson.Clyde.Services.AuthenticatorService;
 | 
				
			||||||
import ovh.herisson.Clyde.Services.InscriptionService;
 | 
					import ovh.herisson.Clyde.Services.InscriptionService;
 | 
				
			||||||
 | 
					import ovh.herisson.Clyde.Services.ProtectionService;
 | 
				
			||||||
import ovh.herisson.Clyde.Tables.InscriptionRequest;
 | 
					import ovh.herisson.Clyde.Tables.InscriptionRequest;
 | 
				
			||||||
import ovh.herisson.Clyde.Tables.RequestState;
 | 
					import ovh.herisson.Clyde.Tables.RequestState;
 | 
				
			||||||
import ovh.herisson.Clyde.Tables.Role;
 | 
					import ovh.herisson.Clyde.Tables.Role;
 | 
				
			||||||
@ -34,13 +35,8 @@ public class InscriptionController {
 | 
				
			|||||||
            return new UnauthorizedResponse<>(null);
 | 
					            return new UnauthorizedResponse<>(null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Iterable<InscriptionRequest> inscriptionRequests = inscriptionServ.getAll();
 | 
					        Iterable<InscriptionRequest> inscriptionRequests = inscriptionServ.getAll();
 | 
				
			||||||
        ArrayList<Map<String,Object>> toReturn = new ArrayList<>();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (InscriptionRequest i:inscriptionRequests){
 | 
					        return new ResponseEntity<>(ProtectionService.requestsWithoutPasswords(inscriptionRequests), HttpStatus.OK);
 | 
				
			||||||
            toReturn.add(requestWithoutPassword(i));
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return new ResponseEntity<>(toReturn, HttpStatus.OK);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -55,38 +51,21 @@ public class InscriptionController {
 | 
				
			|||||||
        if (foundInscriptionRequest == null)
 | 
					        if (foundInscriptionRequest == null)
 | 
				
			||||||
            return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST);
 | 
					            return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return new ResponseEntity<>(requestWithoutPassword(foundInscriptionRequest), HttpStatus.OK);
 | 
					        return new ResponseEntity<>(ProtectionService.requestWithoutPassword(foundInscriptionRequest), HttpStatus.OK);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @PatchMapping("/request/register/{id}")
 | 
					    @PatchMapping("/request/register/{id}")
 | 
				
			||||||
    public ResponseEntity<InscriptionRequest> changeRequestState(@PathVariable long id,
 | 
					    public ResponseEntity<InscriptionRequest> changeRequestState(@PathVariable long id,
 | 
				
			||||||
                                                                 @RequestHeader("Authorization") String token,
 | 
					                                                                 @RequestHeader("Authorization") String token,
 | 
				
			||||||
                                                                 @RequestBody RequestState requestState)
 | 
					                                                                 @RequestBody RequestState state)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (authServ.isNotIn(new Role[]{Role.InscriptionService,Role.Admin},token))
 | 
					        if (authServ.isNotIn(new Role[]{Role.InscriptionService,Role.Admin},token))
 | 
				
			||||||
            return new UnauthorizedResponse<>(null);
 | 
					            return new UnauthorizedResponse<>(null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!inscriptionServ.modifyState(id, requestState))
 | 
					        if (!inscriptionServ.modifyState(id, state))
 | 
				
			||||||
            return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
 | 
					            return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return new ResponseEntity<>(HttpStatus.OK);
 | 
					        return new ResponseEntity<>(HttpStatus.OK);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
    private Map<String, Object> requestWithoutPassword(InscriptionRequest inscriptionRequest) {
 | 
					 | 
				
			||||||
        Map<String, Object> toReturn = new HashMap<>();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        toReturn.put("id", inscriptionRequest.getId());
 | 
					 | 
				
			||||||
        toReturn.put("lastName", inscriptionRequest.getLastName());
 | 
					 | 
				
			||||||
        toReturn.put("firstName", inscriptionRequest.getFirstName());
 | 
					 | 
				
			||||||
        toReturn.put("address", inscriptionRequest.getAddress());
 | 
					 | 
				
			||||||
        toReturn.put("email",inscriptionRequest.getEmail());
 | 
					 | 
				
			||||||
        toReturn.put("birthDate", inscriptionRequest.getBirthDate());
 | 
					 | 
				
			||||||
        toReturn.put("country", inscriptionRequest.getCountry());
 | 
					 | 
				
			||||||
        toReturn.put("curriculum", inscriptionRequest.getCurriculumId());
 | 
					 | 
				
			||||||
        toReturn.put("state", inscriptionRequest.getState());
 | 
					 | 
				
			||||||
        toReturn.put("profilePictureUrl", inscriptionRequest.getProfilePicture());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return toReturn;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -7,8 +7,10 @@ import org.springframework.http.ResponseEntity;
 | 
				
			|||||||
import org.springframework.web.bind.annotation.*;
 | 
					import org.springframework.web.bind.annotation.*;
 | 
				
			||||||
import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
 | 
					import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
 | 
				
			||||||
import ovh.herisson.Clyde.Services.AuthenticatorService;
 | 
					import ovh.herisson.Clyde.Services.AuthenticatorService;
 | 
				
			||||||
 | 
					import ovh.herisson.Clyde.Services.ProtectionService;
 | 
				
			||||||
import ovh.herisson.Clyde.Tables.InscriptionRequest;
 | 
					import ovh.herisson.Clyde.Tables.InscriptionRequest;
 | 
				
			||||||
import java.util.Date;
 | 
					import java.util.Date;
 | 
				
			||||||
 | 
					import java.util.Map;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@RestController
 | 
					@RestController
 | 
				
			||||||
@CrossOrigin(originPatterns = "*", allowCredentials = "true")
 | 
					@CrossOrigin(originPatterns = "*", allowCredentials = "true")
 | 
				
			||||||
@ -45,7 +47,10 @@ public class LoginController {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @PostMapping("/register")
 | 
					    @PostMapping("/register")
 | 
				
			||||||
    public ResponseEntity<InscriptionRequest> register(@RequestBody InscriptionRequest inscriptionRequest){
 | 
					    public ResponseEntity<Map<String,Object>> register(@RequestBody InscriptionRequest inscriptionRequest){
 | 
				
			||||||
        return new ResponseEntity<>(authServ.register(inscriptionRequest), HttpStatus.CREATED);
 | 
					
 | 
				
			||||||
 | 
					        InscriptionRequest returnedInscriptionRequest = authServ.register(inscriptionRequest);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return new ResponseEntity<>(ProtectionService.requestWithoutPassword(returnedInscriptionRequest), HttpStatus.CREATED);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -40,6 +40,16 @@ public class UserController {
 | 
				
			|||||||
        return new ResponseEntity<>(ProtectionService.userWithoutPassword(user), HttpStatus.OK);
 | 
					        return new ResponseEntity<>(ProtectionService.userWithoutPassword(user), HttpStatus.OK);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @GetMapping("/user/{id}")
 | 
				
			||||||
 | 
					    public ResponseEntity<HashMap<String ,Object>> getUserById(@RequestHeader("Authorization") String token, @PathVariable Long id){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary,Role.InscriptionService},token))
 | 
				
			||||||
 | 
					            return new UnauthorizedResponse<>(null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return new ResponseEntity<>(ProtectionService.userWithoutPassword(userService.getUserById(id)), HttpStatus.OK);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @PostMapping("/user")
 | 
					    @PostMapping("/user")
 | 
				
			||||||
    public ResponseEntity<Map<String ,Object>> postUser(@RequestBody User user,@RequestHeader("Authorization") String token){
 | 
					    public ResponseEntity<Map<String ,Object>> postUser(@RequestBody User user,@RequestHeader("Authorization") String token){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -111,4 +121,13 @@ public class UserController {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        return new ResponseEntity<>(ProtectionService.usersWithoutPasswords(students), HttpStatus.OK);
 | 
					        return new ResponseEntity<>(ProtectionService.usersWithoutPasswords(students), HttpStatus.OK);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @DeleteMapping("/user/{id}")
 | 
				
			||||||
 | 
					    public ResponseEntity<String> deleteStudent(@RequestHeader("Authorization") String token, @PathVariable Long id){
 | 
				
			||||||
 | 
					        if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary},token))
 | 
				
			||||||
 | 
					            return new UnauthorizedResponse<>(null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        userService.delete(userService.getUserById(id));
 | 
				
			||||||
 | 
					        return new ResponseEntity<>(HttpStatus.OK);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -32,6 +32,7 @@ public class AuthenticatorService {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public InscriptionRequest register(InscriptionRequest inscriptionRequest) {
 | 
					    public InscriptionRequest register(InscriptionRequest inscriptionRequest) {
 | 
				
			||||||
 | 
					        inscriptionRequest.setState(RequestState.Pending);
 | 
				
			||||||
        return inscriptionService.save(inscriptionRequest);
 | 
					        return inscriptionService.save(inscriptionRequest);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,10 +1,12 @@
 | 
				
			|||||||
package ovh.herisson.Clyde.Services;
 | 
					package ovh.herisson.Clyde.Services;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import ovh.herisson.Clyde.Tables.Course;
 | 
					import ovh.herisson.Clyde.Tables.Course;
 | 
				
			||||||
 | 
					import ovh.herisson.Clyde.Tables.InscriptionRequest;
 | 
				
			||||||
import ovh.herisson.Clyde.Tables.User;
 | 
					import ovh.herisson.Clyde.Tables.User;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.ArrayList;
 | 
					import java.util.ArrayList;
 | 
				
			||||||
import java.util.HashMap;
 | 
					import java.util.HashMap;
 | 
				
			||||||
 | 
					import java.util.Map;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class ProtectionService {
 | 
					public class ProtectionService {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -61,5 +63,32 @@ public class ProtectionService {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static Map<String, Object> requestWithoutPassword(InscriptionRequest inscriptionRequest) {
 | 
				
			||||||
 | 
					        Map<String, Object> toReturn = new HashMap<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        toReturn.put("id", inscriptionRequest.getId());
 | 
				
			||||||
 | 
					        toReturn.put("lastName", inscriptionRequest.getLastName());
 | 
				
			||||||
 | 
					        toReturn.put("firstName", inscriptionRequest.getFirstName());
 | 
				
			||||||
 | 
					        toReturn.put("address", inscriptionRequest.getAddress());
 | 
				
			||||||
 | 
					        toReturn.put("email",inscriptionRequest.getEmail());
 | 
				
			||||||
 | 
					        toReturn.put("birthDate", inscriptionRequest.getBirthDate());
 | 
				
			||||||
 | 
					        toReturn.put("country", inscriptionRequest.getCountry());
 | 
				
			||||||
 | 
					        toReturn.put("curriculum", inscriptionRequest.getCurriculumId());
 | 
				
			||||||
 | 
					        toReturn.put("state", inscriptionRequest.getState());
 | 
				
			||||||
 | 
					        toReturn.put("profilePictureUrl", inscriptionRequest.getProfilePicture());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return toReturn;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static Iterable<Map<String ,Object>> requestsWithoutPasswords(Iterable<InscriptionRequest> inscriptionRequests){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        ArrayList<Map<String,Object>> toReturn = new ArrayList<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for (InscriptionRequest i:inscriptionRequests){
 | 
				
			||||||
 | 
					            toReturn.add(requestWithoutPassword(i));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return toReturn;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -122,4 +122,12 @@ public class UserService {
 | 
				
			|||||||
    public Iterable<User> getAllTeachers (){return userRepo.findAllTeachers();}
 | 
					    public Iterable<User> getAllTeachers (){return userRepo.findAllTeachers();}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public Iterable<User> getAllStudents(){return userRepo.findAllStudents();}
 | 
					    public Iterable<User> getAllStudents(){return userRepo.findAllStudents();}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public User getUserById(long id) {
 | 
				
			||||||
 | 
					        return userRepo.findById(id);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void delete(User user) {
 | 
				
			||||||
 | 
					        userRepo.delete(user);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -1,6 +1,8 @@
 | 
				
			|||||||
package ovh.herisson.Clyde.Tables;
 | 
					package ovh.herisson.Clyde.Tables;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import jakarta.persistence.*;
 | 
					import jakarta.persistence.*;
 | 
				
			||||||
 | 
					import org.hibernate.annotations.OnDelete;
 | 
				
			||||||
 | 
					import org.hibernate.annotations.OnDeleteAction;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@Entity
 | 
					@Entity
 | 
				
			||||||
public class CurriculumCourse {
 | 
					public class CurriculumCourse {
 | 
				
			||||||
@ -10,9 +12,11 @@ public class CurriculumCourse {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @ManyToOne(fetch = FetchType.EAGER)
 | 
					    @ManyToOne(fetch = FetchType.EAGER)
 | 
				
			||||||
    @JoinColumn(name = "Curriculum")
 | 
					    @JoinColumn(name = "Curriculum")
 | 
				
			||||||
 | 
					    @OnDelete(action = OnDeleteAction.CASCADE)
 | 
				
			||||||
    private Curriculum curriculum;
 | 
					    private Curriculum curriculum;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @ManyToOne(fetch = FetchType.EAGER)
 | 
					    @ManyToOne(fetch = FetchType.EAGER)
 | 
				
			||||||
 | 
					    @OnDelete(action = OnDeleteAction.CASCADE)
 | 
				
			||||||
    @JoinColumn(name = "Course")
 | 
					    @JoinColumn(name = "Course")
 | 
				
			||||||
    private Course course;
 | 
					    private Course course;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,6 +1,8 @@
 | 
				
			|||||||
package ovh.herisson.Clyde.Tables;
 | 
					package ovh.herisson.Clyde.Tables;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import jakarta.persistence.*;
 | 
					import jakarta.persistence.*;
 | 
				
			||||||
 | 
					import org.hibernate.annotations.OnDelete;
 | 
				
			||||||
 | 
					import org.hibernate.annotations.OnDeleteAction;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@Entity
 | 
					@Entity
 | 
				
			||||||
public class ReInscriptionRequest {
 | 
					public class ReInscriptionRequest {
 | 
				
			||||||
@ -10,10 +12,12 @@ public class ReInscriptionRequest {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @ManyToOne
 | 
					    @ManyToOne
 | 
				
			||||||
    @JoinColumn(name = "Users")
 | 
					    @JoinColumn(name = "Users")
 | 
				
			||||||
 | 
					    @OnDelete(action = OnDeleteAction.CASCADE)
 | 
				
			||||||
    private User user;
 | 
					    private User user;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @ManyToOne
 | 
					    @ManyToOne
 | 
				
			||||||
    @JoinColumn(name = "Curriculum")
 | 
					    @JoinColumn(name = "Curriculum")
 | 
				
			||||||
 | 
					    @OnDelete(action = OnDeleteAction.CASCADE)
 | 
				
			||||||
    private Curriculum newCurriculum;
 | 
					    private Curriculum newCurriculum;
 | 
				
			||||||
    private RequestState state;
 | 
					    private RequestState state;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,6 +1,8 @@
 | 
				
			|||||||
package ovh.herisson.Clyde.Tables;
 | 
					package ovh.herisson.Clyde.Tables;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import jakarta.persistence.*;
 | 
					import jakarta.persistence.*;
 | 
				
			||||||
 | 
					import org.hibernate.annotations.OnDelete;
 | 
				
			||||||
 | 
					import org.hibernate.annotations.OnDeleteAction;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@Entity
 | 
					@Entity
 | 
				
			||||||
public class TeacherCourse {
 | 
					public class TeacherCourse {
 | 
				
			||||||
@ -9,11 +11,13 @@ public class TeacherCourse {
 | 
				
			|||||||
    private int id;
 | 
					    private int id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @ManyToOne(fetch = FetchType.EAGER)
 | 
					    @ManyToOne(fetch = FetchType.EAGER)
 | 
				
			||||||
 | 
					    @OnDelete(action = OnDeleteAction.CASCADE)
 | 
				
			||||||
    @JoinColumn(name = "Users")
 | 
					    @JoinColumn(name = "Users")
 | 
				
			||||||
    private User user;
 | 
					    private User user;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @ManyToOne(fetch = FetchType.EAGER)
 | 
					    @ManyToOne(fetch = FetchType.EAGER)
 | 
				
			||||||
 | 
					    @OnDelete(action = OnDeleteAction.CASCADE)
 | 
				
			||||||
    @JoinColumn(name = "Course")
 | 
					    @JoinColumn(name = "Course")
 | 
				
			||||||
    private Course course;
 | 
					    private Course course;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,6 +1,8 @@
 | 
				
			|||||||
package ovh.herisson.Clyde.Tables;
 | 
					package ovh.herisson.Clyde.Tables;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import jakarta.persistence.*;
 | 
					import jakarta.persistence.*;
 | 
				
			||||||
 | 
					import org.hibernate.annotations.OnDelete;
 | 
				
			||||||
 | 
					import org.hibernate.annotations.OnDeleteAction;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.Date;
 | 
					import java.util.Date;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -11,6 +13,7 @@ public class Token {
 | 
				
			|||||||
    private int id;
 | 
					    private int id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @ManyToOne(fetch = FetchType.EAGER)
 | 
					    @ManyToOne(fetch = FetchType.EAGER)
 | 
				
			||||||
 | 
					    @OnDelete(action = OnDeleteAction.CASCADE)
 | 
				
			||||||
    @JoinColumn(name ="Users")
 | 
					    @JoinColumn(name ="Users")
 | 
				
			||||||
    private User user;
 | 
					    private User user;
 | 
				
			||||||
    private String token;
 | 
					    private String token;
 | 
				
			||||||
 | 
				
			|||||||
@ -1,6 +1,8 @@
 | 
				
			|||||||
package ovh.herisson.Clyde.Tables;
 | 
					package ovh.herisson.Clyde.Tables;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import jakarta.persistence.*;
 | 
					import jakarta.persistence.*;
 | 
				
			||||||
 | 
					import org.hibernate.annotations.OnDelete;
 | 
				
			||||||
 | 
					import org.hibernate.annotations.OnDeleteAction;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@Entity
 | 
					@Entity
 | 
				
			||||||
public class UserCurriculum {
 | 
					public class UserCurriculum {
 | 
				
			||||||
@ -10,10 +12,11 @@ public class UserCurriculum {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    //Un étudiant peut avoir plusieurs curriculums
 | 
					    //Un étudiant peut avoir plusieurs curriculums
 | 
				
			||||||
    @ManyToOne(fetch = FetchType.EAGER)
 | 
					    @ManyToOne(fetch = FetchType.EAGER)
 | 
				
			||||||
 | 
					    @OnDelete(action = OnDeleteAction.CASCADE)
 | 
				
			||||||
    @JoinColumn(name = "Users")
 | 
					    @JoinColumn(name = "Users")
 | 
				
			||||||
    private User user;
 | 
					    private User user;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @OneToOne(fetch = FetchType.EAGER)
 | 
					    @ManyToOne(fetch = FetchType.EAGER)
 | 
				
			||||||
    @JoinColumn(name = "Curriculum")
 | 
					    @JoinColumn(name = "Curriculum")
 | 
				
			||||||
    private Curriculum curriculum;
 | 
					    private Curriculum curriculum;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user