Develop board
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package com.rest.api.controller.v1.board;
|
||||
|
||||
import com.rest.api.entity.board.Board;
|
||||
import com.rest.api.entity.board.Post;
|
||||
import com.rest.api.model.board.ParamsPost;
|
||||
import com.rest.api.model.response.ListResult;
|
||||
import com.rest.api.model.response.SingleResult;
|
||||
import com.rest.api.service.ResponseService;
|
||||
import com.rest.api.service.board.BoardService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
@Api(tags = {"3. Board"})
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping(value = "/v1/board")
|
||||
public class BoardController {
|
||||
|
||||
private final BoardService boardService;
|
||||
private final ResponseService responseService;
|
||||
|
||||
@ApiOperation(value = "게시판 정보 조회", notes = "게시판 정보를 조회한다.")
|
||||
@GetMapping(value="/{boardName}")
|
||||
public SingleResult<Board> boardInfo(@PathVariable String boardName) {
|
||||
return responseService.getSingleResult(boardService.findBoard(boardName));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "게시판 포스트 조회", notes = "게시판의 포스팅 정보를 조회한다.")
|
||||
@GetMapping(value="/{boardName}/posts")
|
||||
public ListResult<Post> posts(@PathVariable String boardName) {
|
||||
return responseService.getListResult(boardService.findPosts(boardName));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "게시판 글쓰기", notes = "게시판에 글을 작성한다.")
|
||||
@PostMapping(value="/{boardName}")
|
||||
public SingleResult<Post> post(@PathVariable String boardName, @Valid ParamsPost post) {
|
||||
return responseService.getSingleResult(boardService.writePost(boardName, post));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user