diff --git a/src/main/java/com/moviePocket/controller/post/PostController.java b/src/main/java/com/moviePocket/controller/post/PostController.java index 131c1e0..4de74ee 100644 --- a/src/main/java/com/moviePocket/controller/post/PostController.java +++ b/src/main/java/com/moviePocket/controller/post/PostController.java @@ -98,22 +98,22 @@ public ResponseEntity getPost(@RequestParam("idPost") Long idPost) { } @GetMapping("/movie") - public ResponseEntity> getAllPostByIdMovie(@RequestParam("idMovie") Long idMovie) { + public ResponseEntity> getAllPostsByIdMovie(@RequestParam("idMovie") Long idMovie) { return postService.getAllByIdMovie(idMovie); } @GetMapping("/list") - public ResponseEntity> getAllPostByIdList(@RequestParam("idList") Long idList) { + public ResponseEntity> getAllPostsByIdList(@RequestParam("idList") Long idList) { return postService.getAllByIdList(idList); } @GetMapping("/person") - public ResponseEntity> getAllPostByIdPerson(@RequestParam("idPerson") Long idPerson) { + public ResponseEntity> getAllPostsByIdPerson(@RequestParam("idPerson") Long idPerson) { return postService.getAllByIdPerson(idPerson); } @GetMapping("/user") - public ResponseEntity> getAllPostByUser() { + public ResponseEntity> getAllMyPosts() { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); return postService.getAllByUser(authentication.getName()); } @@ -162,17 +162,17 @@ public ResponseEntity getAuthorshipByIdPost(@RequestParam("idPost") Lon // return postService.getAllMyPosts(authentication.getName()); // } // -// @ApiOperation(value = "Get all posts of user", notes = "Returns a list of all posts for the specified username") -// @ApiResponses(value = { -// @ApiResponse(code = 200, message = "Successfully retrieved all posts for specified username"), -// @ApiResponse(code = 400, message = "Invalid username"), -// @ApiResponse(code = 404, message = "User not found") -// }) -// @GetMapping("/getAllUserPosts") -// public ResponseEntity> getAllUsername(@RequestParam("username") String username) { -// return postService.getAllByUsernamePosts(username); -// } -// +@ApiOperation(value = "Get all posts of user", notes = "Returns a list of all posts for the specified username") +@ApiResponses(value = { + @ApiResponse(code = 200, message = "Successfully retrieved all posts for specified username"), + @ApiResponse(code = 401, message = "Invalid username") +}) +@GetMapping("/someUser") +public ResponseEntity> getAllByUsername(@RequestParam("username") String username) { + return postService.getAllByUsernamePosts(username); +} + + // // @ApiOperation(value = "Get the most recent posts", notes = "Returns a sorted list of posts from newest to oldest") // @ApiResponses(value = { // @ApiResponse(code = 200, message = "Successfully retrieved all posts "), @@ -224,10 +224,20 @@ public ResponseEntity getAllLikePostsByIdMovie(@RequestParam("idPost") // return likePostService.getLeastLikedPosts(); // } - @GetMapping("/get/last") - public ResponseEntity> getLast() { - return postService.getTop10LatestPosts(); - } +// @ApiOperation(value = "Get the least liked(popular) posts", notes = "Returns a sorted list of posts from most least to liked") +// @ApiResponses(value = { +// @ApiResponse(code = 200, message = "Successfully retrieved all posts "), +// @ApiResponse(code = 404, message = "Not found") +// }) +// @GetMapping("/getLeastLikedPosts") +// public ResponseEntity> getLeastLikedPosts() { +// return likePostService.getLeastLikedPosts(); +// } +// +@GetMapping("/get/last") +public ResponseEntity> getLast() { + return postService.getTop10LatestPosts(); +} @GetMapping("/get/top") public ResponseEntity> getTop() { diff --git a/src/main/java/com/moviePocket/repository/user/UserRepository.java b/src/main/java/com/moviePocket/repository/user/UserRepository.java index 1910648..4b5bbfd 100644 --- a/src/main/java/com/moviePocket/repository/user/UserRepository.java +++ b/src/main/java/com/moviePocket/repository/user/UserRepository.java @@ -10,11 +10,17 @@ @Repository public interface UserRepository extends JpaRepository { + User findByEmail(String mail); + boolean existsByUsername(String username); + boolean existsByEmail(String email); + User findByUsernameAndAccountActive(String username, boolean isActive); + User findByUsername(String username); + @Query("SELECT u FROM User u WHERE u.username LIKE :partialUsername%") List findByPartialUsername(@Param("partialUsername") String partialUsername); }