Skip to content

Commit

Permalink
Merge pull request #164 from pknu-wap/feature/또또추가사항
Browse files Browse the repository at this point in the history
get/blog/url 추가
  • Loading branch information
JONG-KYEONG authored Nov 29, 2023
2 parents cf5d486 + 75b75aa commit d5cf122
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ protected SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
"/guestbook",
"/introduce",
"/pr/posts/posted",
"/search/**")
"/search/**",
"/blog/url")
.permitAll()
.requestMatchers(HttpMethod.POST,
"/visit")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,11 @@ public Boolean readHasBlog(@CurrentUser UserPrincipal userPrincipal){
return false;
}
}
@GetMapping("/blog/url")
public ResponseEntity<String> getBlogUrl(@RequestParam Long categoryId){
String blogUrl = blogService.getBlogUrl(categoryId);

return new ResponseEntity<>(blogUrl, HttpStatus.OK);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ public interface BlogRepository extends JpaRepository<Blog, Long> {

@Query("SELECT b.id FROM Blog b WHERE b.blogUrl=:blogUrl")
Long findByBlogUrl(@Param("blogUrl") String blogUrl);

@Query("SELECT b.blogUrl FROM Blog b JOIN b.categories c WHERE c.id=:categoryId")
String findByCategoryId(@Param("categoryId") Long categoryId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,8 @@ public void registerReadme(UserPrincipal userPrincipal, String readme){
blog.setReadme(readme);
blogRepository.save(blog);
}

public String getBlogUrl(Long categoryId){
return new String(blogRepository.findByCategoryId(categoryId));
}
}

0 comments on commit d5cf122

Please sign in to comment.