Skip to content

Commit

Permalink
Merge pull request #279 from Modagbul/MNG-20
Browse files Browse the repository at this point in the history
  • Loading branch information
seungueonn authored May 6, 2024
2 parents 04c1daa + cd5ac80 commit 5dfc68b
Show file tree
Hide file tree
Showing 51 changed files with 924 additions and 99 deletions.
17 changes: 17 additions & 0 deletions src/docs/asciidoc/MissionArchiveComment_API.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[[Mission-Comment-API]]
= Mission Comment API

[[Mission-Comment-댓글-생성]]
== Mission Comment 댓글 생성
operation::mission-comment-controller-test/create_mission_comment[snippets='http-request,path-parameters,request-fields,http-response,response-fields']
---

[[Mission-Comment-댓글-삭제]]
== Mission Comment 댓글 삭제
operation::mission-comment-controller-test/delete_mission_comment[snippets='http-request,path-parameters,response-fields']
---

[[MissionArchive-Comment-댓글-전체-조회]]
== Mission Comment 댓글 전체 조회
operation::mission-comment-controller-test/get_board_comment_all[snippets='http-request,path-parameters,http-response,response-fields']
---
2 changes: 2 additions & 0 deletions src/docs/asciidoc/api.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ include::Mission-API.adoc[]

include::MissionArchive-API.adoc[]

include::MissionArchiveComment_API.adoc[]

include::MissionBoard-API.adoc[]

