Skip to content

Commit 5dfc68b

Browse files
authored
Merge pull request #279 from Modagbul/MNG-20
2 parents 04c1daa + cd5ac80 commit 5dfc68b

File tree

51 files changed

+924
-99
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+924
-99
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[[Mission-Comment-API]]
2+
= Mission Comment API
3+
4+
[[Mission-Comment-댓글-생성]]
5+
== Mission Comment 댓글 생성
6+
operation::mission-comment-controller-test/create_mission_comment[snippets='http-request,path-parameters,request-fields,http-response,response-fields']
7+
---
8+
9+
[[Mission-Comment-댓글-삭제]]
10+
== Mission Comment 댓글 삭제
11+
operation::mission-comment-controller-test/delete_mission_comment[snippets='http-request,path-parameters,response-fields']
12+
---
13+
14+
[[MissionArchive-Comment-댓글-전체-조회]]
15+
== Mission Comment 댓글 전체 조회
16+
operation::mission-comment-controller-test/get_board_comment_all[snippets='http-request,path-parameters,http-response,response-fields']
17+
---

src/docs/asciidoc/api.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ include::Mission-API.adoc[]
2222

2323
include::MissionArchive-API.adoc[]
2424

25+
include::MissionArchiveComment_API.adoc[]
26+
2527
include::MissionBoard-API.adoc[]
2628

2729
include::MissionGatherBoard-API.adoc[]

src/main/java/com/moing/backend/domain/board/presentation/BoardController.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,5 @@ public ResponseEntity<SuccessResponse<GetAllBoardResponse>> getBoardAll(@Authent
9191
@PathVariable Long teamId) {
9292
return ResponseEntity.ok(SuccessResponse.create(GET_BOARD_ALL_SUCCESS.getMessage(), this.getBoardUseCase.getAllBoard(user.getSocialId(), teamId)));
9393
}
94+
9495
}

src/main/java/com/moing/backend/domain/boardComment/application/mapper/BoardCommentMapper.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.moing.backend.domain.boardComment.application.mapper;
22

