Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into dev
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/com/moviePocket/repository/user/UserRepository.java
  • Loading branch information
prymakD committed Jan 10, 2024
2 parents a164ee0 + fb49df4 commit 0cb47a8
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 19 deletions.
48 changes: 29 additions & 19 deletions src/main/java/com/moviePocket/controller/post/PostController.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,22 @@ public ResponseEntity<ParsPost> getPost(@RequestParam("idPost") Long idPost) {
}

@GetMapping("/movie")
public ResponseEntity<List<ParsPost>> getAllPostByIdMovie(@RequestParam("idMovie") Long idMovie) {
public ResponseEntity<List<ParsPost>> getAllPostsByIdMovie(@RequestParam("idMovie") Long idMovie) {
return postService.getAllByIdMovie(idMovie);
}

@GetMapping("/list")
public ResponseEntity<List<ParsPost>> getAllPostByIdList(@RequestParam("idList") Long idList) {
public ResponseEntity<List<ParsPost>> getAllPostsByIdList(@RequestParam("idList") Long idList) {
return postService.getAllByIdList(idList);
}

@GetMapping("/person")
public ResponseEntity<List<ParsPost>> getAllPostByIdPerson(@RequestParam("idPerson") Long idPerson) {
public ResponseEntity<List<ParsPost>> getAllPostsByIdPerson(@RequestParam("idPerson") Long idPerson) {
return postService.getAllByIdPerson(idPerson);
}

@GetMapping("/user")
public ResponseEntity<List<ParsPost>> getAllPostByUser() {
public ResponseEntity<List<ParsPost>> getAllMyPosts() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
return postService.getAllByUser(authentication.getName());
}
Expand Down Expand Up @@ -162,17 +162,17 @@ public ResponseEntity<Boolean> 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<List<ParsPost>> 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<List<ParsPost>> 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 "),
Expand Down Expand Up @@ -224,10 +224,20 @@ public ResponseEntity<Boolean> getAllLikePostsByIdMovie(@RequestParam("idPost")
// return likePostService.getLeastLikedPosts();
// }

@GetMapping("/get/last")
public ResponseEntity<List<ParsPost>> 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<List<ParsPost>> getLeastLikedPosts() {
// return likePostService.getLeastLikedPosts();
// }
//
@GetMapping("/get/last")
public ResponseEntity<List<ParsPost>> getLast() {
return postService.getTop10LatestPosts();
}

@GetMapping("/get/top")
public ResponseEntity<List<ParsPost>> getTop() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@

@Repository
public interface UserRepository extends JpaRepository<User, Long> {

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<User> findByPartialUsername(@Param("partialUsername") String partialUsername);
}

0 comments on commit 0cb47a8

Please sign in to comment.