This commit is contained in:
Viktoria committed 2022-08-29 17:11:44 +02:00
1 parent e0c11fedc7
commit b52e056868
3 files changed
+17

No files matched your search

@@ -117,6 +117,17 @@ public class ProjectController {
return modelAndView;
}
@GetMapping("/{commercialStatus}")
public ModelAndView getAllProjectsWithCommercialStatus(@PathVariable("commercialStatus") int commercialStatus) {
ModelAndView modelAndView = new ModelAndView();
modelAndView.addObject("projects", projectService.getAllProjectsWithCommercialStatus(commercialStatus));
modelAndView.setViewName("all-projects");
return modelAndView;
}
@PostMapping("/{projectId}/{nameOfPosition}/applay")
public ModelAndView applayOnProject(@PathVariable("projectId") Long projectId,
@PathVariable("nameOfPosition") String nameOfPosition,
@@ -18,4 +18,6 @@ public interface ProjectRepo extends JpaRepository<Project, Long> {
@Query(value = "SELECT p from Project p WHERE p.technology LIKE %:technology%")
List<Project> findAllByTechnology(@Param("technology") String tech);
List<Project> findAllByCommercialStatus(int commercialStatus);
}
@@ -56,6 +56,10 @@ public class ProjectService {
return projectRepo.findById(projectId).orElseThrow(() -> new ProjectNotFoundException("Project not found"));
}
public List<Project> getAllProjectsWithCommercialStatus(int commercialStatus) {
return projectRepo.findAllByCommercialStatus(commercialStatus);
}
public List<Project> getAllProjectsForUser(Long userId) {
User user = userService.getUserById(userId);
return projectRepo.findAllByOwner(user);