33
import com.moing.backend.domain.board.domain.entity.Board;
4-
import com.moing.backend.domain.boardComment.application.dto.request.CreateBoardCommentRequest;
4+
import com.moing.backend.domain.comment.application.dto.request.CreateCommentRequest;
55
import com.moing.backend.domain.boardComment.domain.entity.BoardComment;
66
import com.moing.backend.domain.teamMember.domain.entity.TeamMember;
77
import lombok.RequiredArgsConstructor;
@@ -10,11 +10,9 @@
1010
@Component
1111
@RequiredArgsConstructor
1212
public class BoardCommentMapper {
13-
public static BoardComment toBoardComment(TeamMember teamMember, Board board, CreateBoardCommentRequest createBoardCommentRequest, boolean isLeader) {
14-
BoardComment boardComment= BoardComment.builder()
15-
.content(createBoardCommentRequest.getContent())
16-
.isLeader(isLeader)
17-
.build();
13+
public static BoardComment toBoardComment(TeamMember teamMember, Board board, CreateCommentRequest createCommentRequest, boolean isLeader) {
14+
BoardComment boardComment= new BoardComment();
15+
boardComment.init(createCommentRequest.getContent(),isLeader);
1816
boardComment.updateBoard(board);
1917
boardComment.updateTeamMember(teamMember);
2018
return boardComment;

src/main/java/com/moing/backend/domain/boardComment/application/service/CreateBoardCommentUseCase.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.moing.backend.domain.boardComment.application.service;
22

3-
import com.moing.backend.domain.boardComment.application.dto.request.CreateBoardCommentRequest;
4-
import com.moing.backend.domain.boardComment.application.dto.response.CreateBoardCommentResponse;
53
import com.moing.backend.domain.boardComment.application.mapper.BoardCommentMapper;
64
import com.moing.backend.domain.boardComment.domain.entity.BoardComment;
75
import com.moing.backend.domain.boardComment.domain.service.BoardCommentSaveService;
6+
import com.moing.backend.domain.comment.application.dto.request.CreateCommentRequest;
7+
import com.moing.backend.domain.comment.application.dto.response.CreateCommentResponse;
88
import com.moing.backend.domain.team.application.service.CheckLeaderUseCase;
99
import com.moing.backend.global.response.BaseBoardServiceResponse;
1010
import com.moing.backend.global.utils.BaseBoardService;
@@ -25,15 +25,15 @@ public class CreateBoardCommentUseCase {
2525
/**
2626
* 게시글 댓글 생성
2727
*/
28-
public CreateBoardCommentResponse createBoardComment(String socialId, Long teamId, Long boardId, CreateBoardCommentRequest createBoardCommentRequest) {
28+
public CreateCommentResponse createBoardComment(String socialId, Long teamId, Long boardId, CreateCommentRequest createCommentRequest) {
2929
// 1. 게시글 댓글 생성
3030
BaseBoardServiceResponse data = baseBoardService.getCommonData(socialId, teamId, boardId);
3131
boolean isLeader = checkLeaderUseCase.isTeamLeader(data.getMember(), data.getTeam());
32-
BoardComment boardComment = boardCommentSaveService.saveBoardComment(BoardCommentMapper.toBoardComment(data.getTeamMember(), data.getBoard(), createBoardCommentRequest, isLeader));
32+
BoardComment boardComment = boardCommentSaveService.saveComment(BoardCommentMapper.toBoardComment(data.getTeamMember(), data.getBoard(), createCommentRequest, isLeader));
3333
// 2. 게시글 댓글 개수 증가
3434
data.getBoard().incrComNum();
3535
// 3. 게시글 댓글 알림
3636
sendCommentAlarmUseCase.sendNewUploadAlarm(data, boardComment);
37-
return new CreateBoardCommentResponse(boardComment.getBoardCommentId());
37+
return new CreateCommentResponse(boardComment.getBoardCommentId());
3838
}
3939
}

src/main/java/com/moing/backend/domain/boardComment/application/service/DeleteBoardCommentUseCase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ public class DeleteBoardCommentUseCase {
2727
public void deleteBoardComment(String socialId, Long teamId, Long boardId, Long boardCommentId){
2828
// 1. 게시글 댓글 조회
2929
BaseBoardServiceResponse data = baseBoardService.getCommonData(socialId, teamId, boardId);
30-
BoardComment boardComment=boardCommentGetService.getBoardComment(boardCommentId);
30+
BoardComment boardComment=boardCommentGetService.getComment(boardCommentId);
3131
// 2. 게시글 댓글 작성자만
3232
if (data.getTeamMember() == boardComment.getTeamMember()) {
3333
// 3. 삭제
34-
boardCommentDeleteService.deleteBoardComment(boardComment);
34+
boardCommentDeleteService.deleteComment(boardComment);
3535
// 4. 댓글 개수 줄이기
3636
data.getBoard().decrComNum();
3737
} else throw new NotAuthByBoardCommentException();

src/main/java/com/moing/backend/domain/boardComment/application/service/GetBoardCommentUseCase.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.moing.backend.domain.boardComment.application.service;
22

3-
import com.moing.backend.domain.boardComment.application.dto.response.GetBoardCommentResponse;
43
import com.moing.backend.domain.boardComment.domain.service.BoardCommentGetService;
4+
import com.moing.backend.domain.comment.application.dto.response.GetCommentResponse;
55
import com.moing.backend.global.response.BaseBoardServiceResponse;
66
import com.moing.backend.global.utils.BaseBoardService;
77
import lombok.RequiredArgsConstructor;
@@ -20,8 +20,8 @@ public class GetBoardCommentUseCase {
2020
/**
2121
* 게시글 댓글 전체 조회
2222
*/
23-
public GetBoardCommentResponse getBoardCommentAll(String socialId, Long teamId, Long boardId){
23+
public GetCommentResponse getBoardCommentAll(String socialId, Long teamId, Long boardId){
2424
BaseBoardServiceResponse data = baseBoardService.getCommonData(socialId, teamId, boardId);
25-
return boardCommentGetService.getBoardCommentAll(boardId, data.getTeamMember());
25+
return boardCommentGetService.getCommentAll(boardId, data.getTeamMember());
2626
}
2727
}
Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
package com.moing.backend.domain.boardComment.domain.entity;
22

33
import com.moing.backend.domain.board.domain.entity.Board;
4-
import com.moing.backend.domain.boardComment.application.dto.request.CreateBoardCommentRequest;
4+
import com.moing.backend.domain.comment.domain.entity.Comment;
55
import com.moing.backend.domain.teamMember.domain.entity.TeamMember;
6-
import com.moing.backend.global.entity.BaseTimeEntity;
76
import lombok.AllArgsConstructor;
87
import lombok.Builder;
98
import lombok.Getter;
@@ -16,16 +15,13 @@
1615
@NoArgsConstructor
1716
@AllArgsConstructor
1817
@Getter
19-
public class BoardComment extends BaseTimeEntity {
18+
public class BoardComment extends Comment {
2019

2120
@Id
2221
@GeneratedValue(strategy = GenerationType.IDENTITY)
2322
@Column(name = "board_comment_id")
2423
private Long boardCommentId;
2524

26-
@Column(nullable = false, length = 300)
27-
private String content;
28-
2925
@ManyToOne(fetch = FetchType.LAZY)
3026
@JoinColumn(name = "team_member_id")
3127
private TeamMember teamMember;
@@ -34,8 +30,6 @@ public class BoardComment extends BaseTimeEntity {
3430
@JoinColumn(name = "board_id")
3531
private Board board;
3632

37-
private boolean isLeader; /*작성자 소모임장유무*/
38-
3933
/**
4034
* 연관관계 매핑
4135
*/
@@ -48,8 +42,8 @@ public void updateTeamMember(TeamMember teamMember) {
4842
this.teamMember = teamMember;
4943
}
5044

51-
public void updateBoardComment(CreateBoardCommentRequest createBoardCommentRequest) {
52-
this.content = createBoardCommentRequest.getContent();
45+
public void init(String content, boolean isLeader){
46+
this.content=content;
47+
this.isLeader=isLeader;
5348
}
54-
5549
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package com.moing.backend.domain.boardComment.domain.repository;
22

3-
import com.moing.backend.domain.boardComment.application.dto.response.GetBoardCommentResponse;
3+
import com.moing.backend.domain.comment.application.dto.response.GetCommentResponse;
44
import com.moing.backend.domain.history.application.dto.response.NewUploadInfo;
55
import com.moing.backend.domain.teamMember.domain.entity.TeamMember;
66

77
import java.util.List;
88
import java.util.Optional;
99

1010
public interface BoardCommentCustomRepository {
11-
GetBoardCommentResponse findBoardCommentAll(Long boardId, TeamMember teamMember);
11+
GetCommentResponse findBoardCommentAll(Long boardId, TeamMember teamMember);
1212

1313
Optional<List<NewUploadInfo>> findNewUploadInfo(Long memberId, Long boardId);
1414
}

src/main/java/com/moing/backend/domain/boardComment/domain/repository/BoardCommentCustomRepositoryImpl.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.moing.backend.domain.boardComment.domain.repository;
22

33
import com.moing.backend.domain.block.domain.repository.BlockRepositoryUtils;
4-
import com.moing.backend.domain.boardComment.application.dto.response.CommentBlocks;
5-
import com.moing.backend.domain.boardComment.application.dto.response.GetBoardCommentResponse;
6-
import com.moing.backend.domain.boardComment.application.dto.response.QCommentBlocks;
4+
import com.moing.backend.domain.comment.application.dto.response.CommentBlocks;
5+
import com.moing.backend.domain.comment.application.dto.response.GetCommentResponse;
6+
import com.moing.backend.domain.comment.application.dto.response.QCommentBlocks;
77
import com.moing.backend.domain.history.application.dto.response.NewUploadInfo;
88
import com.moing.backend.domain.teamMember.domain.entity.QTeamMember;
99
import com.moing.backend.domain.teamMember.domain.entity.TeamMember;
@@ -31,7 +31,7 @@ public BoardCommentCustomRepositoryImpl(EntityManager em) {
3131

3232

3333
@Override
34-
public GetBoardCommentResponse findBoardCommentAll(Long boardId, TeamMember teamMember) {
34+
public GetCommentResponse findBoardCommentAll(Long boardId, TeamMember teamMember) {
3535

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

@@ -59,7 +59,7 @@ public GetBoardCommentResponse findBoardCommentAll(Long boardId, TeamMember team
5959
.orderBy(boardComment.createdDate.asc())
6060
.fetch();
6161

62-
return new GetBoardCommentResponse(commentBlocks);
62+
return new GetCommentResponse(commentBlocks);
6363
}
6464

6565
@Override

src/main/java/com/moing/backend/domain/boardComment/domain/repository/BoardCommentRepository.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.moing.backend.domain.boardComment.domain.repository;
22

3-
import com.moing.backend.domain.board.domain.entity.Board;
43
import com.moing.backend.domain.boardComment.domain.entity.BoardComment;
54
import org.springframework.data.jpa.repository.JpaRepository;
65

src/main/java/com/moing/backend/domain/boardComment/domain/service/BoardCommentDeleteService.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22

33
import com.moing.backend.domain.boardComment.domain.entity.BoardComment;
44
import com.moing.backend.domain.boardComment.domain.repository.BoardCommentRepository;
5+
import com.moing.backend.domain.comment.domain.service.CommentDeleteService;
56
import com.moing.backend.global.annotation.DomainService;
67
import lombok.RequiredArgsConstructor;
78

89
@DomainService
910
@RequiredArgsConstructor
10-
public class BoardCommentDeleteService {
11+
public class BoardCommentDeleteService implements CommentDeleteService<BoardComment> {
1112
private final BoardCommentRepository boardCommentRepository;
1213

13-
public void deleteBoardComment(BoardComment boardComment){
14+
@Override
15+
public void deleteComment(BoardComment boardComment){
1416
this.boardCommentRepository.delete(boardComment);
1517
}
18+
1619
}

src/main/java/com/moing/backend/domain/boardComment/domain/service/BoardCommentGetService.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package com.moing.backend.domain.boardComment.domain.service;
22

3-
import com.moing.backend.domain.boardComment.application.dto.response.GetBoardCommentResponse;
43
import com.moing.backend.domain.boardComment.domain.entity.BoardComment;
54
import com.moing.backend.domain.boardComment.domain.repository.BoardCommentRepository;
65
import com.moing.backend.domain.boardComment.exception.NotFoundByBoardCommentIdException;
6+
import com.moing.backend.domain.comment.application.dto.response.GetCommentResponse;
7+
import com.moing.backend.domain.comment.domain.service.CommentGetService;
78
import com.moing.backend.domain.history.application.dto.response.NewUploadInfo;
89
import com.moing.backend.domain.teamMember.domain.entity.TeamMember;
910
import com.moing.backend.global.annotation.DomainService;
@@ -16,18 +17,21 @@
1617
@DomainService
1718
@Transactional
1819
@RequiredArgsConstructor
19-
public class BoardCommentGetService {
20+
public class BoardCommentGetService implements CommentGetService<BoardComment> {
2021

2122
private final BoardCommentRepository boardCommentRepository;
2223

23-
public BoardComment getBoardComment(Long boardCommentId){
24-
return boardCommentRepository.findBoardCommentByBoardCommentId(boardCommentId).orElseThrow(()->new NotFoundByBoardCommentIdException());
24+
@Override
25+
public BoardComment getComment(Long boardCommentId){
26+
return boardCommentRepository.findBoardCommentByBoardCommentId(boardCommentId).orElseThrow(NotFoundByBoardCommentIdException::new);
2527
}
2628

27-
public GetBoardCommentResponse getBoardCommentAll(Long boardId, TeamMember teamMember){
29+
@Override
30+
public GetCommentResponse getCommentAll(Long boardId, TeamMember teamMember){
2831
return boardCommentRepository.findBoardCommentAll(boardId, teamMember);
2932
}
3033

34+
@Override
3135
public Optional<List<NewUploadInfo>> getNewUploadInfo(Long memberId, Long boardId) {
3236
return boardCommentRepository.findNewUploadInfo(memberId, boardId);
3337
}
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
package com.moing.backend.domain.boardComment.domain.service;
22

3-
import com.moing.backend.domain.boardComment.domain.entity.BoardComment;
43
import com.moing.backend.domain.boardComment.domain.repository.BoardCommentRepository;
4+
import com.moing.backend.domain.boardComment.domain.entity.BoardComment;
5+
import com.moing.backend.domain.comment.domain.service.CommentSaveService;
56
import com.moing.backend.global.annotation.DomainService;
67
import lombok.RequiredArgsConstructor;
78

89
@DomainService
910
@RequiredArgsConstructor
10-
public class BoardCommentSaveService {
11+
public class BoardCommentSaveService implements CommentSaveService<BoardComment> {
1112

1213
private final BoardCommentRepository boardCommentRepository;
1314

14-
public BoardComment saveBoardComment(BoardComment boardComment){
15+
@Override
16+
public BoardComment saveComment(BoardComment boardComment){
1517
return this.boardCommentRepository.save(boardComment);
1618
}
1719
}

src/main/java/com/moing/backend/domain/boardComment/presentattion/BoardCommentController.java

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package com.moing.backend.domain.boardComment.presentattion;
22

3-
import com.moing.backend.domain.boardComment.application.dto.request.CreateBoardCommentRequest;
4-
import com.moing.backend.domain.boardComment.application.dto.response.CreateBoardCommentResponse;
5-
import com.moing.backend.domain.boardComment.application.dto.response.GetBoardCommentResponse;
63
import com.moing.backend.domain.boardComment.application.service.CreateBoardCommentUseCase;
74
import com.moing.backend.domain.boardComment.application.service.DeleteBoardCommentUseCase;
85
import com.moing.backend.domain.boardComment.application.service.GetBoardCommentUseCase;
6+
import com.moing.backend.domain.boardComment.presentattion.constant.BoardCommentResponseMessage;
7+
import com.moing.backend.domain.comment.application.dto.request.CreateCommentRequest;
8+
import com.moing.backend.domain.comment.application.dto.response.CreateCommentResponse;
9+
import com.moing.backend.domain.comment.application.dto.response.GetCommentResponse;
910
import com.moing.backend.global.config.security.dto.User;
1011
import com.moing.backend.global.response.SuccessResponse;
1112
import lombok.AllArgsConstructor;
@@ -15,9 +16,7 @@
1516

1617
import javax.validation.Valid;
1718

18-
import static com.moing.backend.domain.board.presentation.constant.BoardResponseMessage.GET_BOARD_ALL_SUCCESS;
19-
import static com.moing.backend.domain.boardComment.presentattion.constant.BoardCommentResponseMessage.CREATE_BOARD_COMMENT_SUCCESS;
20-
import static com.moing.backend.domain.boardComment.presentattion.constant.BoardCommentResponseMessage.DELETE_BOARD_COMMENT_SUCCESS;
19+
import static com.moing.backend.domain.boardComment.presentattion.constant.BoardCommentResponseMessage.GET_BOARD_COMMENT_ALL_SUCCESS;
2120

2221
@RestController
2322
@AllArgsConstructor
@@ -34,11 +33,11 @@ public class BoardCommentController {
3433
* 작성자 : 김민수
3534
*/
3635
@PostMapping
37-
public ResponseEntity<SuccessResponse<CreateBoardCommentResponse>> createBoardComment(@AuthenticationPrincipal User user,
38-
@PathVariable Long teamId,
39-
@PathVariable Long boardId,
40-
@Valid @RequestBody CreateBoardCommentRequest createBoardCommentRequest) {
41-
return ResponseEntity.ok(SuccessResponse.create(CREATE_BOARD_COMMENT_SUCCESS.getMessage(), this.createBoardCommentUseCase.createBoardComment(user.getSocialId(), teamId, boardId, createBoardCommentRequest)));
36+
public ResponseEntity<SuccessResponse<CreateCommentResponse>> createBoardComment(@AuthenticationPrincipal User user,
37+
@PathVariable Long teamId,
38+
@PathVariable Long boardId,
39+
@Valid @RequestBody CreateCommentRequest createCommentRequest) {
40+
return ResponseEntity.ok(SuccessResponse.create(BoardCommentResponseMessage.CREATE_BOARD_COMMENT_SUCCESS.getMessage(), this.createBoardCommentUseCase.createBoardComment(user.getSocialId(), teamId, boardId, createCommentRequest)));
4241
}
4342

4443
/**
@@ -52,7 +51,7 @@ public ResponseEntity<SuccessResponse> deleteBoardComment(@AuthenticationPrincip
5251
@PathVariable Long boardId,
5352
@PathVariable Long commentId) {
5453
this.deleteBoardCommentUseCase.deleteBoardComment(user.getSocialId(), teamId, boardId, commentId);
55-
return ResponseEntity.ok(SuccessResponse.create(DELETE_BOARD_COMMENT_SUCCESS.getMessage()));
54+
return ResponseEntity.ok(SuccessResponse.create(BoardCommentResponseMessage.DELETE_BOARD_COMMENT_SUCCESS.getMessage()));
5655
}
5756

5857

@@ -62,9 +61,9 @@ public ResponseEntity<SuccessResponse> deleteBoardComment(@AuthenticationPrincip
6261
* 작성자 : 김민수
6362
*/
6463
@GetMapping
65-
public ResponseEntity<SuccessResponse<GetBoardCommentResponse>> getBoardCommentAll(@AuthenticationPrincipal User user,
66-
@PathVariable Long teamId,
67-
@PathVariable Long boardId) {
68-
return ResponseEntity.ok(SuccessResponse.create(GET_BOARD_ALL_SUCCESS.getMessage(), this.getBoardCommentUseCase.getBoardCommentAll(user.getSocialId(), teamId, boardId)));
64+
public ResponseEntity<SuccessResponse<GetCommentResponse>> getBoardCommentAll(@AuthenticationPrincipal User user,
65+
@PathVariable Long teamId,
66+
@PathVariable Long boardId) {
67+
return ResponseEntity.ok(SuccessResponse.create(GET_BOARD_COMMENT_ALL_SUCCESS.getMessage(), this.getBoardCommentUseCase.getBoardCommentAll(user.getSocialId(), teamId, boardId)));
6968
}
7069
}

0 commit comments

Comments
 (0)