Skip to content

Commit

Permalink
Merge pull request #157 from pknu-wap/feature/blog여부
Browse files Browse the repository at this point in the history
블로그 생성 여부
  • Loading branch information
JONG-KYEONG committed Nov 28, 2023
2 parents df951d3 + 6f69b30 commit 0e214e4
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.project.Glog.controller;

import com.project.Glog.domain.Blog;
import com.project.Glog.dto.request.user.UserCreateRequest;
import com.project.Glog.dto.response.blog.MyPageResponse;
import com.project.Glog.repository.BlogRepository;
import com.project.Glog.security.CurrentUser;
import com.project.Glog.security.UserPrincipal;
import com.project.Glog.service.BlogService;
Expand All @@ -10,10 +12,14 @@
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Optional;

@RestController
public class BlogController {
@Autowired
private BlogService blogService;
@Autowired
private BlogRepository blogRepository;

@GetMapping("/mypage")
public ResponseEntity<MyPageResponse> goToMypage(@CurrentUser UserPrincipal userPrincipal){
Expand Down Expand Up @@ -62,4 +68,16 @@ public ResponseEntity<String> putReadme(@CurrentUser UserPrincipal userPrincipal

return new ResponseEntity<>("success update read-me", HttpStatus.OK);
}

@GetMapping("/is/new/blog")
public Boolean readHasBlog(@CurrentUser UserPrincipal userPrincipal){
Optional<Blog> blogOptional = blogRepository.findByUserId(userPrincipal.getId());

if(blogOptional.isPresent()){
return true;
}
else{
return false;
}
}
}

0 comments on commit 0e214e4

Please sign in to comment.