Make board

This commit is contained in:
kimyonghwa
2019-05-10 02:17:23 +09:00
parent 2e5e6be283
commit 189e741ded
5 changed files with 11 additions and 11 deletions

View File

@@ -34,7 +34,7 @@ public class BoardController {
return responseService.getSingleResult(boardService.findBoard(boardName));
}
@ApiOperation(value = "게시글 리스트", notes = "게시판의 포스팅 정보를 조회한다.")
@ApiOperation(value = "게시글 리스트", notes = "게시글 리스트를 조회한다.")
@GetMapping(value = "/{boardName}/posts")
public ListResult<Post> posts(@PathVariable String boardName) {
return responseService.getListResult(boardService.findPosts(boardName));
@@ -43,7 +43,7 @@ public class BoardController {
@ApiImplicitParams({
@ApiImplicitParam(name = "X-AUTH-TOKEN", value = "로그인 성공 후 access_token", required = true, dataType = "String", paramType = "header")
})
@ApiOperation(value = "게시글 작성", notes = "게시판에 글을 작성한다.")
@ApiOperation(value = "게시글 작성", notes = "게시글을 작성한다.")
@PostMapping(value = "/{boardName}")
public SingleResult<Post> post(@PathVariable String boardName, @Valid @ModelAttribute ParamsPost post) {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
@@ -51,7 +51,7 @@ public class BoardController {
return responseService.getSingleResult(boardService.writePost(uid, boardName, post));
}
@ApiOperation(value = "게시글 상세", notes = "게시글 상세정보를 조회한다.")
@ApiOperation(value = "게시글 상세", notes = "게시글 상세정보를 조회한다.")
@GetMapping(value = "/post/{postId}")
public SingleResult<Post> post(@PathVariable long postId) {
return responseService.getSingleResult(boardService.getPost(postId));
@@ -60,7 +60,7 @@ public class BoardController {
@ApiImplicitParams({
@ApiImplicitParam(name = "X-AUTH-TOKEN", value = "로그인 성공 후 access_token", required = true, dataType = "String", paramType = "header")
})
@ApiOperation(value = "게시글 수정", notes = "게시판의 글을 수정한다.")
@ApiOperation(value = "게시글 수정", notes = "게시판의 글을 수정한다.")
@PutMapping(value = "/post/{postId}")
public SingleResult<Post> post(@PathVariable long postId, @Valid @ModelAttribute ParamsPost post) {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
@@ -71,7 +71,7 @@ public class BoardController {
@ApiImplicitParams({
@ApiImplicitParam(name = "X-AUTH-TOKEN", value = "로그인 성공 후 access_token", required = true, dataType = "String", paramType = "header")
})
@ApiOperation(value = "게시글 삭제", notes = "게시판의 글을 삭제한다.")
@ApiOperation(value = "게시글 삭제", notes = "게시글을 삭제한다.")
@DeleteMapping(value = "/post/{postId}")
public CommonResult deletePost(@PathVariable long postId) {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();

View File

@@ -2,6 +2,7 @@ package com.rest.api.entity;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.rest.api.entity.common.CommonDateEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
@@ -23,7 +24,7 @@ import java.util.stream.Collectors;
@AllArgsConstructor // 인자를 모두 갖춘 생성자를 자동으로 생성합니다.
@Table(name = "user") // 'user' 테이블과 매핑됨을 명시
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public class User implements UserDetails {
public class User extends CommonDateEntity implements UserDetails {
@Id // pk
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long msrl;

View File

@@ -11,13 +11,12 @@ import com.rest.api.repo.UserJpaRepo;
import com.rest.api.repo.board.BoardJpaRepo;
import com.rest.api.repo.board.PostJpaRepo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.util.List;
import java.util.Optional;
@Slf4j
@Service
@Transactional
@RequiredArgsConstructor
@@ -28,7 +27,7 @@ public class BoardService {
private final UserJpaRepo userJpaRepo;
public Board findBoard(String boardName) {
return boardJpaRepo.findByName(boardName);
return Optional.ofNullable(boardJpaRepo.findByName(boardName)).orElseThrow(CResourceNotExistException::new);
}
public List<Post> findPosts(String boardName) {

View File

@@ -1,6 +1,6 @@
logging:
level:
root: debug
root: info
com.rest.api: debug
spring:

View File

@@ -24,4 +24,4 @@ notOwner:
msg: "해당 자원의 소유자가 아닙니다."
resourceNotExist:
code: "-1007"
msg: "요청하신 자원이 존재 하지 않습니다."
msg: "요청 자원이 존재 하지 않습니다."