게시판 수정, 휴가
This commit is contained in:
parent
712561ffbc
commit
e49577a02a
@ -21,6 +21,7 @@ import java.sql.Blob;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -56,7 +57,7 @@ public class BoardController {
|
||||
/**
|
||||
* 공지사항 목록 조회
|
||||
* @ReqMap map 요청 파라미터 (searchKeyword)
|
||||
* @return 페이징된 공지사항 목록
|
||||
* @return 전체 공지사항 목록
|
||||
*/
|
||||
@GetMapping("/notices")
|
||||
public ApiResponse<List<MapDto>> getNotices(@ReqMap MapDto map) {
|
||||
@ -76,7 +77,7 @@ public class BoardController {
|
||||
|
||||
/**
|
||||
* 자유/익명 게시판 목록 조회
|
||||
* @ReqMap map 요청 파라미터 (page, size, searchKeyword 포함)
|
||||
* @ReqMap map 요청 파라미터 (page, searchKeyword)
|
||||
* @return 페이징된 자유/익명 게시판 목록
|
||||
*/
|
||||
@GetMapping("/general")
|
||||
@ -121,56 +122,28 @@ public class BoardController {
|
||||
|
||||
/**
|
||||
* 게시물 작성
|
||||
* @ReqMap map 요청 파라미터 (page, size, searchKeyword 포함)
|
||||
* @ReqMap map 요청 파라미터 (LOCBRDTTL, LOCBRDCON, MEMBERSEQ, LOCBRDTYP,
|
||||
* LOCBRDPWD(익명일떄에만), LOCBRDCAT(지식커뮤니티만))
|
||||
* @return 작성된 게시물의 ID
|
||||
*/
|
||||
@PostMapping
|
||||
public ApiResponse<?> createBoard(@ReqMap MapDto map) {
|
||||
BigInteger createdIdx = boardService.createBoard(map); // 작성된 게시물의 idx를 반환
|
||||
Map<String, Object> responseData = new HashMap<>();
|
||||
responseData.put("boardId", createdIdx);
|
||||
responseData.put("CMNBRDSEQ", createdIdx);
|
||||
responseData.put("message", "게시물이 작성되었습니다.");
|
||||
return ApiResponse.ok(responseData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 첨부파일 추가
|
||||
* @param boardId 게시물 ID
|
||||
* @param file 업로드된 파일
|
||||
* @param filePath 파일 저장 경로
|
||||
* @param originalFileName 원본 파일명
|
||||
* @param fileExtension 파일 확장자
|
||||
* @param fileSize 파일 크기
|
||||
* @param registrantId 등록자 ID
|
||||
* @param fileName 저장될 파일명
|
||||
* @ReqMap map 요청 파라미터 (CMNFLEREG, CMNFLESIZ, CMNFLEEXT, CMNFLEORG, CMNFLENAM, CMNFLEPAT, CMNBRDSEQ)
|
||||
* @return 첨부파일 저장 결과 메시지
|
||||
*/
|
||||
@PostMapping("/{boardId}/attachments")
|
||||
public ApiResponse<String> uploadAttachment(
|
||||
@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();
|
||||
fileData.put("CMNBRDSEQ", boardId);
|
||||
fileData.put("CMNFLENAM", fileName); // 업로드된 파일 이름
|
||||
fileData.put("CMNFLEORG", originalFileName);
|
||||
fileData.put("CMNFLEPAT", filePath);
|
||||
fileData.put("CMNFLEEXT", fileExtension);
|
||||
fileData.put("CMNFLESIZ", fileSize);
|
||||
fileData.put("CMNFLEREG", registrantId);
|
||||
fileData.put("CMNFLERDT", new Date()); // 등록일 현재 시간
|
||||
|
||||
log.info("Uploading attachment for board ID: {}", boardId);
|
||||
|
||||
@PostMapping("/{CMNBRDSEQ}/attachments")
|
||||
public ApiResponse<String> uploadAttachment(@ReqMap MapDto map) {
|
||||
// 파일 데이터 저장
|
||||
boardService.addAttachment(fileData);
|
||||
boardService.addAttachment(map);
|
||||
|
||||
return ApiResponse.ok("첨부파일이 저장되었습니다.");
|
||||
}
|
||||
@ -230,7 +203,7 @@ public class BoardController {
|
||||
/**
|
||||
* 게시물 수정
|
||||
* @param boardId 게시물 ID
|
||||
* @ReqMap map 수정 데이터 (제목, 내용 등)
|
||||
* @ReqMap map 수정 데이터 (LOCBRDTTL, LOCBRDCON)
|
||||
* @return 수정 결과 메시지
|
||||
*/
|
||||
@PutMapping("/{boardId}")
|
||||
@ -241,73 +214,40 @@ public class BoardController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 게시물 좋아요/싫어요 추가
|
||||
* @param boardId 게시물 ID
|
||||
* @ReqMap map 좋아요/싫어요 데이터
|
||||
* 게시물,댓글 좋아요/싫어요 추가
|
||||
* @ReqMap map 데이터 (LOCCMTSEQ, MEMBERSEQ, LOCGOBGOD, LOCGOBBAD, LOCBRDSEQ)
|
||||
* @return 반응 추가 결과 메시지
|
||||
*/
|
||||
@PostMapping("/{boardId}/reaction")
|
||||
public ApiResponse<String> reactToBoard(@PathVariable("boardId") Long boardId, @ReqMap MapDto map) {
|
||||
map.put("LOCBRDSEQ", boardId);
|
||||
@PostMapping("/{LOCBRDSEQ}/{LOCCMTSEQ}/reaction")
|
||||
public ApiResponse<String> reactToBoard(@ReqMap MapDto map) {
|
||||
boardService.reactToBoard(map);
|
||||
return ApiResponse.ok("반응이 추가되었습니다.");
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* 댓글/대댓글 조회
|
||||
* @param boardId 게시물 ID
|
||||
* @return 댓글과 대댓글의 계층 구조 데이터
|
||||
*/
|
||||
@GetMapping("/{boardId}/comments")
|
||||
public ApiResponse<List<Map<String, Object>>> getComments(@PathVariable("boardId") int boardId) {
|
||||
public ApiResponse<List<MapDto>> getComments(@PathVariable("boardId") int boardId) {
|
||||
// 모든 댓글과 대댓글 조회
|
||||
List<MapDto> comments = boardService.getComments(boardId);
|
||||
|
||||
// 댓글과 대댓글을 계층 구조로 정렬
|
||||
Map<Integer, Map<String, Object>> commentMap = new HashMap<>();
|
||||
for (MapDto comment : comments) {
|
||||
int commentId = (int) comment.get("LOCCMTSEQ");
|
||||
Integer parentId = (Integer) comment.get("LOCCMTRPY");
|
||||
|
||||
Map<String, Object> commentData = new HashMap<>(comment);
|
||||
commentData.put("replies", new ArrayList<>()); // 대댓글 리스트 초기화
|
||||
|
||||
if (parentId == null) {
|
||||
// 댓글인 경우
|
||||
commentMap.put(commentId, commentData);
|
||||
} else {
|
||||
// 대댓글인 경우, 부모 댓글의 "replies"에 추가
|
||||
Map<String, Object> parentComment = commentMap.get(parentId);
|
||||
if (parentComment != null) {
|
||||
List<Map<String, Object>> replies = (List<Map<String, Object>>) parentComment.get("replies");
|
||||
replies.add(commentData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 최상위 댓글 리스트 반환
|
||||
List<Map<String, Object>> result = new ArrayList<>(commentMap.values());
|
||||
return ApiResponse.ok(result);
|
||||
return ApiResponse.ok(comments);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 댓글/대댓글 작성
|
||||
* @param boardId 게시물 ID
|
||||
* @ReqMap map 댓글 데이터 (내용, 부모 ID 등)
|
||||
* @ReqMap map 댓글 데이터 (LOCBRDSEQ, LOCCMTRPY, LOCCMTPNT, LOCCMTPWD, MEMBERSEQ 등)
|
||||
* @return 작성 결과 메시지
|
||||
*/
|
||||
@PostMapping("/{boardId}/comment")
|
||||
public ApiResponse<String> addCommentOrReply(@PathVariable("boardId") int boardId, @ReqMap MapDto map) {
|
||||
map.put("LOCBRDSEQ", boardId);
|
||||
|
||||
@PostMapping("/{LOCBRDSEQ}/comment")
|
||||
public ApiResponse<String> addCommentOrReply(@ReqMap MapDto map) {
|
||||
// 부모 댓글 확인
|
||||
Integer parentCommentId = (Integer) map.get("LOCCMTRPY");
|
||||
if (parentCommentId != null) {
|
||||
MapDto parentComment = boardService.getCommentById(parentCommentId);
|
||||
if (parentComment == null) {
|
||||
throw new IllegalArgumentException("Invalid parent comment ID: " + parentCommentId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
boardService.addCommentOrReply(map);
|
||||
return ApiResponse.ok("댓글 또는 대댓글이 작성되었습니다.");
|
||||
@ -316,7 +256,7 @@ public class BoardController {
|
||||
/**
|
||||
* 댓글/대댓글 수정
|
||||
* @param commentId 댓글 ID
|
||||
* @ReqMap map 수정 데이터 (내용, 비밀번호 등)
|
||||
* @ReqMap map 수정 데이터 (LOCCMTSEQ, LOCCMTRPY )
|
||||
* @return 수정 결과 메시지
|
||||
*/
|
||||
@PutMapping("/comment/{commentId}")
|
||||
@ -327,9 +267,6 @@ public class BoardController {
|
||||
throw new IllegalArgumentException("Comment not found for ID: " + commentId);
|
||||
}
|
||||
|
||||
// 부모 댓글 ID는 수정 불가
|
||||
map.remove("LOCCMTRPY");
|
||||
|
||||
map.put("LOCCMTSEQ", commentId);
|
||||
boardService.updateComment(map);
|
||||
|
||||
@ -339,7 +276,6 @@ public class BoardController {
|
||||
/**
|
||||
* 댓글/대댓글 삭제
|
||||
* @param commentId 댓글 ID
|
||||
* @ReqMap map 요청 데이터 (비밀번호 등)
|
||||
* @return 삭제 결과 메시지
|
||||
*/
|
||||
@DeleteMapping("/comment/{commentId}")
|
||||
@ -362,40 +298,17 @@ public class BoardController {
|
||||
return ApiResponse.ok(boardService.checkCommentPassword(map));
|
||||
}
|
||||
|
||||
/**
|
||||
* 게시물 비밀번호 확인
|
||||
* @param boardId 게시물 ID
|
||||
* @ReqMap map 비밀번호 데이터
|
||||
* @return 비밀번호 확인 결과
|
||||
*/
|
||||
@PostMapping("/{boardId}/password")
|
||||
public ApiResponse<Boolean> checkBoardPassword(@PathVariable("boardId") int boardId, @ReqMap MapDto map) {
|
||||
map.put("LOCBRDSEQ", boardId);
|
||||
return ApiResponse.ok(boardService.checkBoardPassword(map));
|
||||
}
|
||||
// /**
|
||||
// * 게시물 비밀번호 확인
|
||||
// * @param boardId 게시물 ID
|
||||
// * @ReqMap map 비밀번호 데이터
|
||||
// * @return 비밀번호 확인 결과
|
||||
// */
|
||||
// @PostMapping("/{boardId}/password")
|
||||
// public ApiResponse<Boolean> checkBoardPassword(@PathVariable("boardId") int boardId, @ReqMap MapDto map) {
|
||||
// map.put("LOCBRDSEQ", boardId);
|
||||
// return ApiResponse.ok(boardService.checkBoardPassword(map));
|
||||
// }
|
||||
|
||||
/**
|
||||
* 비밀게시판 여부 확인
|
||||
* @param boardId 게시물 ID
|
||||
* @return 비밀게시판 여부
|
||||
*/
|
||||
@GetMapping("/{boardId}/isSecret")
|
||||
public ApiResponse<Boolean> isSecretBoard(@PathVariable("boardId") Long boardId) {
|
||||
log.info("Checking if board ID {} is secret", boardId);
|
||||
return ApiResponse.ok(boardService.isSecretBoard(boardId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 댓글 좋아요/싫어요 추가
|
||||
* @param commentId 댓글 ID
|
||||
* @ReqMap map 좋아요/싫어요 데이터
|
||||
* @return 반응 추가 결과 메시지
|
||||
*/
|
||||
@PostMapping("/comment/{commentId}/reaction")
|
||||
public ApiResponse<String> reactToComment(@PathVariable("commentId") int commentId, @ReqMap MapDto map) {
|
||||
map.put("LOCCMTSEQ", commentId);
|
||||
boardService.reactToComment(map);
|
||||
return ApiResponse.ok("Comment reaction added.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package io.company.localhost.controller.api;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@ -45,4 +46,16 @@ public class VacationController {
|
||||
// 성공적으로 저장된 경우 응답 반환
|
||||
return ApiResponse.ok("모든 휴가가 성공적으로 저장되었습니다.");
|
||||
}
|
||||
|
||||
/**
|
||||
* 휴가 정보를 조회하여 프론트엔드로 전달
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public ApiResponse<List<MapDto>> getVacationList() {
|
||||
|
||||
// 서비스 호출을 통해 데이터 조회
|
||||
List<MapDto> vacationList = localVacaService.getVacationList();
|
||||
|
||||
return ApiResponse.ok(vacationList);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +1,18 @@
|
||||
package io.company.localhost.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import io.company.localhost.common.dto.MapDto;
|
||||
|
||||
|
||||
@Mapper
|
||||
public interface localvacaMapper {
|
||||
void insertVacation(MapDto vacationRequest);
|
||||
void insertVacation(MapDto map);
|
||||
|
||||
List<MapDto> findVacations();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -18,4 +18,8 @@ public class localvacaService {
|
||||
localvacaMapper.insertVacation(vacationRequest);
|
||||
}
|
||||
|
||||
public List<MapDto> getVacationList() {
|
||||
return localvacaMapper.findVacations();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
<if test="searchKeyword != null and searchKeyword != ''">
|
||||
AND LOCBRDTTL LIKE CONCAT('%', #{searchKeyword}, '%')
|
||||
</if>
|
||||
ORDER BY LOCBRDRDT DESC
|
||||
ORDER BY LOCBRDUDT DESC
|
||||
</select>
|
||||
|
||||
<!-- 자유/익명 게시판 조회 -->
|
||||
@ -29,7 +29,7 @@
|
||||
<if test="searchKeyword != null and searchKeyword != ''">
|
||||
AND LOCBRDTTL LIKE CONCAT('%', #{searchKeyword}, '%')
|
||||
</if>
|
||||
ORDER BY LOCBRDRDT DESC
|
||||
ORDER BY LOCBRDUDT DESC
|
||||
</select>
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@
|
||||
CMNFLEEXT,CMNFLESIZ,CMNFLEREG,CMNFLERDT
|
||||
) VALUES (
|
||||
#{CMNBRDSEQ},#{CMNFLENAM},#{CMNFLEORG},#{CMNFLEPAT},
|
||||
#{CMNFLEEXT},#{CMNFLESIZ},#{CMNFLEREG},#{CMNFLERDT}
|
||||
#{CMNFLEEXT},#{CMNFLESIZ},#{CMNFLEREG},NOW()
|
||||
)
|
||||
</insert>
|
||||
|
||||
@ -96,26 +96,26 @@
|
||||
LOCCMTUDT,LOCCMTPWD,LOCCMTRDT,LOCCMTPNT
|
||||
FROM localcomt
|
||||
WHERE LOCBRDSEQ = #{boardId}
|
||||
ORDER BY LOCCMTPNT ASC, LOCCMTRDT ASC
|
||||
ORDER BY LOCCMTPNT ASC, LOCCMTUDT ASC
|
||||
</select>
|
||||
|
||||
<!-- 댓글/대댓글 작성 -->
|
||||
<insert id="addCommentOrReply">
|
||||
INSERT INTO localcomt (LOCBRDSEQ, LOCCMTRPY, LOCCMTPWD, LOCCMTRDT, LOCCMTPNT)
|
||||
VALUES (#{LOCBRDSEQ}, #{LOCCMTRPY}, #{LOCCMTPWD}, NOW(), #{LOCCMTPNT})
|
||||
INSERT INTO localcomt (LOCBRDSEQ, LOCCMTRPY, LOCCMTPWD, LOCCMTRDT, LOCCMTUDT, LOCCMTPNT, MEMBERSEQ)
|
||||
VALUES (#{LOCBRDSEQ}, #{LOCCMTRPY}, #{LOCCMTPWD}, NOW(), NOW() , #{LOCCMTPNT}, #{MEMBERSEQ})
|
||||
</insert>
|
||||
|
||||
<!-- 댓글/대댓글 수정 -->
|
||||
<update id="updateComment">
|
||||
UPDATE localcomt
|
||||
SET LOCCMTRPY = #{LOCCMTRPY}, LOCCMTUDT = NOW()
|
||||
WHERE LOCCMTSEQ = #{LOCCMTSEQ} AND LOCCMTPWD = #{LOCCMTPWD}
|
||||
WHERE LOCCMTSEQ = #{LOCCMTSEQ}
|
||||
</update>
|
||||
|
||||
<!-- 댓글/대댓글 삭제 -->
|
||||
<delete id="deleteComment">
|
||||
DELETE FROM localcomt
|
||||
WHERE LOCCMTSEQ = #{LOCCMTSEQ} AND LOCCMTPWD = #{LOCCMTPWD}
|
||||
WHERE LOCCMTSEQ = #{LOCCMTSEQ}
|
||||
</delete>
|
||||
|
||||
<!-- 비밀번호 확인 (게시물) -->
|
||||
@ -132,15 +132,8 @@
|
||||
<select id="isSecretBoard" resultType="boolean">
|
||||
SELECT CASE WHEN LOCBRDTYP = 'S' THEN TRUE ELSE FALSE END
|
||||
FROM localbord
|
||||
WHERE LOCBRDSEQ = #{LOCBRDSEQ}
|
||||
WHERE LOCBRDSEQ = #{boardId}
|
||||
</select>
|
||||
|
||||
<!-- 댓글 좋아요/싫어요 추가 -->
|
||||
<insert id="reactToComment">
|
||||
INSERT INTO localcomt (LOCCMTSEQ, MEMBERSEQ, LOCGORGOD, LOCGORBAD)
|
||||
VALUES (#{LOCCMTSEQ}, #{MEMBERSEQ}, #{LOCGORGOD}, #{LOCGORBAD})
|
||||
ON DUPLICATE KEY UPDATE LOCGORGOD = #{LOCGORGOD}, LOCGORBAD = #{LOCGORBAD}
|
||||
</insert>
|
||||
|
||||
<!-- 댓글 id확인 -->
|
||||
<select id="getCommentById" resultType="io.company.localhost.common.dto.MapDto">
|
||||
|
||||
@ -8,4 +8,13 @@
|
||||
VALUES (#{employeeId}, #{date}, #{type}, NOW())
|
||||
</insert>
|
||||
|
||||
<!-- 직원 ID로 휴가 정보 조회 -->
|
||||
<select id="findVacationsByEmployeeId" parameterType="int" resultType="map">
|
||||
SELECT
|
||||
MEMBERSEQ
|
||||
LOCVACUDT,
|
||||
LOCVACTYP
|
||||
FROM
|
||||
localvaca
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue
Block a user