Skip to content

Commit

Permalink
boardUpdateModify
Browse files Browse the repository at this point in the history
  • Loading branch information
Johyunik committed Nov 30, 2023
1 parent 3c80fe9 commit dc4c17e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,13 @@ public boolean patchBoard(
@RequestHeader("decodedToken") String nickName,
@PathVariable int boardId,
@RequestPart("board") String boardJson,
@RequestPart(value = "images", required = false) MultipartFile[] images) {
@RequestPart(value = "images", required = false) MultipartFile[] images) throws UnsupportedEncodingException {
String decodedNickname = new String(Base64.getDecoder().decode(nickName), "UTF-8");
ObjectMapper objectMapper = new ObjectMapper();

try {
BoardUpdateDTO boardUpdateDTO = objectMapper.readValue(boardJson, BoardUpdateDTO.class);
boardService.patchBoard(boardId, boardUpdateDTO, images, nickName);
boardService.patchBoard(boardId, boardUpdateDTO, images, decodedNickname);
return true;
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/weatherfit/board/service/BoardService.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ public void patchBoard(int boardId, BoardUpdateDTO boardUpdateDTO, MultipartFile

BoardEntity originalBoard = optionalBoard.orElseThrow(() -> new IllegalArgumentException("해당 게시글이 존재하지 않습니다. id=" + boardId));

System.out.println(originalBoard.getNickName().toString());

if (!originalBoard.getNickName().equals(nickName)) {
throw new IllegalArgumentException("게시글 수정 권한이 없습니다.");
}
Expand Down

0 comments on commit dc4c17e

Please sign in to comment.