include::MissionGatherBoard-API.adoc[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,5 @@ public ResponseEntity<SuccessResponse<GetAllBoardResponse>> getBoardAll(@Authent
@PathVariable Long teamId) {
return ResponseEntity.ok(SuccessResponse.create(GET_BOARD_ALL_SUCCESS.getMessage(), this.getBoardUseCase.getAllBoard(user.getSocialId(), teamId)));
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.moing.backend.domain.boardComment.application.mapper;

import com.moing.backend.domain.board.domain.entity.Board;
import com.moing.backend.domain.boardComment.application.dto.request.CreateBoardCommentRequest;
import com.moing.backend.domain.comment.application.dto.request.CreateCommentRequest;
import com.moing.backend.domain.boardComment.domain.entity.BoardComment;
import com.moing.backend.domain.teamMember.domain.entity.TeamMember;
import lombok.RequiredArgsConstructor;
Expand All @@ -10,11 +10,9 @@
@Component
@RequiredArgsConstructor
public class BoardCommentMapper {
public static BoardComment toBoardComment(TeamMember teamMember, Board board, CreateBoardCommentRequest createBoardCommentRequest, boolean isLeader) {
BoardComment boardComment= BoardComment.builder()
.content(createBoardCommentRequest.getContent())
.isLeader(isLeader)
.build();
public static BoardComment toBoardComment(TeamMember teamMember, Board board, CreateCommentRequest createCommentRequest, boolean isLeader) {
BoardComment boardComment= new BoardComment();
boardComment.init(createCommentRequest.getContent(),isLeader);
boardComment.updateBoard(board);
boardComment.updateTeamMember(teamMember);
return boardComment;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.moing.backend.domain.boardComment.application.service;

import com.moing.backend.domain.boardComment.application.dto.request.CreateBoardCommentRequest;
import com.moing.backend.domain.boardComment.application.dto.response.CreateBoardCommentResponse;
import com.moing.backend.domain.boardComment.application.mapper.BoardCommentMapper;
import com.moing.backend.domain.boardComment.domain.entity.BoardComment;
import com.moing.backend.domain.boardComment.domain.service.BoardCommentSaveService;
import com.moing.backend.domain.comment.application.dto.request.CreateCommentRequest;
import com.moing.backend.domain.comment.application.dto.response.CreateCommentResponse;
import com.moing.backend.domain.team.application.service.CheckLeaderUseCase;
import com.moing.backend.global.response.BaseBoardServiceResponse;
import com.moing.backend.global.utils.BaseBoardService;
Expand All @@ -25,15 +25,15 @@ public class CreateBoardCommentUseCase {
/**
* 게시글 댓글 생성
*/
public CreateBoardCommentResponse createBoardComment(String socialId, Long teamId, Long boardId, CreateBoardCommentRequest createBoardCommentRequest) {
public CreateCommentResponse createBoardComment(String socialId, Long teamId, Long boardId, CreateCommentRequest createCommentRequest) {
// 1. 게시글 댓글 생성
BaseBoardServiceResponse data = baseBoardService.getCommonData(socialId, teamId, boardId);
boolean isLeader = checkLeaderUseCase.isTeamLeader(data.getMember(), data.getTeam());
BoardComment boardComment = boardCommentSaveService.saveBoardComment(BoardCommentMapper.toBoardComment(data.getTeamMember(), data.getBoard(), createBoardCommentRequest, isLeader));
BoardComment boardComment = boardCommentSaveService.saveComment(BoardCommentMapper.toBoardComment(data.getTeamMember(), data.getBoard(), createCommentRequest, isLeader));
// 2. 게시글 댓글 개수 증가
data.getBoard().incrComNum();
// 3. 게시글 댓글 알림
sendCommentAlarmUseCase.sendNewUploadAlarm(data, boardComment);
return new CreateBoardCommentResponse(boardComment.getBoardCommentId());
return new CreateCommentResponse(boardComment.getBoardCommentId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ public class DeleteBoardCommentUseCase {
public void deleteBoardComment(String socialId, Long teamId, Long boardId, Long boardCommentId){
// 1. 게시글 댓글 조회
BaseBoardServiceResponse data = baseBoardService.getCommonData(socialId, teamId, boardId);
BoardComment boardComment=boardCommentGetService.getBoardComment(boardCommentId);
BoardComment boardComment=boardCommentGetService.getComment(boardCommentId);
// 2. 게시글 댓글 작성자만
if (data.getTeamMember() == boardComment.getTeamMember()) {
// 3. 삭제
boardCommentDeleteService.deleteBoardComment(boardComment);
boardCommentDeleteService.deleteComment(boardComment);
// 4. 댓글 개수 줄이기
data.getBoard().decrComNum();
} else throw new NotAuthByBoardCommentException();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.moing.backend.domain.boardComment.application.service;

import com.moing.backend.domain.boardComment.application.dto.response.GetBoardCommentResponse;
import com.moing.backend.domain.boardComment.domain.service.BoardCommentGetService;
import com.moing.backend.domain.comment.application.dto.response.GetCommentResponse;
import com.moing.backend.global.response.BaseBoardServiceResponse;
import com.moing.backend.global.utils.BaseBoardService;
import lombok.RequiredArgsConstructor;
Expand All @@ -20,8 +20,8 @@ public class GetBoardCommentUseCase {
/**
* 게시글 댓글 전체 조회
*/
public GetBoardCommentResponse getBoardCommentAll(String socialId, Long teamId, Long boardId){
public GetCommentResponse getBoardCommentAll(String socialId, Long teamId, Long boardId){
BaseBoardServiceResponse data = baseBoardService.getCommonData(socialId, teamId, boardId);
return boardCommentGetService.getBoardCommentAll(boardId, data.getTeamMember());
return boardCommentGetService.getCommentAll(boardId, data.getTeamMember());
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.moing.backend.domain.boardComment.domain.entity;

import com.moing.backend.domain.board.domain.entity.Board;
import com.moing.backend.domain.boardComment.application.dto.request.CreateBoardCommentRequest;
import com.moing.backend.domain.comment.domain.entity.Comment;
import com.moing.backend.domain.teamMember.domain.entity.TeamMember;
import com.moing.backend.global.entity.BaseTimeEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
Expand All @@ -16,16 +15,13 @@
@NoArgsConstructor
@AllArgsConstructor
@Getter
public class BoardComment extends BaseTimeEntity {
public class BoardComment extends Comment {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "board_comment_id")
private Long boardCommentId;

@Column(nullable = false, length = 300)
private String content;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "team_member_id")
private TeamMember teamMember;
Expand All @@ -34,8 +30,6 @@ public class BoardComment extends BaseTimeEntity {
@JoinColumn(name = "board_id")
private Board board;

private boolean isLeader; /*작성자 소모임장유무*/

/**
* 연관관계 매핑
*/
Expand All @@ -48,8 +42,8 @@ public void updateTeamMember(TeamMember teamMember) {
this.teamMember = teamMember;
}

public void updateBoardComment(CreateBoardCommentRequest createBoardCommentRequest) {
this.content = createBoardCommentRequest.getContent();
public void init(String content, boolean isLeader){
this.content=content;
this.isLeader=isLeader;
}

}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.moing.backend.domain.boardComment.domain.repository;

import com.moing.backend.domain.boardComment.application.dto.response.GetBoardCommentResponse;
import com.moing.backend.domain.comment.application.dto.response.GetCommentResponse;
import com.moing.backend.domain.history.application.dto.response.NewUploadInfo;
import com.moing.backend.domain.teamMember.domain.entity.TeamMember;

import java.util.List;
import java.util.Optional;

public interface BoardCommentCustomRepository {
GetBoardCommentResponse findBoardCommentAll(Long boardId, TeamMember teamMember);
GetCommentResponse findBoardCommentAll(Long boardId, TeamMember teamMember);

Optional<List<NewUploadInfo>> findNewUploadInfo(Long memberId, Long boardId);
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.moing.backend.domain.boardComment.domain.repository;

import com.moing.backend.domain.block.domain.repository.BlockRepositoryUtils;
import com.moing.backend.domain.boardComment.application.dto.response.CommentBlocks;
import com.moing.backend.domain.boardComment.application.dto.response.GetBoardCommentResponse;
import com.moing.backend.domain.boardComment.application.dto.response.QCommentBlocks;
import com.moing.backend.domain.comment.application.dto.response.CommentBlocks;
import com.moing.backend.domain.comment.application.dto.response.GetCommentResponse;
import com.moing.backend.domain.comment.application.dto.response.QCommentBlocks;
import com.moing.backend.domain.history.application.dto.response.NewUploadInfo;
import com.moing.backend.domain.teamMember.domain.entity.QTeamMember;
import com.moing.backend.domain.teamMember.domain.entity.TeamMember;
Expand Down Expand Up @@ -31,7 +31,7 @@ public BoardCommentCustomRepositoryImpl(EntityManager em) {


@Override
public GetBoardCommentResponse findBoardCommentAll(Long boardId, TeamMember teamMember) {
public GetCommentResponse findBoardCommentAll(Long boardId, TeamMember teamMember) {

BooleanExpression blockCondition = BlockRepositoryUtils.blockCondition(teamMember.getTeamMemberId(), boardComment.teamMember.member.memberId);

Expand Down Expand Up @@ -59,7 +59,7 @@ public GetBoardCommentResponse findBoardCommentAll(Long boardId, TeamMember team
.orderBy(boardComment.createdDate.asc())
.fetch();

return new GetBoardCommentResponse(commentBlocks);
return new GetCommentResponse(commentBlocks);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.moing.backend.domain.boardComment.domain.repository;

import com.moing.backend.domain.board.domain.entity.Board;
import com.moing.backend.domain.boardComment.domain.entity.BoardComment;
import org.springframework.data.jpa.repository.JpaRepository;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@

import com.moing.backend.domain.boardComment.domain.entity.BoardComment;
import com.moing.backend.domain.boardComment.domain.repository.BoardCommentRepository;
import com.moing.backend.domain.comment.domain.service.CommentDeleteService;
import com.moing.backend.global.annotation.DomainService;
import lombok.RequiredArgsConstructor;

@DomainService
@RequiredArgsConstructor
public class BoardCommentDeleteService {
public class BoardCommentDeleteService implements CommentDeleteService<BoardComment> {
private final BoardCommentRepository boardCommentRepository;

public void deleteBoardComment(BoardComment boardComment){
@Override
public void deleteComment(BoardComment boardComment){
this.boardCommentRepository.delete(boardComment);
}

}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.moing.backend.domain.boardComment.domain.service;

import com.moing.backend.domain.boardComment.application.dto.response.GetBoardCommentResponse;
import com.moing.backend.domain.boardComment.domain.entity.BoardComment;
import com.moing.backend.domain.boardComment.domain.repository.BoardCommentRepository;
import com.moing.backend.domain.boardComment.exception.NotFoundByBoardCommentIdException;
import com.moing.backend.domain.comment.application.dto.response.GetCommentResponse;
import com.moing.backend.domain.comment.domain.service.CommentGetService;
import com.moing.backend.domain.history.application.dto.response.NewUploadInfo;
import com.moing.backend.domain.teamMember.domain.entity.TeamMember;
import com.moing.backend.global.annotation.DomainService;
Expand All @@ -16,18 +17,21 @@
@DomainService
@Transactional
@RequiredArgsConstructor
public class BoardCommentGetService {
public class BoardCommentGetService implements CommentGetService<BoardComment> {

private final BoardCommentRepository boardCommentRepository;

public BoardComment getBoardComment(Long boardCommentId){
return boardCommentRepository.findBoardCommentByBoardCommentId(boardCommentId).orElseThrow(()->new NotFoundByBoardCommentIdException());
@Override
public BoardComment getComment(Long boardCommentId){
return boardCommentRepository.findBoardCommentByBoardCommentId(boardCommentId).orElseThrow(NotFoundByBoardCommentIdException::new);
}

public GetBoardCommentResponse getBoardCommentAll(Long boardId, TeamMember teamMember){
@Override
public GetCommentResponse getCommentAll(Long boardId, TeamMember teamMember){
return boardCommentRepository.findBoardCommentAll(boardId, teamMember);
}

@Override
public Optional<List<NewUploadInfo>> getNewUploadInfo(Long memberId, Long boardId) {
return boardCommentRepository.findNewUploadInfo(memberId, boardId);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
package com.moing.backend.domain.boardComment.domain.service;

import com.moing.backend.domain.boardComment.domain.entity.BoardComment;
import com.moing.backend.domain.boardComment.domain.repository.BoardCommentRepository;
import com.moing.backend.domain.boardComment.domain.entity.BoardComment;
import com.moing.backend.domain.comment.domain.service.CommentSaveService;
import com.moing.backend.global.annotation.DomainService;
import lombok.RequiredArgsConstructor;

@DomainService
@RequiredArgsConstructor
public class BoardCommentSaveService {
public class BoardCommentSaveService implements CommentSaveService<BoardComment> {

private final BoardCommentRepository boardCommentRepository;

public BoardComment saveBoardComment(BoardComment boardComment){
@Override
public BoardComment saveComment(BoardComment boardComment){
return this.boardCommentRepository.save(boardComment);
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.moing.backend.domain.boardComment.presentattion;

import com.moing.backend.domain.boardComment.application.dto.request.CreateBoardCommentRequest;
import com.moing.backend.domain.boardComment.application.dto.response.CreateBoardCommentResponse;
import com.moing.backend.domain.boardComment.application.dto.response.GetBoardCommentResponse;
import com.moing.backend.domain.boardComment.application.service.CreateBoardCommentUseCase;
import com.moing.backend.domain.boardComment.application.service.DeleteBoardCommentUseCase;
import com.moing.backend.domain.boardComment.application.service.GetBoardCommentUseCase;
import com.moing.backend.domain.boardComment.presentattion.constant.BoardCommentResponseMessage;
import com.moing.backend.domain.comment.application.dto.request.CreateCommentRequest;
import com.moing.backend.domain.comment.application.dto.response.CreateCommentResponse;
import com.moing.backend.domain.comment.application.dto.response.GetCommentResponse;
import com.moing.backend.global.config.security.dto.User;
import com.moing.backend.global.response.SuccessResponse;
import lombok.AllArgsConstructor;
Expand All @@ -15,9 +16,7 @@

import javax.validation.Valid;

import static com.moing.backend.domain.board.presentation.constant.BoardResponseMessage.GET_BOARD_ALL_SUCCESS;
import static com.moing.backend.domain.boardComment.presentattion.constant.BoardCommentResponseMessage.CREATE_BOARD_COMMENT_SUCCESS;
import static com.moing.backend.domain.boardComment.presentattion.constant.BoardCommentResponseMessage.DELETE_BOARD_COMMENT_SUCCESS;
import static com.moing.backend.domain.boardComment.presentattion.constant.BoardCommentResponseMessage.GET_BOARD_COMMENT_ALL_SUCCESS;

@RestController
@AllArgsConstructor
Expand All @@ -34,11 +33,11 @@ public class BoardCommentController {
* 작성자 : 김민수
*/
@PostMapping
public ResponseEntity<SuccessResponse<CreateBoardCommentResponse>> createBoardComment(@AuthenticationPrincipal User user,
@PathVariable Long teamId,
@PathVariable Long boardId,
@Valid @RequestBody CreateBoardCommentRequest createBoardCommentRequest) {
return ResponseEntity.ok(SuccessResponse.create(CREATE_BOARD_COMMENT_SUCCESS.getMessage(), this.createBoardCommentUseCase.createBoardComment(user.getSocialId(), teamId, boardId, createBoardCommentRequest)));
public ResponseEntity<SuccessResponse<CreateCommentResponse>> createBoardComment(@AuthenticationPrincipal User user,
@PathVariable Long teamId,
@PathVariable Long boardId,
@Valid @RequestBody CreateCommentRequest createCommentRequest) {
return ResponseEntity.ok(SuccessResponse.create(BoardCommentResponseMessage.CREATE_BOARD_COMMENT_SUCCESS.getMessage(), this.createBoardCommentUseCase.createBoardComment(user.getSocialId(), teamId, boardId, createCommentRequest)));
}

/**
Expand All @@ -52,7 +51,7 @@ public ResponseEntity<SuccessResponse> deleteBoardComment(@AuthenticationPrincip
@PathVariable Long boardId,
@PathVariable Long commentId) {
this.deleteBoardCommentUseCase.deleteBoardComment(user.getSocialId(), teamId, boardId, commentId);
return ResponseEntity.ok(SuccessResponse.create(DELETE_BOARD_COMMENT_SUCCESS.getMessage()));
return ResponseEntity.ok(SuccessResponse.create(BoardCommentResponseMessage.DELETE_BOARD_COMMENT_SUCCESS.getMessage()));
}


Expand All @@ -62,9 +61,9 @@ public ResponseEntity<SuccessResponse> deleteBoardComment(@AuthenticationPrincip
* 작성자 : 김민수
*/
@GetMapping
public ResponseEntity<SuccessResponse<GetBoardCommentResponse>> getBoardCommentAll(@AuthenticationPrincipal User user,
@PathVariable Long teamId,
@PathVariable Long boardId) {
return ResponseEntity.ok(SuccessResponse.create(GET_BOARD_ALL_SUCCESS.getMessage(), this.getBoardCommentUseCase.getBoardCommentAll(user.getSocialId(), teamId, boardId)));
public ResponseEntity<SuccessResponse<GetCommentResponse>> getBoardCommentAll(@AuthenticationPrincipal User user,
@PathVariable Long teamId,
@PathVariable Long boardId) {
return ResponseEntity.ok(SuccessResponse.create(GET_BOARD_COMMENT_ALL_SUCCESS.getMessage(), this.getBoardCommentUseCase.getBoardCommentAll(user.getSocialId(), teamId, boardId)));
}
}
Loading

0 comments on commit 5dfc68b

Please sign in to comment.