Skip to content

Commit

Permalink
remove comment, print
Browse files Browse the repository at this point in the history
  • Loading branch information
yennanliu committed Nov 6, 2023
1 parent 27b5c9f commit ed87b61
Showing 1 changed file with 0 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,11 @@ public String getPaginatedPosts(
public String getPostById(@PathVariable long id, Model model, Principal principal) {

Optional<Post> postOptional = postRepository.findById(id);

if (postOptional.isPresent()) {
model.addAttribute("post", postOptional.get());
model.addAttribute("comment", new CreateComment());
// load comment
// TODO : double check whether should do below here or in CommentController
List<Comment> commentList = commentService.getCommentsByPostId(id);
System.out.println(">>> comment len = " + commentList.size());
// only add to model when comment size > 0
if (commentList.size() > 0){
model.addAttribute("comments", commentList);
Expand Down Expand Up @@ -163,7 +160,6 @@ public String createPost(CreatePost request, Model model, Principal principal){
post.setSynopsis(PostUtil.getSynopsis(request.getContent()));
post.setAuthorId(author.getId());
post.setDateTime(LocalDateTime.now());
//post.setAuthorId(authorId);
log.info(">>> request = " + request + " post = " + post + " author = " + author);
log.info(">>>> create post end ...");
postService.savePost(post);
Expand All @@ -179,7 +175,6 @@ public String getMyPost(
Model model) {

Author author = authorService.getByName(principal.getName());

// if there is current user has no any post
if (author == null){
model.addAttribute("user", principal.getName());
Expand Down

0 comments on commit ed87b61

Please sign in to comment.