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 6be5861..19603ab 100644 --- a/src/main/java/io/company/localhost/controller/api/BoardController.java +++ b/src/main/java/io/company/localhost/controller/api/BoardController.java @@ -37,7 +37,19 @@ public class BoardController { //공지사항 @GetMapping("/notices") public ApiResponse> getNotices() { - return ApiResponse.ok(boardService.getNotices()); + List posts = boardService.getNotices(); + for (Map post : posts) { + Object content = post.get("content"); + if (content instanceof Blob) { + Blob blob = (Blob) content; + try { + post.put("content", new String(blob.getBytes(1, (int) blob.length()), StandardCharsets.UTF_8)); + } catch (Exception e) { + post.put("content", ""); // 변환 실패 시 기본 값 설정 + } + } + } + return ApiResponse.ok(posts); } //비밀,자유게시판 @GetMapping("/general") @@ -68,14 +80,14 @@ public class BoardController { // 첨부파일 추가 @PostMapping("/{boardId}/attachments") public ApiResponse uploadAttachment( - @PathVariable("boardId") Long boardId, - @RequestParam(name = "file") MultipartFile file, - @RequestParam(name = "CMNFLEPAT") String filePath, - @RequestParam(name = "CMNFLEORG") String originalFileName, - @RequestParam(name = "CMNFLEEXT") String fileExtension, - @RequestParam(name = "CMNFLESIZ") Long fileSize, - @RequestParam(name = "CMNFLEREG") Long registrantId, - @RequestParam(name = "CMNFLENAM") String fileName + @PathVariable("boardId") Long boardId, + @RequestParam("file") MultipartFile file, + @RequestParam("CMNFLEPAT") String filePath, + @RequestParam("CMNFLEORG") String originalFileName, + @RequestParam("CMNFLEEXT") String fileExtension, + @RequestParam("CMNFLESIZ") Long fileSize, + @RequestParam("CMNFLEREG") Long registrantId, + @RequestParam("CMNFLENAM") String fileName ) { // 데이터 준비 MapDto fileData = new MapDto(); @@ -95,10 +107,9 @@ public class BoardController { return ApiResponse.ok("첨부파일이 저장되었습니다."); } - // 게시물 상세보기 @GetMapping("/{boardId}") - public ApiResponse> getBoardDetail(@PathVariable Long boardId) { + public ApiResponse> getBoardDetail(@PathVariable("boardId") Long boardId) { log.info("Fetching details for board ID: {}", boardId); // 게시물 상세정보 조회 @@ -118,8 +129,6 @@ public class BoardController { return ApiResponse.ok(result); } - - // 게시물 삭제 @DeleteMapping("/{boardId}") public ApiResponse deleteBoard(@PathVariable Long boardId, @ReqMap MapDto map) { @@ -179,7 +188,7 @@ public class BoardController { map.put("LOCBRDSEQ", boardId); return ApiResponse.ok(boardService.checkBoardPassword(map)); } - // 비밀게시판 여부 확인 + // 비밀게시판 여부 확인 @GetMapping("/{boardId}/isSecret") public ApiResponse isSecretBoard(@PathVariable Long boardId) { log.info("Checking if board ID {} is secret", boardId); diff --git a/src/main/resources/mapper/LocalBordMapper.xml b/src/main/resources/mapper/LocalBordMapper.xml index f6f3920..0088287 100644 --- a/src/main/resources/mapper/LocalBordMapper.xml +++ b/src/main/resources/mapper/LocalBordMapper.xml @@ -3,20 +3,19 @@ - SELECT - LOCBRDSEQ, - LOCBRDTTL, - LOCBRDCON, - LOCBRDRDT, - LOCBRDTYP, + LOCBRDSEQ AS id, + LOCBRDTTL AS title, + LOCBRDCON AS content, + LOCBRDRDT AS date FROM localbord WHERE b.LOCBRDTYP = 'N' ORDER BY b.LOCBRDRDT DESC - SELECT LOCBRDSEQ AS id, LOCBRDTTL AS title,