게시판 상세추가
This commit is contained in:
parent
d5f9e7242f
commit
5a1e5a1f33
@ -69,13 +69,13 @@ public class BoardController {
|
|||||||
@PostMapping("/{boardId}/attachments")
|
@PostMapping("/{boardId}/attachments")
|
||||||
public ApiResponse<String> uploadAttachment(
|
public ApiResponse<String> uploadAttachment(
|
||||||
@PathVariable("boardId") Long boardId,
|
@PathVariable("boardId") Long boardId,
|
||||||
@RequestParam("file") MultipartFile file,
|
@RequestParam(name = "file") MultipartFile file,
|
||||||
@RequestParam("CMNFLEPAT") String filePath,
|
@RequestParam(name = "CMNFLEPAT") String filePath,
|
||||||
@RequestParam("CMNFLEORG") String originalFileName,
|
@RequestParam(name = "CMNFLEORG") String originalFileName,
|
||||||
@RequestParam("CMNFLEEXT") String fileExtension,
|
@RequestParam(name = "CMNFLEEXT") String fileExtension,
|
||||||
@RequestParam("CMNFLESIZ") Long fileSize,
|
@RequestParam(name = "CMNFLESIZ") Long fileSize,
|
||||||
@RequestParam("CMNFLEREG") Long registrantId,
|
@RequestParam(name = "CMNFLEREG") Long registrantId,
|
||||||
@RequestParam("CMNFLENAM") String fileName
|
@RequestParam(name = "CMNFLENAM") String fileName
|
||||||
) {
|
) {
|
||||||
// 데이터 준비
|
// 데이터 준비
|
||||||
MapDto fileData = new MapDto();
|
MapDto fileData = new MapDto();
|
||||||
@ -96,6 +96,30 @@ public class BoardController {
|
|||||||
return ApiResponse.ok("첨부파일이 저장되었습니다.");
|
return ApiResponse.ok("첨부파일이 저장되었습니다.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 게시물 상세보기
|
||||||
|
@GetMapping("/{boardId}")
|
||||||
|
public ApiResponse<Map<String, Object>> getBoardDetail(@PathVariable Long boardId) {
|
||||||
|
log.info("Fetching details for board ID: {}", boardId);
|
||||||
|
|
||||||
|
// 게시물 상세정보 조회
|
||||||
|
MapDto boardDetail = boardService.getBoardDetail(boardId);
|
||||||
|
|
||||||
|
// 첨부파일 목록 조회
|
||||||
|
List<MapDto> attachments = boardService.getAttachments(boardId);
|
||||||
|
|
||||||
|
// 댓글 목록 조회
|
||||||
|
List<MapDto> comments = boardService.getComments(boardId.intValue());
|
||||||
|
|
||||||
|
// 결과 조합
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
result.put("boardDetail", boardDetail);
|
||||||
|
result.put("attachments", attachments);
|
||||||
|
result.put("comments", comments);
|
||||||
|
|
||||||
|
return ApiResponse.ok(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 게시물 삭제
|
// 게시물 삭제
|
||||||
@DeleteMapping("/{boardId}")
|
@DeleteMapping("/{boardId}")
|
||||||
public ApiResponse<String> deleteBoard(@PathVariable Long boardId, @ReqMap MapDto map) {
|
public ApiResponse<String> deleteBoard(@PathVariable Long boardId, @ReqMap MapDto map) {
|
||||||
|
|||||||
@ -51,5 +51,11 @@ public interface LocalBordMapper {
|
|||||||
|
|
||||||
// 비밀 게시판 여부 확인
|
// 비밀 게시판 여부 확인
|
||||||
boolean isSecretBoard(Long boardId);
|
boolean isSecretBoard(Long boardId);
|
||||||
|
|
||||||
|
// 게시물 상세보기
|
||||||
|
MapDto selectBoardDetail(Long boardId);
|
||||||
|
|
||||||
|
// 첨부파일 가져오기
|
||||||
|
List<MapDto> selectAttachments(Long boardId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -32,6 +32,15 @@ public class LocalBordService {
|
|||||||
boardMapper.addAttachment(map);
|
boardMapper.addAttachment(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MapDto getBoardDetail(Long boardId) {
|
||||||
|
return boardMapper.selectBoardDetail(boardId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MapDto> getAttachments(Long boardId) {
|
||||||
|
return boardMapper.selectAttachments(boardId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void deleteBoard(MapDto map) {
|
public void deleteBoard(MapDto map) {
|
||||||
boardMapper.deleteBoard(map);
|
boardMapper.deleteBoard(map);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,6 +46,24 @@
|
|||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 게시물 상세정보 조회 -->
|
||||||
|
<select id="selectBoardDetail" parameterType="long" resultType="map">
|
||||||
|
SELECT LOCBRDSEQ AS id, LOCBRDTTL AS title, LOCBRDCON AS content, LOCBRDRDT AS date, LOCBRDTYP AS type
|
||||||
|
FROM localbord
|
||||||
|
WHERE LOCBRDSEQ = #{boardId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 첨부파일 목록 조회 -->
|
||||||
|
<select id="selectAttachments" parameterType="long" resultType="map">
|
||||||
|
SELECT CMNFLESEQ AS id, CMNFLEORG AS originalName, CMNFLENAM AS fileName, CMNFLEPAT AS path,
|
||||||
|
CMNFLEEXT AS extension, CMNFLESIZ AS size, CMNFLERDT AS uploadDate
|
||||||
|
FROM commonfil
|
||||||
|
WHERE CMNBRDSEQ = #{boardId}
|
||||||
|
ORDER BY CMNFLERDT DESC
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<!-- 게시물 삭제 -->
|
<!-- 게시물 삭제 -->
|
||||||
<delete id="deleteBoard">
|
<delete id="deleteBoard">
|
||||||
DELETE FROM localbord WHERE LOCBRDSEQ = #{LOCBRDSEQ}
|
DELETE FROM localbord WHERE LOCBRDSEQ = #{LOCBRDSEQ}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user