Compare commits
No commits in common. "a9e5e458726dd5a0bfc635df06548761165d4d5b" and "73d50f3f50d54a4d2e55afe323117ca730b954d5" have entirely different histories.
a9e5e45872
...
73d50f3f50
@ -5,7 +5,9 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
|
||||
import ovh.herisson.Clyde.Services.*;
|
||||
import ovh.herisson.Clyde.Services.AuthenticatorService;
|
||||
import ovh.herisson.Clyde.Services.CurriculumCourseService;
|
||||
import ovh.herisson.Clyde.Services.CurriculumService;
|
||||
import ovh.herisson.Clyde.Tables.Curriculum;
|
||||
import ovh.herisson.Clyde.Tables.Role;
|
||||
|
||||
@ -19,13 +21,11 @@ public class CurriculumController {
|
||||
private final CurriculumService curriculumServ;
|
||||
private final AuthenticatorService authServ;
|
||||
|
||||
private final UserCurriculumService userCurriculumServ;
|
||||
private final CurriculumCourseService curriculumCourseServ;
|
||||
|
||||
public CurriculumController(CurriculumService curriculumServ, AuthenticatorService authServ, UserCurriculumService userCurriculumServ, CurriculumCourseService curriculumCourseServ){
|
||||
public CurriculumController(CurriculumService curriculumServ, AuthenticatorService authServ, CurriculumCourseService curriculumCourseServ){
|
||||
this.curriculumServ = curriculumServ;
|
||||
this.authServ = authServ;
|
||||
this.userCurriculumServ = userCurriculumServ;
|
||||
this.curriculumCourseServ = curriculumCourseServ;
|
||||
}
|
||||
|
||||
@ -39,19 +39,6 @@ public class CurriculumController {
|
||||
return new ResponseEntity<>(curriculumCourseServ.getDepthCurriculum(foundCurriculum), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/curriculum")
|
||||
public ResponseEntity<Map<String ,Object>> findSelfCurriculum(@RequestHeader("Authorization") String token){
|
||||
if (authServ.getUserFromToken(token) == null)
|
||||
return new UnauthorizedResponse<>(null);
|
||||
|
||||
Curriculum curriculum = userCurriculumServ.findByUser(authServ.getUserFromToken(token));
|
||||
|
||||
if (curriculum == null)
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
|
||||
return new ResponseEntity<>(curriculumCourseServ.getDepthCurriculum(curriculum),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/curriculums")
|
||||
public ResponseEntity<Iterable<Map<String, Object>>> findAllIndDepth(){
|
||||
return new ResponseEntity<>(curriculumCourseServ.getAllDepthCurriculum(),HttpStatus.OK);
|
||||
|
@ -1,13 +1,7 @@
|
||||
package ovh.herisson.Clyde.Repositories;
|
||||
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import ovh.herisson.Clyde.Tables.Curriculum;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
import ovh.herisson.Clyde.Tables.UserCurriculum;
|
||||
|
||||
public interface UserCurriculumRepository extends CrudRepository<UserCurriculum, Long> {
|
||||
|
||||
@Query("select uc.curriculum from UserCurriculum uc where uc.user = ?1")
|
||||
Curriculum findByUser(User student);
|
||||
}
|
||||
|
@ -1,20 +0,0 @@
|
||||
package ovh.herisson.Clyde.Services;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import ovh.herisson.Clyde.Repositories.UserCurriculumRepository;
|
||||
import ovh.herisson.Clyde.Tables.Curriculum;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
|
||||
@Service
|
||||
public class UserCurriculumService {
|
||||
|
||||
private final UserCurriculumRepository userCurriculumRepository;
|
||||
|
||||
public UserCurriculumService(UserCurriculumRepository userCurriculumRepository) {
|
||||
this.userCurriculumRepository = userCurriculumRepository;
|
||||
}
|
||||
|
||||
public Curriculum findByUser(User student){
|
||||
return userCurriculumRepository.findByUser(student);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user