게시판
This commit is contained in:
parent
5a1e5a1f33
commit
b64f203a93
@ -37,7 +37,19 @@ public class BoardController {
|
||||
//공지사항
|
||||
@GetMapping("/notices")
|
||||
public ApiResponse<List<MapDto>> getNotices() {
|
||||
return ApiResponse.ok(boardService.getNotices());
|
||||
List<MapDto> posts = boardService.getNotices();
|
||||
for (Map<String, Object> 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<String> 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<Map<String, Object>> getBoardDetail(@PathVariable Long boardId) {
|
||||
public ApiResponse<Map<String, Object>> 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<String> 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<Boolean> isSecretBoard(@PathVariable Long boardId) {
|
||||
log.info("Checking if board ID {} is secret", boardId);
|
||||
|
||||
@ -3,20 +3,19 @@
|
||||
<mapper namespace="io.company.localhost.mapper.LocalBordMapper">
|
||||
|
||||
<!-- 공지사항 조회 -->
|
||||
<select id="getNotices" resultType="java.util.Map">
|
||||
<select id="getNotices" resultType="hashmap">
|
||||
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>
|
||||
|
||||
<!-- 자유/비밀 게시판 조회 -->
|
||||
<select id="getGeneralPosts" resultType="map">
|
||||
<select id="getGeneralPosts" resultType="io.company.localhost.common.dto.MapDto">
|
||||
SELECT
|
||||
LOCBRDSEQ AS id,
|
||||
LOCBRDTTL AS title,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user