From 691ffbff9448eee52dc6fbc162abc3561e2b77f0 Mon Sep 17 00:00:00 2001 From: yoon Date: Mon, 10 Feb 2025 10:18:57 +0900 Subject: [PATCH 1/9] =?UTF-8?q?=EA=B8=B0=EC=A1=B4=20=EB=B9=84=EB=B0=80?= =?UTF-8?q?=EB=B2=88=ED=98=B8=20=EC=B2=B4=ED=81=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../localhost/controller/common/UserController.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/io/company/localhost/controller/common/UserController.java b/src/main/java/io/company/localhost/controller/common/UserController.java index bde060a..65b1863 100644 --- a/src/main/java/io/company/localhost/controller/common/UserController.java +++ b/src/main/java/io/company/localhost/controller/common/UserController.java @@ -153,6 +153,18 @@ public class UserController { return ApiResponse.ok(isPwReset); } + /** + * 기존 비밀번호 체크 + * + * @param map + * @return ApiResponse + */ + @PostMapping("/checkPassword") + public ApiResponse selectPassword(@ReqMap MapDto map) { + boolean isNewPassword = netmemberservice.selectPassword(map); + return ApiResponse.ok(isNewPassword); + } + /** * 비밀번호 재설정 * From 9c61c369286e7b3f5e9ce569ac9665c44e5fd767 Mon Sep 17 00:00:00 2001 From: khj0414 Date: Mon, 10 Feb 2025 10:52:52 +0900 Subject: [PATCH 2/9] =?UTF-8?q?=EC=9A=A9=EC=96=B4=EC=A7=91=20userid=20?= =?UTF-8?q?=EC=9E=84=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../localhost/controller/api/worddictController.java | 8 ++++++-- .../controller/common/ImageUploadController.java | 1 - 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/company/localhost/controller/api/worddictController.java b/src/main/java/io/company/localhost/controller/api/worddictController.java index 55159bf..8d9d4e2 100644 --- a/src/main/java/io/company/localhost/controller/api/worddictController.java +++ b/src/main/java/io/company/localhost/controller/api/worddictController.java @@ -109,7 +109,9 @@ public class worddictController { public ApiResponse insertWord(@AuthenticationPrincipal MemberVo memberVo,@ReqMap MapDto map) { //userId - Long userId = AuthUtil.getUser().getId(); + //Long userId = AuthUtil.getUser().getId(); + //임시 + int userId = 38; map.put("userId", userId); Long result = worddictyservice.insertWord(map); @@ -126,7 +128,9 @@ public class worddictController { public ApiResponse updateWord(@AuthenticationPrincipal MemberVo memberVo,@ReqMap MapDto map) { //userId - Long userId = AuthUtil.getUser().getId(); + //Long userId = AuthUtil.getUser().getId(); + //임시 + int userId = 38; map.put("userId", userId); Long result = worddictyservice.updateWord(map); diff --git a/src/main/java/io/company/localhost/controller/common/ImageUploadController.java b/src/main/java/io/company/localhost/controller/common/ImageUploadController.java index b4002a3..f8bf8f0 100644 --- a/src/main/java/io/company/localhost/controller/common/ImageUploadController.java +++ b/src/main/java/io/company/localhost/controller/common/ImageUploadController.java @@ -24,7 +24,6 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; From d8c653618c3bebd7ca9773a09f6231b2ae63eb59 Mon Sep 17 00:00:00 2001 From: dyhj625 Date: Mon, 10 Feb 2025 14:28:44 +0900 Subject: [PATCH 3/9] =?UTF-8?q?memberseq=20=EC=9E=84=EC=9D=98=EA=B0=92?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EC=88=98=EC=A0=95(=EC=9E=84=EC=8B=9C)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/GlobalExceptionHandler.java | 65 ++++++++++---- .../exception/InvalidPasswordException.java | 7 ++ .../common/exception/NotFoundHandler.java | 15 +--- .../exception/code/CommonErrorCode.java | 2 + .../controller/api/BoardController.java | 89 ++++++++++++++----- .../localhost/service/localbordService.java | 47 +++++----- 6 files changed, 147 insertions(+), 78 deletions(-) create mode 100644 src/main/java/io/company/localhost/common/exception/InvalidPasswordException.java diff --git a/src/main/java/io/company/localhost/common/exception/GlobalExceptionHandler.java b/src/main/java/io/company/localhost/common/exception/GlobalExceptionHandler.java index 37914a2..e001992 100644 --- a/src/main/java/io/company/localhost/common/exception/GlobalExceptionHandler.java +++ b/src/main/java/io/company/localhost/common/exception/GlobalExceptionHandler.java @@ -10,6 +10,7 @@ * DATE AUTHOR NOTE * ----------------------------------------------------------- * 24.12.06 조인제 최초 생성 + * 25.02.10 서지희 InvalidPasswordException추가 * *************************************************************/ package io.company.localhost.common.exception; @@ -28,26 +29,52 @@ import lombok.extern.slf4j.Slf4j; @RestControllerAdvice(annotations = RestController.class) public class GlobalExceptionHandler extends ResponseEntityExceptionHandler { - @ExceptionHandler(RestApiException.class) - public ResponseEntity handleCustomException(RestApiException e) { - ErrorCode errorCode = e.getErrorCode(); - return ErrorResult.handleExceptionInternal(errorCode); - } + /** + * 사용자 정의 API 예외 처리 (RestApiException) + */ + @ExceptionHandler(RestApiException.class) + public ResponseEntity handleCustomException(RestApiException e) { + ErrorCode errorCode = e.getErrorCode(); + return ErrorResult.handleExceptionInternal(errorCode); + } - @ExceptionHandler(IllegalArgumentException.class) - public ResponseEntity handleIllegalArgument(IllegalArgumentException e) { - log.warn("handleIllegalArgument", e); - ErrorCode errorCode = CommonErrorCode.INVALID_PARAMETER; - return ErrorResult.handleExceptionInternal(errorCode, e.getMessage()); - } + /** + * 잘못된 요청 (IllegalArgumentException) 처리 + */ + @ExceptionHandler(IllegalArgumentException.class) + public ResponseEntity handleIllegalArgument(IllegalArgumentException e) { + log.warn("handleIllegalArgument", e); + ErrorCode errorCode = CommonErrorCode.INVALID_PARAMETER; + return ErrorResult.handleExceptionInternal(errorCode, e.getMessage()); + } + /** + * 게시물을 찾을 수 없는 경우 (NotFoundHandler) + */ + @ExceptionHandler(NotFoundHandler.class) + public ResponseEntity handleBoardNotFoundException(NotFoundHandler e) { + log.warn("handleBoardNotFoundException: {}", e.getMessage()); + ErrorCode errorCode = CommonErrorCode.RESOURCE_NOT_FOUND; + return ErrorResult.handleExceptionInternal(errorCode, e.getMessage()); + } - @ExceptionHandler({Exception.class}) - public ResponseEntity handleAllException(Exception ex) { - log.warn("handleAllException", ex); - ErrorCode errorCode = CommonErrorCode.INTERNAL_SERVER_ERROR; - return ErrorResult.handleExceptionInternal(errorCode); - } + /** + * 비밀번호가 틀린 경우 예외 처리 (InvalidPasswordException) + */ + @ExceptionHandler(InvalidPasswordException.class) + public ResponseEntity handleInvalidPasswordException(InvalidPasswordException e) { + log.warn("handleInvalidPasswordException: {}", e.getMessage()); + ErrorCode errorCode = CommonErrorCode.UNAUTHORIZED; + return ErrorResult.handleExceptionInternal(errorCode, e.getMessage()); + } - -} + /** + * 서버 내부 오류 처리 (Exception) + */ + @ExceptionHandler({Exception.class}) + public ResponseEntity handleAllException(Exception ex) { + log.warn("handleAllException", ex); + ErrorCode errorCode = CommonErrorCode.INTERNAL_SERVER_ERROR; + return ErrorResult.handleExceptionInternal(errorCode); + } +} \ No newline at end of file diff --git a/src/main/java/io/company/localhost/common/exception/InvalidPasswordException.java b/src/main/java/io/company/localhost/common/exception/InvalidPasswordException.java new file mode 100644 index 0000000..e723a99 --- /dev/null +++ b/src/main/java/io/company/localhost/common/exception/InvalidPasswordException.java @@ -0,0 +1,7 @@ +package io.company.localhost.common.exception; + +public class InvalidPasswordException extends RuntimeException { + public InvalidPasswordException(String message) { + super(message); + } +} diff --git a/src/main/java/io/company/localhost/common/exception/NotFoundHandler.java b/src/main/java/io/company/localhost/common/exception/NotFoundHandler.java index af18be4..118df5c 100644 --- a/src/main/java/io/company/localhost/common/exception/NotFoundHandler.java +++ b/src/main/java/io/company/localhost/common/exception/NotFoundHandler.java @@ -25,15 +25,8 @@ import io.company.localhost.common.exception.code.CommonErrorCode; import io.company.localhost.common.exception.code.ErrorCode; import lombok.extern.slf4j.Slf4j; -@Slf4j -@RestControllerAdvice -public class NotFoundHandler { - - @ResponseStatus(HttpStatus.NOT_FOUND) - @ExceptionHandler(NoHandlerFoundException.class) - public ResponseEntity noHandlerFoundArgument(NoHandlerFoundException e) { - log.warn("NoHandlerFoundException", e); - ErrorCode errorCode = CommonErrorCode.RESOURCE_NOT_FOUND; - return ErrorResult.handleExceptionInternal(errorCode, errorCode.getMessage()); - } +public class NotFoundHandler extends RuntimeException { + public NotFoundHandler(String message) { + super(message); + } } diff --git a/src/main/java/io/company/localhost/common/exception/code/CommonErrorCode.java b/src/main/java/io/company/localhost/common/exception/code/CommonErrorCode.java index 5d99fd4..caea7af 100644 --- a/src/main/java/io/company/localhost/common/exception/code/CommonErrorCode.java +++ b/src/main/java/io/company/localhost/common/exception/code/CommonErrorCode.java @@ -10,6 +10,7 @@ * DATE AUTHOR NOTE * ----------------------------------------------------------- * 24.12.06 조인제 최초 생성 + * 24.02.10 서지희 비밀번호 불일치 시 권한없음 추가 * *************************************************************/ package io.company.localhost.common.exception.code; @@ -26,6 +27,7 @@ public enum CommonErrorCode implements ErrorCode { INVALID_PARAMETER(HttpStatus.BAD_REQUEST,"잘못된 매개변수가 포함되었습니다."), RESOURCE_NOT_FOUND(HttpStatus.NOT_FOUND,"리소스가 존재하지 않습니다"), INTERNAL_SERVER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR,"내부 서버 오류"), + UNAUTHORIZED(HttpStatus.UNAUTHORIZED,"권한없음"), ; private final long code; diff --git a/src/main/java/io/company/localhost/controller/api/BoardController.java b/src/main/java/io/company/localhost/controller/api/BoardController.java index f5da9b3..ba4fe49 100644 --- a/src/main/java/io/company/localhost/controller/api/BoardController.java +++ b/src/main/java/io/company/localhost/controller/api/BoardController.java @@ -18,6 +18,7 @@ package io.company.localhost.controller.api; import java.math.BigInteger; import java.util.List; +import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.web.bind.annotation.*; import com.github.pagehelper.PageInfo; @@ -27,6 +28,8 @@ import io.company.localhost.common.annotation.ParameterCheck; import io.company.localhost.common.annotation.ReqMap; import io.company.localhost.common.dto.ApiResponse; import io.company.localhost.common.dto.MapDto; +import io.company.localhost.common.exception.InvalidPasswordException; +import io.company.localhost.common.exception.NotFoundHandler; import io.company.localhost.service.commoncodService; import io.company.localhost.service.localbordService; import io.company.localhost.utils.AuthUtil; @@ -41,6 +44,7 @@ public class BoardController { private final localbordService boardService; private final commoncodService commoncodService; + private final PasswordEncoder passwordEncoder; /** * 공지사항 목록 조회 @@ -76,8 +80,15 @@ public class BoardController { @ParameterCheck @PostMapping public ApiResponse createBoard(@ReqMap MapDto map) { - Long userId = AuthUtil.getUser().getId(); - map.put("MEMBERSEQ", userId); + Long userId = AuthUtil.getUser().getId(); + map.put("MEMBERSEQ", 22); + + if (map.containsKey("LOCBRDPWD") && !map.getString("LOCBRDPWD").trim().isEmpty()) { // 빈 값 체크 + String rawPassword = map.getString("LOCBRDPWD"); + String hashedPassword = passwordEncoder.encode(rawPassword); + map.put("LOCBRDPWD", hashedPassword); + } + return ApiResponse.ok(boardService.createBoard(map)); } @@ -90,7 +101,11 @@ public class BoardController { @ParameterCheck @GetMapping("/{boardId}") public ApiResponse getBoardDetail(@PathVariable("boardId") Long boardId) { - return ApiResponse.ok(boardService.getBoardDetail(boardId)); + MapDto board = boardService.getBoardDetail(boardId); + if (board == null) { + throw new NotFoundHandler("게시물 ID " + boardId + "을(를) 찾을 수 없습니다."); + } + return ApiResponse.ok(board); } /** @@ -129,7 +144,7 @@ public class BoardController { @PostMapping("/{CMNBRDSEQ}/attachments") public ApiResponse uploadAttachment(@ReqMap MapDto map) { Long userId = AuthUtil.getUser().getId(); - map.put("CMNFLEREG", userId); + map.put("CMNFLEREG", 22); boardService.addAttachment(map); return ApiResponse.ok("첨부파일이 저장되었습니다."); } @@ -144,7 +159,7 @@ public class BoardController { @PostMapping("/{LOCBRDSEQ}/{LOCCMTSEQ}/reaction") public ApiResponse reactToBoard(@ReqMap MapDto map) { Long userId = AuthUtil.getUser().getId(); - map.put("MEMBERSEQ", userId); + map.put("MEMBERSEQ", 22); boardService.reactToBoard(map); return ApiResponse.ok("반응이 성공적으로 처리되었습니다."); } @@ -172,7 +187,13 @@ public class BoardController { @PostMapping("/{LOCBRDSEQ}/comment") public ApiResponse addCommentOrReply(@ReqMap MapDto map) { Long userId = AuthUtil.getUser().getId(); - map.put("MEMBERSEQ", userId); + map.put("MEMBERSEQ", 22); + + if (map.containsKey("LOCCMTPWD") && !map.getString("LOCCMTPWD").trim().isEmpty()) { // 빈 값 체크 + String rawPassword = map.getString("LOCCMTPWD"); + String hashedPassword = passwordEncoder.encode(rawPassword); + map.put("LOCCMTPWD", hashedPassword); + } boardService.addCommentOrReply(map); return ApiResponse.ok("댓글 또는 대댓글이 작성되었습니다."); } @@ -205,20 +226,7 @@ public class BoardController { } /** - * 댓글 비밀번호 확인 - * @ReqMap map 수정 데이터 (LOCCMTSEQ, LOCCMTPWD) - * @return 비밀번호 확인 결과 - */ - @Member - @ParameterCheck - @PostMapping("/comment/{commentId}/password") - public ApiResponse checkCommentPassword(@ReqMap MapDto map) { - int commentId = (int) map.get("LOCCMTPWD"); - return ApiResponse.ok(boardService.getCommentPassword(commentId).equals(map.getString("LOCCMTPWD"))); - } - - /** - * 게시물 비밀번호 확인 + * 게시물 비밀번호 확인 (해싱된 비밀번호 비교 적용) * @ReqMap map 수정 데이터 (LOCBRDSEQ, LOCBRDPWD) * @return 비밀번호 확인 결과 */ @@ -226,8 +234,45 @@ public class BoardController { @ParameterCheck @PostMapping("/{boardId}/password") public ApiResponse checkBoardPassword(@ReqMap MapDto map) { - int boardId = (int) map.get("LOCBRDSEQ"); - return ApiResponse.ok(boardService.getBoardPassword(boardId).equals(map.getString("LOCBRDPWD"))); + int boardId = (int) map.get("LOCBRDSEQ"); + String rawPassword = map.getString("LOCBRDPWD"); + + String storedHashedPassword = boardService.getBoardPassword(boardId); + if (storedHashedPassword == null) { + throw new NotFoundHandler("해당 게시물이 존재하지 않습니다."); + } + + boolean isMatch = passwordEncoder.matches(rawPassword, storedHashedPassword); + if (!isMatch) { + throw new InvalidPasswordException("비밀번호가 일치하지 않습니다."); + } + + return ApiResponse.ok(true); + } + + /** + * 댓글 비밀번호 확인 (해싱된 비밀번호 비교 적용) + * @ReqMap map 수정 데이터 (LOCCMTSEQ, LOCCMTPWD) + * @return 비밀번호 확인 결과 + */ + @Member + @ParameterCheck + @PostMapping("/comment/{commentId}/password") + public ApiResponse checkCommentPassword(@ReqMap MapDto map) { + int commentId = (int) map.get("LOCCMTSEQ"); + String rawPassword = map.getString("LOCCMTPWD"); + + String storedHashedPassword = boardService.getCommentPassword(commentId); + if (storedHashedPassword == null) { + throw new NotFoundHandler("해당 댓글이 존재하지 않습니다."); + } + + boolean isMatch = passwordEncoder.matches(rawPassword, storedHashedPassword); + if (!isMatch) { + throw new InvalidPasswordException("비밀번호가 일치하지 않습니다."); + } + + return ApiResponse.ok(true); } /** diff --git a/src/main/java/io/company/localhost/service/localbordService.java b/src/main/java/io/company/localhost/service/localbordService.java index cddff6d..a5cab39 100644 --- a/src/main/java/io/company/localhost/service/localbordService.java +++ b/src/main/java/io/company/localhost/service/localbordService.java @@ -171,45 +171,24 @@ public class localbordService { return boardMapper.getCommentReactions(boardId); } - private void enrichBoardDetail(MapDto boardDetail) { - long boardId = ((Number) boardDetail.get("id")).longValue(); - boardDetail.put("hasAttachment", hasAttachments(boardId)); - boardDetail.put("commentCount", getCommentCount(boardId)); - MapDto reactions = getBoardReactions(boardId); - boardDetail.put("likeCount", reactions.getOrDefault("likeCount", 0)); - boardDetail.put("dislikeCount", reactions.getOrDefault("dislikeCount", 0)); - - // Blob 데이터를 문자열로 변환 - Object content = boardDetail.get("content"); - if (content != null) { - String contentString = convertBlobToString(content); // Blob을 문자열로 변환 - boardDetail.put("content", contentString); // JSON 변환 가능 - } - } - private String convertBlobToString(Object blob) { try { if (blob instanceof String) { - return (String) blob; // 이미 문자열인 경우 반환 + return (String) blob; // 이미 문자열이면 그대로 반환 } else if (blob instanceof java.sql.Blob) { java.sql.Blob sqlBlob = (java.sql.Blob) blob; long blobLength = sqlBlob.length(); byte[] blobBytes = sqlBlob.getBytes(1, (int) blobLength); - return new String(blobBytes, StandardCharsets.UTF_8); - } else if (blob instanceof ByteArrayInputStream) { - ByteArrayInputStream inputStream = (ByteArrayInputStream) blob; - byte[] bytes = inputStream.readAllBytes(); - return new String(bytes, StandardCharsets.UTF_8); + return new String(blobBytes, StandardCharsets.UTF_8); // SQL BLOB → 바이트 배열 → 문자열 변환 } else { - System.err.println("Unsupported blob type: " + blob.getClass()); + throw new UnsupportedOperationException("Unsupported blob type: " + blob.getClass()); // 지원되지 않는 타입이면 예외 발생 } } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException("Failed to convert Blob to String: " + e.getMessage(), e); + throw new RuntimeException("Failed to convert Blob to String: " + e.getMessage(), e); // 변환 실패 시 예외 처리 } - return null; } + private String extractFirstImageUrl(String jsonContent) { try { // JSON 유효성 검사 @@ -276,7 +255,23 @@ public class localbordService { } return plainTextBuilder.toString(); } + + private void enrichBoardDetail(MapDto boardDetail) { + long boardId = ((Number) boardDetail.get("id")).longValue(); + boardDetail.put("hasAttachment", hasAttachments(boardId)); + boardDetail.put("commentCount", getCommentCount(boardId)); + MapDto reactions = getBoardReactions(boardId); + boardDetail.put("likeCount", reactions.getOrDefault("likeCount", 0)); + boardDetail.put("dislikeCount", reactions.getOrDefault("dislikeCount", 0)); + // Blob 데이터를 문자열로 변환 + Object content = boardDetail.get("content"); + if (content != null) { + String contentString = convertBlobToString(content); // Blob을 문자열로 변환 + boardDetail.put("content", contentString); // JSON 변환 가능 + } + } + private void enrichPostsWithAdditionalData(List posts) { for (MapDto post : posts) { Object idObject = post.get("id"); From 2d0e4a9b5a12dfe04fedece8878ce01fc492616f Mon Sep 17 00:00:00 2001 From: dyhj625 Date: Mon, 10 Feb 2025 14:33:15 +0900 Subject: [PATCH 4/9] 22 --- .../company/localhost/controller/api/BoardController.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/company/localhost/controller/api/BoardController.java b/src/main/java/io/company/localhost/controller/api/BoardController.java index ba4fe49..d6cdd61 100644 --- a/src/main/java/io/company/localhost/controller/api/BoardController.java +++ b/src/main/java/io/company/localhost/controller/api/BoardController.java @@ -80,7 +80,7 @@ public class BoardController { @ParameterCheck @PostMapping public ApiResponse createBoard(@ReqMap MapDto map) { - Long userId = AuthUtil.getUser().getId(); + //Long userId = AuthUtil.getUser().getId(); map.put("MEMBERSEQ", 22); if (map.containsKey("LOCBRDPWD") && !map.getString("LOCBRDPWD").trim().isEmpty()) { // 빈 값 체크 @@ -143,7 +143,7 @@ public class BoardController { @ParameterCheck @PostMapping("/{CMNBRDSEQ}/attachments") public ApiResponse uploadAttachment(@ReqMap MapDto map) { - Long userId = AuthUtil.getUser().getId(); + //Long userId = AuthUtil.getUser().getId(); map.put("CMNFLEREG", 22); boardService.addAttachment(map); return ApiResponse.ok("첨부파일이 저장되었습니다."); @@ -158,7 +158,7 @@ public class BoardController { @ParameterCheck @PostMapping("/{LOCBRDSEQ}/{LOCCMTSEQ}/reaction") public ApiResponse reactToBoard(@ReqMap MapDto map) { - Long userId = AuthUtil.getUser().getId(); + //Long userId = AuthUtil.getUser().getId(); map.put("MEMBERSEQ", 22); boardService.reactToBoard(map); return ApiResponse.ok("반응이 성공적으로 처리되었습니다."); @@ -186,7 +186,7 @@ public class BoardController { @ParameterCheck @PostMapping("/{LOCBRDSEQ}/comment") public ApiResponse addCommentOrReply(@ReqMap MapDto map) { - Long userId = AuthUtil.getUser().getId(); + //Long userId = AuthUtil.getUser().getId(); map.put("MEMBERSEQ", 22); if (map.containsKey("LOCCMTPWD") && !map.getString("LOCCMTPWD").trim().isEmpty()) { // 빈 값 체크 From 331b5d53f5629b0e370d60e97fed1e4c9e3ef2d5 Mon Sep 17 00:00:00 2001 From: dyhj625 Date: Mon, 10 Feb 2025 15:13:37 +0900 Subject: [PATCH 5/9] s --- .../controller/api/BoardController.java | 4 ++-- .../localhost/service/localbordService.java | 5 ++--- src/main/resources/mapper/localbordMapper.xml | 17 +++++++++++++---- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/main/java/io/company/localhost/controller/api/BoardController.java b/src/main/java/io/company/localhost/controller/api/BoardController.java index d6cdd61..f0ae76e 100644 --- a/src/main/java/io/company/localhost/controller/api/BoardController.java +++ b/src/main/java/io/company/localhost/controller/api/BoardController.java @@ -234,7 +234,7 @@ public class BoardController { @ParameterCheck @PostMapping("/{boardId}/password") public ApiResponse checkBoardPassword(@ReqMap MapDto map) { - int boardId = (int) map.get("LOCBRDSEQ"); + int boardId = Integer.parseInt(map.getString("LOCBRDSEQ")); String rawPassword = map.getString("LOCBRDPWD"); String storedHashedPassword = boardService.getBoardPassword(boardId); @@ -259,7 +259,7 @@ public class BoardController { @ParameterCheck @PostMapping("/comment/{commentId}/password") public ApiResponse checkCommentPassword(@ReqMap MapDto map) { - int commentId = (int) map.get("LOCCMTSEQ"); + int commentId = Integer.parseInt(map.getString("LOCCMTSEQ")); String rawPassword = map.getString("LOCCMTPWD"); String storedHashedPassword = boardService.getCommentPassword(commentId); diff --git a/src/main/java/io/company/localhost/service/localbordService.java b/src/main/java/io/company/localhost/service/localbordService.java index a5cab39..97af85c 100644 --- a/src/main/java/io/company/localhost/service/localbordService.java +++ b/src/main/java/io/company/localhost/service/localbordService.java @@ -82,9 +82,8 @@ public class localbordService { public MapDto getBoardDetail(Long boardId) { incrementViewCount(boardId); MapDto boardDetail = boardMapper.selectBoardDetail(boardId); - if (boardDetail != null) { - enrichBoardDetail(boardDetail); - } + enrichBoardDetail(boardDetail); + return boardDetail; } diff --git a/src/main/resources/mapper/localbordMapper.xml b/src/main/resources/mapper/localbordMapper.xml index d99cd63..fe7a59c 100644 --- a/src/main/resources/mapper/localbordMapper.xml +++ b/src/main/resources/mapper/localbordMapper.xml @@ -67,10 +67,19 @@ + SELECT + b.LOCBRDSEQ AS id, + b.LOCBRDTTL AS title, + b.LOCBRDCON AS content, + b.LOCBRDUDT AS date, + b.LOCBRDTYP AS type, + b.LOCBRDCNT AS cnt, + m.MEMBERNAM AS author + FROM localbord b + LEFT JOIN netmember m ON b.MEMBERSEQ = m.MEMBERSEQ + WHERE b.LOCBRDSEQ = #{boardId} + + + + + From 16ce027be96a8effc1758719eba03e5614c27198 Mon Sep 17 00:00:00 2001 From: yoon Date: Tue, 11 Feb 2025 09:55:39 +0900 Subject: [PATCH 8/9] =?UTF-8?q?project=20=EA=B2=BD=EB=A1=9C=20member=20?= =?UTF-8?q?=EA=B6=8C=ED=95=9C=20=EC=B6=94=EA=B0=80=20(=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../localhost/common/security/config/SecurityConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/company/localhost/common/security/config/SecurityConfig.java b/src/main/java/io/company/localhost/common/security/config/SecurityConfig.java index 58f9f84..f23a512 100644 --- a/src/main/java/io/company/localhost/common/security/config/SecurityConfig.java +++ b/src/main/java/io/company/localhost/common/security/config/SecurityConfig.java @@ -80,7 +80,7 @@ public class SecurityConfig { http .securityMatcher("/api/**") // '/api/**' 경로에 대해서만 보안 적용 .authorizeHttpRequests(auth -> auth - //.requestMatchers("/api/board/**").hasRole("MEMBER") + .requestMatchers("/api/project/**").hasRole("MEMBER") .requestMatchers("/api/**").permitAll() // 특정 엔드포인트 허용 .anyRequest().authenticated() // 나머지 요청은 인증 필요 //auth.anyRequest().access(authorizationManager) // 모든 요청에 대해 권한 관리 From 6456a6d1c808eaa70e76bd620450012dd0b23fe8 Mon Sep 17 00:00:00 2001 From: dyhj625 Date: Tue, 11 Feb 2025 16:18:45 +0900 Subject: [PATCH 9/9] =?UTF-8?q?=ED=9C=B4=EA=B0=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../localhost/controller/api/VacationController.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/company/localhost/controller/api/VacationController.java b/src/main/java/io/company/localhost/controller/api/VacationController.java index ef1b3ae..3123c9e 100644 --- a/src/main/java/io/company/localhost/controller/api/VacationController.java +++ b/src/main/java/io/company/localhost/controller/api/VacationController.java @@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.RestController; import io.company.localhost.common.annotation.ReqMap; import io.company.localhost.common.dto.ApiResponse; import io.company.localhost.common.dto.MapDto; +import io.company.localhost.service.commoncodService; import io.company.localhost.service.localvacaService; // 서비스 클래스 경로 수정 import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -40,13 +41,12 @@ public class VacationController { localVacaService.insertVacation(request); } - // 성공적으로 저장된 경우 응답 반환 return ApiResponse.ok("모든 휴가가 성공적으로 저장되었습니다."); } /** - * ✅ 특정 연월에 대한 휴가 데이터 조회 + * 특정 연월에 대한 휴가 데이터 조회 */ @GetMapping("/list/{year}/{month}") public List getVacations(@PathVariable("year") int year, @PathVariable("month") int month) { @@ -54,7 +54,7 @@ public class VacationController { } /** - * ✅ 특정 연월에 대한 공휴일 데이터 조회 + * 특정 연월에 대한 공휴일 데이터 조회 */ @GetMapping("/{year}/{month}") public List getHolidays(@PathVariable("year") int year, @PathVariable("month") int month) {