diff --git a/src/docs/asciidoc/MissionArchiveComment_API.adoc b/src/docs/asciidoc/MissionArchiveComment_API.adoc new file mode 100644 index 00000000..9ec5e7fa --- /dev/null +++ b/src/docs/asciidoc/MissionArchiveComment_API.adoc @@ -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'] +--- \ No newline at end of file diff --git a/src/docs/asciidoc/api.adoc b/src/docs/asciidoc/api.adoc index 41519d3c..0addb28b 100644 --- a/src/docs/asciidoc/api.adoc +++ b/src/docs/asciidoc/api.adoc @@ -22,6 +22,8 @@ include::Mission-API.adoc[] include::MissionArchive-API.adoc[] +include::MissionArchiveComment_API.adoc[] + include::MissionBoard-API.adoc[] include::MissionGatherBoard-API.adoc[] diff --git a/src/main/java/com/moing/backend/domain/board/presentation/BoardController.java b/src/main/java/com/moing/backend/domain/board/presentation/BoardController.java index 739935e4..6e0c89c4 100644 --- a/src/main/java/com/moing/backend/domain/board/presentation/BoardController.java +++ b/src/main/java/com/moing/backend/domain/board/presentation/BoardController.java @@ -91,4 +91,5 @@ public ResponseEntity> getBoardAll(@Authent @PathVariable Long teamId) { return ResponseEntity.ok(SuccessResponse.create(GET_BOARD_ALL_SUCCESS.getMessage(), this.getBoardUseCase.getAllBoard(user.getSocialId(), teamId))); } + } diff --git a/src/main/java/com/moing/backend/domain/boardComment/application/mapper/BoardCommentMapper.java b/src/main/java/com/moing/backend/domain/boardComment/application/mapper/BoardCommentMapper.java index e2311e2a..00f9f751 100644 --- a/src/main/java/com/moing/backend/domain/boardComment/application/mapper/BoardCommentMapper.java +++ b/src/main/java/com/moing/backend/domain/boardComment/application/mapper/BoardCommentMapper.java @@ -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; @@ -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; diff --git a/src/main/java/com/moing/backend/domain/boardComment/application/service/CreateBoardCommentUseCase.java b/src/main/java/com/moing/backend/domain/boardComment/application/service/CreateBoardCommentUseCase.java index 3530d8a5..ffac8705 100644 --- a/src/main/java/com/moing/backend/domain/boardComment/application/service/CreateBoardCommentUseCase.java +++ b/src/main/java/com/moing/backend/domain/boardComment/application/service/CreateBoardCommentUseCase.java @@ -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; @@ -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()); } } diff --git a/src/main/java/com/moing/backend/domain/boardComment/application/service/DeleteBoardCommentUseCase.java b/src/main/java/com/moing/backend/domain/boardComment/application/service/DeleteBoardCommentUseCase.java index 0937123d..7c5a4611 100644 --- a/src/main/java/com/moing/backend/domain/boardComment/application/service/DeleteBoardCommentUseCase.java +++ b/src/main/java/com/moing/backend/domain/boardComment/application/service/DeleteBoardCommentUseCase.java @@ -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(); diff --git a/src/main/java/com/moing/backend/domain/boardComment/application/service/GetBoardCommentUseCase.java b/src/main/java/com/moing/backend/domain/boardComment/application/service/GetBoardCommentUseCase.java index a3163427..d34816cd 100644 --- a/src/main/java/com/moing/backend/domain/boardComment/application/service/GetBoardCommentUseCase.java +++ b/src/main/java/com/moing/backend/domain/boardComment/application/service/GetBoardCommentUseCase.java @@ -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; @@ -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()); } } diff --git a/src/main/java/com/moing/backend/domain/boardComment/domain/entity/BoardComment.java b/src/main/java/com/moing/backend/domain/boardComment/domain/entity/BoardComment.java index 7edf67cb..6a4092d4 100644 --- a/src/main/java/com/moing/backend/domain/boardComment/domain/entity/BoardComment.java +++ b/src/main/java/com/moing/backend/domain/boardComment/domain/entity/BoardComment.java @@ -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; @@ -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; @@ -34,8 +30,6 @@ public class BoardComment extends BaseTimeEntity { @JoinColumn(name = "board_id") private Board board; - private boolean isLeader; /*작성자 소모임장유무*/ - /** * 연관관계 매핑 */ @@ -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; } - } diff --git a/src/main/java/com/moing/backend/domain/boardComment/domain/repository/BoardCommentCustomRepository.java b/src/main/java/com/moing/backend/domain/boardComment/domain/repository/BoardCommentCustomRepository.java index 25a70306..8040bf28 100644 --- a/src/main/java/com/moing/backend/domain/boardComment/domain/repository/BoardCommentCustomRepository.java +++ b/src/main/java/com/moing/backend/domain/boardComment/domain/repository/BoardCommentCustomRepository.java @@ -1,6 +1,6 @@ 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; @@ -8,7 +8,7 @@ import java.util.Optional; public interface BoardCommentCustomRepository { - GetBoardCommentResponse findBoardCommentAll(Long boardId, TeamMember teamMember); + GetCommentResponse findBoardCommentAll(Long boardId, TeamMember teamMember); Optional> findNewUploadInfo(Long memberId, Long boardId); } diff --git a/src/main/java/com/moing/backend/domain/boardComment/domain/repository/BoardCommentCustomRepositoryImpl.java b/src/main/java/com/moing/backend/domain/boardComment/domain/repository/BoardCommentCustomRepositoryImpl.java index 048fa21f..413f4203 100644 --- a/src/main/java/com/moing/backend/domain/boardComment/domain/repository/BoardCommentCustomRepositoryImpl.java +++ b/src/main/java/com/moing/backend/domain/boardComment/domain/repository/BoardCommentCustomRepositoryImpl.java @@ -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; @@ -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); @@ -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 diff --git a/src/main/java/com/moing/backend/domain/boardComment/domain/repository/BoardCommentRepository.java b/src/main/java/com/moing/backend/domain/boardComment/domain/repository/BoardCommentRepository.java index 8ccec194..99a7b2a3 100644 --- a/src/main/java/com/moing/backend/domain/boardComment/domain/repository/BoardCommentRepository.java +++ b/src/main/java/com/moing/backend/domain/boardComment/domain/repository/BoardCommentRepository.java @@ -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; diff --git a/src/main/java/com/moing/backend/domain/boardComment/domain/service/BoardCommentDeleteService.java b/src/main/java/com/moing/backend/domain/boardComment/domain/service/BoardCommentDeleteService.java index c3bd102f..63e55f09 100644 --- a/src/main/java/com/moing/backend/domain/boardComment/domain/service/BoardCommentDeleteService.java +++ b/src/main/java/com/moing/backend/domain/boardComment/domain/service/BoardCommentDeleteService.java @@ -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 { private final BoardCommentRepository boardCommentRepository; - public void deleteBoardComment(BoardComment boardComment){ + @Override + public void deleteComment(BoardComment boardComment){ this.boardCommentRepository.delete(boardComment); } + } diff --git a/src/main/java/com/moing/backend/domain/boardComment/domain/service/BoardCommentGetService.java b/src/main/java/com/moing/backend/domain/boardComment/domain/service/BoardCommentGetService.java index 28023ab0..1f2eaea0 100644 --- a/src/main/java/com/moing/backend/domain/boardComment/domain/service/BoardCommentGetService.java +++ b/src/main/java/com/moing/backend/domain/boardComment/domain/service/BoardCommentGetService.java @@ -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; @@ -16,18 +17,21 @@ @DomainService @Transactional @RequiredArgsConstructor -public class BoardCommentGetService { +public class BoardCommentGetService implements CommentGetService { 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> getNewUploadInfo(Long memberId, Long boardId) { return boardCommentRepository.findNewUploadInfo(memberId, boardId); } diff --git a/src/main/java/com/moing/backend/domain/boardComment/domain/service/BoardCommentSaveService.java b/src/main/java/com/moing/backend/domain/boardComment/domain/service/BoardCommentSaveService.java index 48b634aa..f4ac6d04 100644 --- a/src/main/java/com/moing/backend/domain/boardComment/domain/service/BoardCommentSaveService.java +++ b/src/main/java/com/moing/backend/domain/boardComment/domain/service/BoardCommentSaveService.java @@ -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 { private final BoardCommentRepository boardCommentRepository; - public BoardComment saveBoardComment(BoardComment boardComment){ + @Override + public BoardComment saveComment(BoardComment boardComment){ return this.boardCommentRepository.save(boardComment); } } diff --git a/src/main/java/com/moing/backend/domain/boardComment/presentattion/BoardCommentController.java b/src/main/java/com/moing/backend/domain/boardComment/presentattion/BoardCommentController.java index 506d9250..501f0cfd 100644 --- a/src/main/java/com/moing/backend/domain/boardComment/presentattion/BoardCommentController.java +++ b/src/main/java/com/moing/backend/domain/boardComment/presentattion/BoardCommentController.java @@ -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; @@ -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 @@ -34,11 +33,11 @@ public class BoardCommentController { * 작성자 : 김민수 */ @PostMapping - public ResponseEntity> 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> 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))); } /** @@ -52,7 +51,7 @@ public ResponseEntity 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())); } @@ -62,9 +61,9 @@ public ResponseEntity deleteBoardComment(@AuthenticationPrincip * 작성자 : 김민수 */ @GetMapping - public ResponseEntity> 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> 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))); } } diff --git a/src/main/java/com/moing/backend/domain/boardComment/application/dto/request/CreateBoardCommentRequest.java b/src/main/java/com/moing/backend/domain/comment/application/dto/request/CreateCommentRequest.java similarity index 79% rename from src/main/java/com/moing/backend/domain/boardComment/application/dto/request/CreateBoardCommentRequest.java rename to src/main/java/com/moing/backend/domain/comment/application/dto/request/CreateCommentRequest.java index 9cc0841d..84d79633 100644 --- a/src/main/java/com/moing/backend/domain/boardComment/application/dto/request/CreateBoardCommentRequest.java +++ b/src/main/java/com/moing/backend/domain/comment/application/dto/request/CreateCommentRequest.java @@ -1,4 +1,4 @@ -package com.moing.backend.domain.boardComment.application.dto.request; +package com.moing.backend.domain.comment.application.dto.request; import lombok.AllArgsConstructor; import lombok.Builder; @@ -12,7 +12,7 @@ @Builder @NoArgsConstructor @Getter -public class CreateBoardCommentRequest { +public class CreateCommentRequest { @NotBlank(message = "content 을 입력해 주세요.") @Size(min = 0, max = 300, message = "댓글 글자수를 초과했습니다.") diff --git a/src/main/java/com/moing/backend/domain/boardComment/application/dto/response/CommentBlocks.java b/src/main/java/com/moing/backend/domain/comment/application/dto/response/CommentBlocks.java similarity index 78% rename from src/main/java/com/moing/backend/domain/boardComment/application/dto/response/CommentBlocks.java rename to src/main/java/com/moing/backend/domain/comment/application/dto/response/CommentBlocks.java index af02defe..40164051 100644 --- a/src/main/java/com/moing/backend/domain/boardComment/application/dto/response/CommentBlocks.java +++ b/src/main/java/com/moing/backend/domain/comment/application/dto/response/CommentBlocks.java @@ -1,4 +1,4 @@ -package com.moing.backend.domain.boardComment.application.dto.response; +package com.moing.backend.domain.comment.application.dto.response; import com.querydsl.core.annotations.QueryProjection; import lombok.AllArgsConstructor; @@ -13,7 +13,7 @@ @AllArgsConstructor public class CommentBlocks { - private Long boardCommentId; + private Long commentId; private String content; @@ -32,8 +32,8 @@ public class CommentBlocks { private Long makerId; @QueryProjection - public CommentBlocks(Long boardCommentId, String content, String writerNickName, Boolean writerIsLeader, String writerProfileImage, Boolean isWriter, Boolean writerIsDeleted, LocalDateTime createdDate, Long makerId) { - this.boardCommentId = boardCommentId; + public CommentBlocks(Long commentId, String content, String writerNickName, Boolean writerIsLeader, String writerProfileImage, Boolean isWriter, Boolean writerIsDeleted, LocalDateTime createdDate, Long makerId) { + this.commentId = commentId; this.writerNickName = writerNickName; this.writerIsLeader = writerIsLeader; this.writerProfileImage = writerProfileImage; diff --git a/src/main/java/com/moing/backend/domain/boardComment/application/dto/response/CreateBoardCommentResponse.java b/src/main/java/com/moing/backend/domain/comment/application/dto/response/CreateCommentResponse.java similarity index 53% rename from src/main/java/com/moing/backend/domain/boardComment/application/dto/response/CreateBoardCommentResponse.java rename to src/main/java/com/moing/backend/domain/comment/application/dto/response/CreateCommentResponse.java index 8967920c..b392489c 100644 --- a/src/main/java/com/moing/backend/domain/boardComment/application/dto/response/CreateBoardCommentResponse.java +++ b/src/main/java/com/moing/backend/domain/comment/application/dto/response/CreateCommentResponse.java @@ -1,4 +1,4 @@ -package com.moing.backend.domain.boardComment.application.dto.response; +package com.moing.backend.domain.comment.application.dto.response; import lombok.AllArgsConstructor; import lombok.Builder; @@ -9,6 +9,6 @@ @Builder @NoArgsConstructor @Getter -public class CreateBoardCommentResponse { - private Long boardCommentId; +public class CreateCommentResponse { + private Long commentId; } diff --git a/src/main/java/com/moing/backend/domain/boardComment/application/dto/response/GetBoardCommentResponse.java b/src/main/java/com/moing/backend/domain/comment/application/dto/response/GetCommentResponse.java similarity index 68% rename from src/main/java/com/moing/backend/domain/boardComment/application/dto/response/GetBoardCommentResponse.java rename to src/main/java/com/moing/backend/domain/comment/application/dto/response/GetCommentResponse.java index 94bbbe1d..06df8937 100644 --- a/src/main/java/com/moing/backend/domain/boardComment/application/dto/response/GetBoardCommentResponse.java +++ b/src/main/java/com/moing/backend/domain/comment/application/dto/response/GetCommentResponse.java @@ -1,4 +1,4 @@ -package com.moing.backend.domain.boardComment.application.dto.response; +package com.moing.backend.domain.comment.application.dto.response; import lombok.AllArgsConstructor; import lombok.Builder; @@ -11,6 +11,6 @@ @Builder @NoArgsConstructor @Getter -public class GetBoardCommentResponse { +public class GetCommentResponse { private List commentBlocks; } diff --git a/src/main/java/com/moing/backend/domain/comment/domain/entity/Comment.java b/src/main/java/com/moing/backend/domain/comment/domain/entity/Comment.java new file mode 100644 index 00000000..5410bf33 --- /dev/null +++ b/src/main/java/com/moing/backend/domain/comment/domain/entity/Comment.java @@ -0,0 +1,24 @@ +package com.moing.backend.domain.comment.domain.entity; + +import com.moing.backend.global.entity.BaseTimeEntity; +import lombok.Getter; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +import javax.persistence.Column; +import javax.persistence.EntityListeners; +import javax.persistence.MappedSuperclass; + +@Getter +@MappedSuperclass +@EntityListeners(AuditingEntityListener.class) +public class Comment extends BaseTimeEntity { + + @Column(nullable = false, length = 300) + protected String content; + + protected boolean isLeader; /*작성자 소모임장유무*/ + public void updateContent(String content) { + this.content = content; + } + +} \ No newline at end of file diff --git a/src/main/java/com/moing/backend/domain/comment/domain/service/CommentDeleteService.java b/src/main/java/com/moing/backend/domain/comment/domain/service/CommentDeleteService.java new file mode 100644 index 00000000..1bd99c90 --- /dev/null +++ b/src/main/java/com/moing/backend/domain/comment/domain/service/CommentDeleteService.java @@ -0,0 +1,5 @@ +package com.moing.backend.domain.comment.domain.service; + +public interface CommentDeleteService { + void deleteComment(T comment); +} diff --git a/src/main/java/com/moing/backend/domain/comment/domain/service/CommentGetService.java b/src/main/java/com/moing/backend/domain/comment/domain/service/CommentGetService.java new file mode 100644 index 00000000..3f6cb854 --- /dev/null +++ b/src/main/java/com/moing/backend/domain/comment/domain/service/CommentGetService.java @@ -0,0 +1,14 @@ +package com.moing.backend.domain.comment.domain.service; + +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 CommentGetService { + T getComment(Long commentId); + GetCommentResponse getCommentAll(Long boardId, TeamMember teamMember); + Optional> getNewUploadInfo(Long memberId, Long boardId); +} diff --git a/src/main/java/com/moing/backend/domain/comment/domain/service/CommentSaveService.java b/src/main/java/com/moing/backend/domain/comment/domain/service/CommentSaveService.java new file mode 100644 index 00000000..b0a73f8b --- /dev/null +++ b/src/main/java/com/moing/backend/domain/comment/domain/service/CommentSaveService.java @@ -0,0 +1,5 @@ +package com.moing.backend.domain.comment.domain.service; + +public interface CommentSaveService { + T saveComment(T comment); +} diff --git a/src/main/java/com/moing/backend/domain/mission/application/dto/res/GatherRepeatMissionRes.java b/src/main/java/com/moing/backend/domain/mission/application/dto/res/GatherRepeatMissionRes.java index 993fd70e..1859d7d1 100644 --- a/src/main/java/com/moing/backend/domain/mission/application/dto/res/GatherRepeatMissionRes.java +++ b/src/main/java/com/moing/backend/domain/mission/application/dto/res/GatherRepeatMissionRes.java @@ -4,6 +4,8 @@ import lombok.Builder; import lombok.Getter; +import java.util.List; + @Getter @Builder @AllArgsConstructor @@ -16,6 +18,8 @@ public class GatherRepeatMissionRes { private String totalNum; private String doneNum; private String status; + private String donePeople; + private String totalPeople; } diff --git a/src/main/java/com/moing/backend/domain/mission/application/dto/res/GatherSingleMissionRes.java b/src/main/java/com/moing/backend/domain/mission/application/dto/res/GatherSingleMissionRes.java index 0b173365..27b6a46e 100644 --- a/src/main/java/com/moing/backend/domain/mission/application/dto/res/GatherSingleMissionRes.java +++ b/src/main/java/com/moing/backend/domain/mission/application/dto/res/GatherSingleMissionRes.java @@ -3,9 +3,11 @@ import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; +import lombok.ToString; @Getter @Builder +@ToString @AllArgsConstructor public class GatherSingleMissionRes { private Long missionId; @@ -14,6 +16,16 @@ public class GatherSingleMissionRes { private String missionTitle; private String dueTo; private String status; + private String done; + private String total; - + public GatherSingleMissionRes(Long missionId, Long teamId, String teamName, String missionTitle, String dueTo, String status, String total) { + this.missionId = missionId; + this.teamId = teamId; + this.teamName = teamName; + this.missionTitle = missionTitle; + this.dueTo = dueTo; + this.status = status; + this.total = total; + } } diff --git a/src/main/java/com/moing/backend/domain/mission/application/service/MissionCreateUseCase.java b/src/main/java/com/moing/backend/domain/mission/application/service/MissionCreateUseCase.java index 4f2d2a33..c4d223ec 100644 --- a/src/main/java/com/moing/backend/domain/mission/application/service/MissionCreateUseCase.java +++ b/src/main/java/com/moing/backend/domain/mission/application/service/MissionCreateUseCase.java @@ -49,7 +49,7 @@ public MissionCreateRes createMission(String socialId, Long teamId, MissionReq m throw new NoAccessCreateMission(); // 반복미션은 최대 2개 생성 가능 } else if (missionQueryService.isAbleCreateRepeatMission(team.getTeamId())) { - throw new NoAccessCreateMission(); + throw new NoMoreCreateMission(); } // 반복미션 유예 해제 mission.updateStatus(MissionStatus.ONGOING); diff --git a/src/main/java/com/moing/backend/domain/mission/application/service/MissionRemindAlarmUseCase.java b/src/main/java/com/moing/backend/domain/mission/application/service/MissionRemindAlarmUseCase.java index 5bcfa309..2a43ef79 100644 --- a/src/main/java/com/moing/backend/domain/mission/application/service/MissionRemindAlarmUseCase.java +++ b/src/main/java/com/moing/backend/domain/mission/application/service/MissionRemindAlarmUseCase.java @@ -12,7 +12,6 @@ import com.moing.backend.global.config.fcm.dto.request.MultiRequest; import com.moing.backend.global.config.fcm.service.MultiMessageSender; import lombok.RequiredArgsConstructor; -import org.springframework.context.ApplicationEventPublisher; import org.springframework.stereotype.Service; import javax.transaction.Transactional; @@ -31,7 +30,6 @@ public class MissionRemindAlarmUseCase { private final MissionArchiveScheduleQueryService missionArchiveScheduleQueryService; private final MissionQueryService missionQueryService; - private final ApplicationEventPublisher eventPublisher; private final MultiMessageSender multiMessageSender; private final SaveMultiAlarmHistoryUseCase saveMultiAlarmHistoryUseCase; @@ -39,7 +37,7 @@ public class MissionRemindAlarmUseCase { String REMIND_NAME = "미션 리마인드"; - public Boolean sendRemindMissionAlarm() { + public void sendRemindMissionAlarm() { Random random = new Random(System.currentTimeMillis()); String title = getTitle(random.nextInt(4)); @@ -50,16 +48,12 @@ public Boolean sendRemindMissionAlarm() { Optional> memberIdAndTokens = mapToMemberAndToken(remainMissionPeople); Optional> pushMemberIdAndToken = isPushMemberIdAndToken(remainMissionPeople); -// eventPublisher.publishEvent(new MultiFcmEvent(title, message, pushMemberIdAndToken, memberIdAndTokens, -// "",REMIND_NAME, AlarmType.REMIND, PagePath.MISSION_ALL_PTAH.getValue())); - if (pushMemberIdAndToken.isPresent() && !pushMemberIdAndToken.get().isEmpty()) { multiMessageSender.send(new MultiRequest(pushMemberIdAndToken.get(), title, message, "", REMIND_NAME, AlarmType.REMIND, PagePath.MISSION_ALL_PTAH.getValue())); } if (memberIdAndTokens.isPresent() && !memberIdAndTokens.get().isEmpty()) { saveMultiAlarmHistoryUseCase.saveAlarmHistories(AlarmHistoryMapper.getMemberIds(memberIdAndTokens.get()),"",title,message,REMIND_NAME, AlarmType.REMIND, PagePath.MISSION_ALL_PTAH.getValue()); } - return true; } @@ -137,7 +131,7 @@ public Boolean sendRepeatMissionRemindOnMonday() { } - public Optional> mapToMemberAndToken(List members) { + private Optional> mapToMemberAndToken(List members) { return Optional.of(members.stream() .map(member -> MemberIdAndToken.builder() .fcmToken(member.getFcmToken()) @@ -145,7 +139,7 @@ public Optional> mapToMemberAndToken(List members .build()) .collect(Collectors.toList())); } - public Optional> isPushMemberIdAndToken(List members) { + private Optional> isPushMemberIdAndToken(List members) { return Optional.of(members.stream() .map(member -> { if (member.isRemindPush() && !member.isSignOut()) { diff --git a/src/main/java/com/moing/backend/domain/mission/application/service/MissionScheduleUseCase.java b/src/main/java/com/moing/backend/domain/mission/application/service/MissionScheduleUseCase.java new file mode 100644 index 00000000..1223dba5 --- /dev/null +++ b/src/main/java/com/moing/backend/domain/mission/application/service/MissionScheduleUseCase.java @@ -0,0 +1,44 @@ +package com.moing.backend.domain.mission.application.service; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.context.annotation.Profile; +import org.springframework.scheduling.annotation.EnableAsync; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + + +@Slf4j +@Service +@Transactional +@EnableAsync +@EnableScheduling +@RequiredArgsConstructor +@Profile("prod") +public class MissionScheduleUseCase { + + private final MissionRemindAlarmUseCase missionRemindAlarmUseCase; + private final MissionUpdateUseCase missionUpdateUseCase; + + /** + * 단일 미션 마감 + * 해당 시간 미션 마감 + * 한시간 마다 실행 + */ + @Scheduled(cron = "0 1 * * * *") + public void singleMissionEndRoutine() { + missionUpdateUseCase.terminateMissionByAdmin(); + } + + /** + * 리마인드 알림 + * 인증하지 않은 미션이 있는 경우 알림 + * 매일 오후 8시 + */ + @Scheduled(cron = "0 0 20 * * *") + public void MissionRemindAlarm() { + missionRemindAlarmUseCase.sendRemindMissionAlarm(); + } +} \ No newline at end of file diff --git a/src/main/java/com/moing/backend/domain/mission/application/service/MissionTerminationUseCase.java b/src/main/java/com/moing/backend/domain/mission/application/service/MissionTerminationUseCase.java deleted file mode 100644 index 243582d5..00000000 --- a/src/main/java/com/moing/backend/domain/mission/application/service/MissionTerminationUseCase.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.moing.backend.domain.mission.application.service; - -import com.moing.backend.domain.member.domain.service.MemberGetService; -import com.moing.backend.domain.mission.domain.entity.Mission; -import com.moing.backend.domain.mission.domain.entity.constant.MissionStatus; -import com.moing.backend.domain.mission.domain.service.MissionQueryService; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.util.List; - -@Service -@Transactional -@RequiredArgsConstructor -public class MissionTerminationUseCase { - - private final MemberGetService memberGetService; - private final MissionQueryService missionQueryService; - - // 스케쥴러에서 호출 - public void terminateMission() { - - List missionByDueTo = missionQueryService.findMissionByDueTo(); - - missionByDueTo.stream().forEach( - // 미션 종료 처리 - mission -> mission.updateStatus(MissionStatus.END) - - ); - } - - // 미션 점수 반영 -> MissionState - - - - // MissionState 조회 해서 미션 점수 현황조회 - - public void getMissionScoreStatus() { - - } - - // 팀별 점수 반영 - public void updateMissionScore() { - - } - -} diff --git a/src/main/java/com/moing/backend/domain/mission/application/service/MissionUpdateUseCase.java b/src/main/java/com/moing/backend/domain/mission/application/service/MissionUpdateUseCase.java index 37a42829..6e3f6bc6 100644 --- a/src/main/java/com/moing/backend/domain/mission/application/service/MissionUpdateUseCase.java +++ b/src/main/java/com/moing/backend/domain/mission/application/service/MissionUpdateUseCase.java @@ -10,8 +10,6 @@ import com.moing.backend.domain.mission.domain.entity.constant.MissionStatus; import com.moing.backend.domain.mission.domain.service.MissionQueryService; import com.moing.backend.domain.mission.domain.service.MissionSaveService; -import com.moing.backend.domain.mission.exception.NoAccessCreateMission; -import com.moing.backend.domain.mission.exception.NoAccessDeleteMission; import com.moing.backend.domain.mission.exception.NoAccessUpdateMission; import com.moing.backend.domain.team.domain.entity.Team; import lombok.RequiredArgsConstructor; @@ -19,6 +17,7 @@ import org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; +import java.util.List; @Service @Transactional @@ -31,17 +30,12 @@ public class MissionUpdateUseCase { public MissionCreateRes updateMission(String userSocialId, Long missionId, MissionReq missionReq) { - Member member = memberGetService.getMemberBySocialId(userSocialId); Mission mission = missionQueryService.findMissionById(missionId); Team team = mission.getTeam(); Long memberId = member.getMemberId(); - /** - * 미션 생성자 확인 - */ - if (!((memberId.equals(mission.getMakerId())) || memberId.equals(team.getLeaderId())) ) { throw new NoAccessUpdateMission(); } @@ -51,11 +45,11 @@ public MissionCreateRes updateMission(String userSocialId, Long missionId, Missi } - public MissionReadRes updateMissionStatus(String userSocialId, Long missionId) { - + public MissionReadRes terminateMissionByUser(String userSocialId, Long missionId) { Member member = memberGetService.getMemberBySocialId(userSocialId); Long memberId = member.getMemberId(); + Mission findMission = missionQueryService.findMissionById(missionId); Team team = findMission.getTeam(); @@ -69,4 +63,10 @@ public MissionReadRes updateMissionStatus(String userSocialId, Long missionId) { return MissionMapper.mapToMissionReadRes(findMission,member); } + + public void terminateMissionByAdmin() { + missionQueryService.findMissionByDueTo().stream().forEach( + mission -> mission.updateStatus(MissionStatus.END) + ); + } } diff --git a/src/main/java/com/moing/backend/domain/mission/domain/entity/Mission.java b/src/main/java/com/moing/backend/domain/mission/domain/entity/Mission.java index c609fdff..d5d6c80f 100644 --- a/src/main/java/com/moing/backend/domain/mission/domain/entity/Mission.java +++ b/src/main/java/com/moing/backend/domain/mission/domain/entity/Mission.java @@ -6,7 +6,6 @@ import com.moing.backend.domain.mission.domain.entity.constant.MissionWay; import com.moing.backend.domain.missionArchive.domain.entity.MissionArchive; import com.moing.backend.domain.missionRead.domain.entity.MissionRead; -import com.moing.backend.domain.missionState.domain.entity.MissionState; import com.moing.backend.domain.team.domain.entity.Team; import com.moing.backend.global.entity.BaseTimeEntity; import lombok.AllArgsConstructor; @@ -56,9 +55,6 @@ public class Mission extends BaseTimeEntity { @OneToMany(mappedBy = "mission") List missionArchiveList = new ArrayList<>(); - - @OneToMany(mappedBy = "mission") - List missionStateList = new ArrayList<>(); @OneToMany(mappedBy = "mission") List missionReads=new ArrayList<>(); diff --git a/src/main/java/com/moing/backend/domain/mission/domain/repository/MissionCustomRepositoryImpl.java b/src/main/java/com/moing/backend/domain/mission/domain/repository/MissionCustomRepositoryImpl.java index cf525072..1baa1d3a 100644 --- a/src/main/java/com/moing/backend/domain/mission/domain/repository/MissionCustomRepositoryImpl.java +++ b/src/main/java/com/moing/backend/domain/mission/domain/repository/MissionCustomRepositoryImpl.java @@ -10,21 +10,24 @@ import com.moing.backend.domain.mission.domain.entity.constant.MissionType; import com.querydsl.core.types.Projections; import com.querydsl.core.types.dsl.BooleanExpression; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.jpa.JPAExpressions; +import com.querydsl.jpa.JPQLQuery; import com.querydsl.jpa.impl.JPAQueryFactory; import javax.persistence.EntityManager; + import java.time.DayOfWeek; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.temporal.TemporalAdjusters; -import java.util.List; -import java.util.Optional; +import java.util.*; import static com.moing.backend.domain.mission.domain.entity.QMission.mission; import static com.moing.backend.domain.missionArchive.domain.entity.QMissionArchive.missionArchive; -import static com.moing.backend.domain.missionState.domain.entity.QMissionState.missionState; import static com.moing.backend.domain.teamMember.domain.entity.QTeamMember.teamMember; +import static com.querydsl.jpa.JPAExpressions.select; public class MissionCustomRepositoryImpl implements MissionCustomRepository{ @@ -48,7 +51,7 @@ public Long findMissionsCountByTeam(Long teamId) { @Override public Optional> findRepeatMissionByMemberId(Long memberId,Listteams) { - BooleanExpression dateInRange = createRepeatTypeConditionByState(); + BooleanExpression dateInRange = createRepeatTypeConditionByArchive(); return Optional.ofNullable(queryFactory .select(Projections.constructor(GatherRepeatMissionRes.class, @@ -57,13 +60,26 @@ public Optional> findRepeatMissionByMemberId(Long m mission.team.name, mission.title, mission.number.stringValue(), - missionState.count().stringValue(), - mission.status.stringValue() + missionArchive.count.max().coalesce(0L).stringValue(), + missionArchive.status.coalesce(mission.status).stringValue(), + + JPAExpressions + .select(teamMember.member.countDistinct().stringValue()) + .from(teamMember) + .where( + teamMember.team.eq(mission.team), + teamMember.member.memberId.in(RepeatMissionDonePeopleByWeek(mission.id)) + .or(teamMember.member.memberId.in(RepeatMissionDonePeopleByDay(mission.id))), + teamMember.isDeleted.ne(Boolean.TRUE) + ), + + mission.team.numOfMember.stringValue() + )) .from(mission) - .leftJoin(missionState) - .on(missionState.mission.eq(mission), - missionState.member.memberId.eq(memberId), + .leftJoin(missionArchive) + .on(missionArchive.mission.eq(mission), + missionArchive.member.memberId.eq(memberId), dateInRange ) .where( @@ -72,24 +88,51 @@ public Optional> findRepeatMissionByMemberId(Long m mission.type.eq(MissionType.REPEAT) ) - .groupBy(mission.id,mission.number) - .having(missionState.count().lt(mission.number) - ) // HAVING 절을 사용하여 조건 적용 - .orderBy(missionState.count().desc()) + .groupBy(mission) + .orderBy(mission.createdDate.desc()) .fetch()); } + private JPQLQuery RepeatMissionDonePeopleByDay(NumberPath missionId) { + + BooleanExpression dateInRange = createRepeatTypeConditionByArchive(); + BooleanExpression hasAlreadyVerifiedToday = hasAlreadyVerifiedToday(); + + return + select(missionArchive.member.memberId) + .from(missionArchive) + .where( + missionArchive.mission.id.eq(missionId), + (missionArchive.mission.type.eq(MissionType.REPEAT).and(dateInRange).and(hasAlreadyVerifiedToday)) + ).distinct(); + } + + private JPQLQuery RepeatMissionDonePeopleByWeek(NumberPath missionId) { + + BooleanExpression dateInRange = createRepeatTypeConditionByArchive(); + + return select(missionArchive.member.memberId) + .from(missionArchive) + .where( + missionArchive.mission.id.eq(missionId), + (missionArchive.mission.type.eq(MissionType.REPEAT).and(dateInRange)) + ) + .groupBy(missionArchive.mission.number, missionArchive.count) + .having( + missionArchive.count.max().goe(missionArchive.mission.number)) + .distinct(); + + } + @Override public Optional> findMissionByDueTo() { - LocalDateTime now = LocalDateTime.now(); - return Optional.ofNullable(queryFactory .selectFrom(mission) .where( - mission.dueTo.before(now), mission.status.eq(MissionStatus.WAIT).or(mission.status.eq(MissionStatus.ONGOING)), + mission.dueTo.before(LocalDateTime.now()), mission.type.eq(MissionType.ONCE) ).fetch()); } @@ -135,6 +178,7 @@ public Optional> findRepeatMissionByStatus(MissionStatus missionSt @Override public Optional> findSingleMissionByMemberId(Long memberId, List teams) { + BooleanExpression dateInRange = createRepeatTypeConditionByArchive(); return Optional.ofNullable(queryFactory .select(Projections.constructor(GatherSingleMissionRes.class, @@ -143,18 +187,29 @@ public Optional> findSingleMissionByMemberId(Long m mission.team.name, mission.title, mission.dueTo.stringValue(), - mission.status.stringValue() + missionArchive.status.coalesce(mission.status).stringValue(), + + JPAExpressions + .select(missionArchive.member.count().stringValue()) + .from(missionArchive) + .where( + missionArchive.mission.id.eq(mission.id), + missionArchive.mission.type.eq(MissionType.REPEAT).and(dateInRange) + .or(missionArchive.mission.type.eq(MissionType.ONCE)) + ), + + mission.team.numOfMember.stringValue() )) .from(mission) - .leftJoin(missionState).on( - mission.eq(missionState.mission), - missionState.member.memberId.eq(memberId) - ) + .leftJoin(missionArchive) + .on( + mission.eq(missionArchive.mission), + missionArchive.member.memberId.eq(memberId) + ) .where( mission.team.teamId.in(teams), mission.status.eq(MissionStatus.ONGOING).or(mission.status.eq(MissionStatus.WAIT)), - mission.type.eq(MissionType.ONCE), - missionState.id.isNull() + mission.type.eq(MissionType.ONCE) ) .orderBy(mission.dueTo.asc()) .fetch()); @@ -171,6 +226,8 @@ public boolean findRepeatMissionsByTeamId(Long teamId) { ).fetchCount() > 2; } + + @Override public Optional findByIds(Long memberId, Long missionId) { @@ -270,34 +327,25 @@ public Long getYesterdayRepeatMissions() { } + + private BooleanExpression createRepeatTypeConditionByArchive() { LocalDate now = LocalDate.now(); DayOfWeek firstDayOfWeek = DayOfWeek.MONDAY; LocalDate startOfWeek = now.with(TemporalAdjusters.previousOrSame(firstDayOfWeek)); LocalDate endOfWeek = startOfWeek.plusDays(6); - // MissionType.REPEAT 인 경우의 추가적인 날짜 범위 조건 -// BooleanExpression isRepeatType = missionArchive.mission.type.eq(MissionType.REPEAT); - BooleanExpression dateInRange = missionArchive.createdDate.goe(startOfWeek.atStartOfDay()) + return missionArchive.createdDate.goe(startOfWeek.atStartOfDay()) .and(missionArchive.createdDate.loe(endOfWeek.atStartOfDay().plusDays(1).minusNanos(1))); - // 조건이 MissionType.REPEAT 인 경우에만 날짜 범위 조건 적용 - return dateInRange.and(dateInRange); } - private BooleanExpression createRepeatTypeConditionByState() { - LocalDate now = LocalDate.now(); - DayOfWeek firstDayOfWeek = DayOfWeek.MONDAY; - LocalDate startOfWeek = now.with(TemporalAdjusters.previousOrSame(firstDayOfWeek)); - LocalDate endOfWeek = startOfWeek.plusDays(6); - - // MissionType.REPEAT 인 경우의 추가적인 날짜 범위 조건 -// BooleanExpression isRepeatType = missionArchive.mission.type.eq(MissionType.REPEAT); - BooleanExpression dateInRange = missionState.createdDate.goe(startOfWeek.atStartOfDay()) - .and(missionState.createdDate.loe(endOfWeek.atStartOfDay().plusDays(1).minusNanos(1))); + private BooleanExpression hasAlreadyVerifiedToday() { + LocalDateTime today = LocalDateTime.now(); + LocalDateTime startOfToday = today.withHour(0).withMinute(0).withSecond(0).withNano(0); + LocalDateTime endOfToday = today.withHour(23).withMinute(59).withSecond(59).withNano(999999999); - // 조건이 MissionType.REPEAT 인 경우에만 날짜 범위 조건 적용 - return dateInRange.and(dateInRange); + return missionArchive.createdDate.between(startOfToday, endOfToday); } diff --git a/src/main/java/com/moing/backend/domain/mission/presentation/MissionController.java b/src/main/java/com/moing/backend/domain/mission/presentation/MissionController.java index f041b45b..56dccc52 100644 --- a/src/main/java/com/moing/backend/domain/mission/presentation/MissionController.java +++ b/src/main/java/com/moing/backend/domain/mission/presentation/MissionController.java @@ -20,14 +20,11 @@ @RequestMapping("/api/team/{teamId}/missions") public class MissionController { - private final MissionCreateUseCase missionCreateUseCase; private final MissionReadUseCase missionReadUseCase; private final MissionUpdateUseCase missionUpdateUseCase; private final MissionDeleteUseCase missionDeleteUseCase; -// private final MissionRemindAlarmUseCase missionRemindAlarmUseCase; - /** * 미션 조회 * [GET] {teamId}/missions/{missionId} @@ -39,8 +36,6 @@ public ResponseEntity> getMission(@Authenticatio return ResponseEntity.ok(SuccessResponse.create(READ_MISSION_SUCCESS.getMessage(), this.missionReadUseCase.getMission(user.getSocialId(),missionId))); } - - /** * 미션 생성 * [POST] {teamId}/missions @@ -68,8 +63,8 @@ public ResponseEntity> updateMission(@Authenti * 작성자 : 정승연 */ @PutMapping("/{missionId}/end") - public ResponseEntity> endMission(@AuthenticationPrincipal User user,@PathVariable("teamId") Long teamId,@PathVariable Long missionId) { - return ResponseEntity.ok(SuccessResponse.create(END_MISSION_SUCCESS.getMessage(), this.missionUpdateUseCase.updateMissionStatus(user.getSocialId(),missionId))); + public ResponseEntity> terminateMission(@AuthenticationPrincipal User user, @PathVariable("teamId") Long teamId, @PathVariable Long missionId) { + return ResponseEntity.ok(SuccessResponse.create(END_MISSION_SUCCESS.getMessage(), this.missionUpdateUseCase.terminateMissionByUser(user.getSocialId(),missionId))); } /** @@ -78,7 +73,7 @@ public ResponseEntity> endMission(@Authenticatio * 작성자 : 정승연 */ @DeleteMapping("/{missionId}") - public ResponseEntity> deleteMission(@AuthenticationPrincipal User user,@PathVariable Long missionId) { + public ResponseEntity> deleteMission(@AuthenticationPrincipal User user,@PathVariable("teamId") Long teamId,@PathVariable Long missionId) { return ResponseEntity.ok(SuccessResponse.create(DELETE_MISSION_SUCCESS.getMessage(), this.missionDeleteUseCase.deleteMission(user.getSocialId(),missionId))); } @@ -92,6 +87,7 @@ public ResponseEntity> deleteMission(@AuthenticationPrinci public ResponseEntity> recommendMission(@AuthenticationPrincipal User user,@PathVariable Long teamId) { return ResponseEntity.ok(SuccessResponse.create(RECOMMEND_MISSION_SUCCESS.getMessage(), this.missionReadUseCase.getTeamCategory(teamId))); } + /** * 미션 추천 * [GET] {teamId}/missions/isLeader @@ -103,10 +99,6 @@ public ResponseEntity> isLeader(@AuthenticationPrincipa return ResponseEntity.ok(SuccessResponse.create(RECOMMEND_MISSION_SUCCESS.getMessage(), this.missionCreateUseCase.getIsLeader(user.getSocialId(),teamId))); } -// @PostMapping("/remind") -// public ResponseEntity> remindAlarm(@AuthenticationPrincipal User user,@PathVariable Long teamId) { -// return ResponseEntity.ok(SuccessResponse.create(RECOMMEND_MISSION_SUCCESS.getMessage(), this.missionRemindAlarmUseCase.sendRepeatMissionRemind())); -// } /** * 미션 설명 확인 (미션 읽음 처리) @@ -124,5 +116,4 @@ public ResponseEntity> confirmMissionExplanat - } diff --git a/src/main/java/com/moing/backend/domain/missionArchive/application/dto/req/MissionArchiveReq.java b/src/main/java/com/moing/backend/domain/missionArchive/application/dto/req/MissionArchiveReq.java index a973aa29..bba83666 100644 --- a/src/main/java/com/moing/backend/domain/missionArchive/application/dto/req/MissionArchiveReq.java +++ b/src/main/java/com/moing/backend/domain/missionArchive/application/dto/req/MissionArchiveReq.java @@ -2,6 +2,7 @@ import lombok.*; +import javax.annotation.Nullable; import javax.validation.constraints.Size; @Builder @@ -10,12 +11,16 @@ public class MissionArchiveReq { private String status; + @Size(min = 1, max = 1000) private String archive; //사진일 경우 파일명, 이외에는 text,link + private String contents; + @Builder - public MissionArchiveReq(String status, String archive) { + public MissionArchiveReq(String status, String archive, String contents) { this.status = status; this.archive = archive; + this.contents = contents; } } diff --git a/src/main/java/com/moing/backend/domain/missionArchive/application/dto/res/MissionArchiveRes.java b/src/main/java/com/moing/backend/domain/missionArchive/application/dto/res/MissionArchiveRes.java index 10b73af9..871786c3 100644 --- a/src/main/java/com/moing/backend/domain/missionArchive/application/dto/res/MissionArchiveRes.java +++ b/src/main/java/com/moing/backend/domain/missionArchive/application/dto/res/MissionArchiveRes.java @@ -1,9 +1,9 @@ package com.moing.backend.domain.missionArchive.application.dto.res; -import lombok.*; - -import javax.annotation.Nullable; -import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; @AllArgsConstructor @Builder @NoArgsConstructor @@ -18,6 +18,8 @@ public class MissionArchiveRes { private Long count; private String heartStatus; private Long hearts; + private String contents; + private Long comments; public void updateCount(Long count) { this.count = count; diff --git a/src/main/java/com/moing/backend/domain/missionArchive/application/dto/res/PersonalArchiveRes.java b/src/main/java/com/moing/backend/domain/missionArchive/application/dto/res/PersonalArchiveRes.java index 47df8949..5ed6a0bb 100644 --- a/src/main/java/com/moing/backend/domain/missionArchive/application/dto/res/PersonalArchiveRes.java +++ b/src/main/java/com/moing/backend/domain/missionArchive/application/dto/res/PersonalArchiveRes.java @@ -2,6 +2,8 @@ import lombok.*; +import javax.annotation.Nullable; + @AllArgsConstructor @Builder @NoArgsConstructor @@ -24,5 +26,8 @@ public class PersonalArchiveRes { private Long makerId; + @Nullable + private String contents; + private Long comments; } diff --git a/src/main/java/com/moing/backend/domain/missionArchive/application/mapper/MissionArchiveMapper.java b/src/main/java/com/moing/backend/domain/missionArchive/application/mapper/MissionArchiveMapper.java index deac83d6..6c4b40ae 100644 --- a/src/main/java/com/moing/backend/domain/missionArchive/application/mapper/MissionArchiveMapper.java +++ b/src/main/java/com/moing/backend/domain/missionArchive/application/mapper/MissionArchiveMapper.java @@ -2,7 +2,6 @@ import com.moing.backend.domain.member.domain.entity.Member; import com.moing.backend.domain.mission.application.dto.res.FinishMissionBoardRes; -import com.moing.backend.domain.mission.application.dto.res.RepeatMissionBoardRes; import com.moing.backend.domain.mission.application.dto.res.SingleMissionBoardRes; import com.moing.backend.domain.mission.domain.entity.Mission; import com.moing.backend.domain.missionArchive.application.dto.req.MissionArchiveReq; @@ -29,6 +28,8 @@ public static MissionArchive mapToMissionArchive(MissionArchiveReq missionArchiv .member(member) .mission(mission) .heartList(new ArrayList<>()) + .contents(missionArchiveReq.getContents()) + .commentNum(0L) .build(); } @@ -50,6 +51,8 @@ public static MissionArchiveRes mapToMissionArchiveRes(MissionArchive missionArc .filter(heart -> heart.getHeartStatus() == ( MissionHeartStatus.True)) .filter(heart -> heart.getMissionArchive().equals( missionArchive))// heartStatus가 true인 요소만 필터링 .count()) + .contents(missionArchive.getContents()) + .comments(missionArchive.getCommentNum()) .build(); } @@ -84,6 +87,8 @@ public static PersonalArchiveRes mapToPersonalArchive(MissionArchive missionArch .filter(heart -> heart.getMissionArchive().equals( missionArchive))// heartStatus가 true인 요소만 필터링 .count()) .makerId(missionArchive.getMember().getMemberId()) + .contents(missionArchive.getContents()) + .comments(missionArchive.getCommentNum()) .build(); } diff --git a/src/main/java/com/moing/backend/domain/missionArchive/application/service/MissionArchiveCreateUseCase.java b/src/main/java/com/moing/backend/domain/missionArchive/application/service/MissionArchiveCreateUseCase.java index 4d4ba925..618a02c7 100644 --- a/src/main/java/com/moing/backend/domain/missionArchive/application/service/MissionArchiveCreateUseCase.java +++ b/src/main/java/com/moing/backend/domain/missionArchive/application/service/MissionArchiveCreateUseCase.java @@ -10,13 +10,9 @@ import com.moing.backend.domain.missionArchive.application.dto.res.MissionArchiveRes; import com.moing.backend.domain.missionArchive.application.mapper.MissionArchiveMapper; import com.moing.backend.domain.missionArchive.domain.entity.MissionArchive; -import com.moing.backend.domain.missionArchive.domain.service.MissionArchiveDeleteService; import com.moing.backend.domain.missionArchive.domain.service.MissionArchiveQueryService; import com.moing.backend.domain.missionArchive.domain.service.MissionArchiveSaveService; import com.moing.backend.domain.missionArchive.exception.NoMoreMissionArchiveException; -import com.moing.backend.domain.missionState.application.service.MissionStateUseCase; -import com.moing.backend.domain.missionState.domain.service.MissionStateSaveService; -import com.moing.backend.domain.missionHeart.domain.service.MissionHeartQueryService; import com.moing.backend.domain.team.domain.entity.Team; import com.moing.backend.domain.teamScore.application.service.TeamScoreUpdateUseCase; import com.moing.backend.domain.teamScore.domain.entity.ScoreStatus; @@ -36,8 +32,6 @@ public class MissionArchiveCreateUseCase { private final MissionQueryService missionQueryService; private final MemberGetService memberGetService; - private final MissionStateUseCase missionStateUseCase; - private final TeamScoreUpdateUseCase teamScoreUpdateUseCase; public MissionArchiveRes createArchive(String userSocialId, Long missionId, MissionArchiveReq missionReq) { @@ -64,8 +58,6 @@ public MissionArchiveRes createArchive(String userSocialId, Long missionId, Miss } newArchive.updateCount(missionArchiveQueryService.findMyDoneArchives(memberId, missionId) + 1); - missionStateUseCase.updateMissionState(member, mission, newArchive); - missionArchiveRes = MissionArchiveMapper.mapToMissionArchiveRes(missionArchiveSaveService.save(newArchive), memberId); } @@ -79,8 +71,6 @@ public MissionArchiveRes createArchive(String userSocialId, Long missionId, Miss } newArchive.updateCount(missionArchiveQueryService.findMyDoneArchives(memberId, missionId)+1); - missionStateUseCase.updateMissionState(member, mission, newArchive); - missionArchiveRes = MissionArchiveMapper.mapToMissionArchiveRes(missionArchiveSaveService.save(newArchive), memberId); // 인증 후 n/n명 인증 성공 리턴값 업데이트 @@ -137,4 +127,4 @@ private boolean isAbleToFinishOnceMission(Mission mission) { } -} +} \ No newline at end of file diff --git a/src/main/java/com/moing/backend/domain/missionArchive/application/service/MissionArchiveDeleteUseCase.java b/src/main/java/com/moing/backend/domain/missionArchive/application/service/MissionArchiveDeleteUseCase.java index 58ebc08d..362fec96 100644 --- a/src/main/java/com/moing/backend/domain/missionArchive/application/service/MissionArchiveDeleteUseCase.java +++ b/src/main/java/com/moing/backend/domain/missionArchive/application/service/MissionArchiveDeleteUseCase.java @@ -1,16 +1,11 @@ package com.moing.backend.domain.missionArchive.application.service; -import com.moing.backend.domain.infra.image.application.service.IssuePresignedUrlUseCase; import com.moing.backend.domain.member.domain.entity.Member; import com.moing.backend.domain.member.domain.service.MemberGetService; import com.moing.backend.domain.mission.domain.entity.Mission; -import com.moing.backend.domain.mission.domain.entity.constant.MissionStatus; import com.moing.backend.domain.mission.domain.entity.constant.MissionType; import com.moing.backend.domain.mission.domain.entity.constant.MissionWay; import com.moing.backend.domain.mission.domain.service.MissionQueryService; -import com.moing.backend.domain.missionArchive.application.dto.req.MissionArchiveReq; -import com.moing.backend.domain.missionArchive.application.dto.res.MissionArchiveRes; -import com.moing.backend.domain.missionArchive.application.mapper.MissionArchiveMapper; import com.moing.backend.domain.missionArchive.domain.entity.MissionArchive; import com.moing.backend.domain.missionArchive.domain.entity.MissionArchiveStatus; import com.moing.backend.domain.missionArchive.domain.service.MissionArchiveDeleteService; @@ -18,11 +13,6 @@ import com.moing.backend.domain.missionArchive.domain.service.MissionArchiveSaveService; import com.moing.backend.domain.missionArchive.exception.NoAccessMissionArchiveException; import com.moing.backend.domain.missionHeart.domain.service.MissionHeartQueryService; -import com.moing.backend.domain.missionState.application.service.MissionStateUseCase; -import com.moing.backend.domain.missionState.domain.entity.MissionState; -import com.moing.backend.domain.missionState.domain.service.MissionStateDeleteService; -import com.moing.backend.domain.missionState.domain.service.MissionStateQueryService; -import com.moing.backend.domain.missionState.domain.service.MissionStateSaveService; import com.moing.backend.domain.team.domain.entity.Team; import com.moing.backend.domain.teamScore.application.service.TeamScoreUpdateUseCase; import com.moing.backend.domain.teamScore.domain.entity.ScoreStatus; @@ -38,18 +28,11 @@ @RequiredArgsConstructor public class MissionArchiveDeleteUseCase { - private final MissionArchiveSaveService missionArchiveSaveService; private final MissionArchiveQueryService missionArchiveQueryService; private final MissionArchiveDeleteService missionArchiveDeleteService; - private final MissionHeartQueryService missionHeartQueryService; - private final MissionQueryService missionQueryService; private final MemberGetService memberGetService; - - private final MissionStateDeleteService missionStateDeleteService; - private final MissionStateQueryService missionStateQueryService; - private final TeamScoreUpdateUseCase teamScoreUpdateUseCase; private final UpdateUtils updateUtils; @@ -62,10 +45,8 @@ public Long deleteArchive(String userSocialId, Long missionId,Long count) { Long memberId = member.getMemberId(); Mission mission = missionQueryService.findMissionById(missionId); - Team team = mission.getTeam(); MissionArchive deleteArchive = missionArchiveQueryService.findOneMyArchive(memberId, missionId,count); - MissionState missionState = missionStateQueryService.findMissionState(member, mission); LocalDateTime createdDate = deleteArchive.getCreatedDate(); LocalDateTime today = LocalDateTime.now(); @@ -81,8 +62,6 @@ public Long deleteArchive(String userSocialId, Long missionId,Long count) { } missionArchiveDeleteService.deleteMissionArchive(deleteArchive); - missionStateDeleteService.deleteMissionState(missionState); - teamScoreUpdateUseCase.gainScoreOfArchive(mission, ScoreStatus.MINUS); return deleteArchive.getId(); diff --git a/src/main/java/com/moing/backend/domain/missionArchive/application/service/MissionArchiveUpdateUseCase.java b/src/main/java/com/moing/backend/domain/missionArchive/application/service/MissionArchiveUpdateUseCase.java index 4b459cd3..2d7222e7 100644 --- a/src/main/java/com/moing/backend/domain/missionArchive/application/service/MissionArchiveUpdateUseCase.java +++ b/src/main/java/com/moing/backend/domain/missionArchive/application/service/MissionArchiveUpdateUseCase.java @@ -1,23 +1,16 @@ package com.moing.backend.domain.missionArchive.application.service; -import com.moing.backend.domain.infra.image.application.service.IssuePresignedUrlUseCase; import com.moing.backend.domain.member.domain.entity.Member; import com.moing.backend.domain.member.domain.service.MemberGetService; import com.moing.backend.domain.mission.domain.entity.Mission; -import com.moing.backend.domain.mission.domain.entity.constant.MissionStatus; -import com.moing.backend.domain.mission.domain.entity.constant.MissionType; import com.moing.backend.domain.mission.domain.entity.constant.MissionWay; import com.moing.backend.domain.mission.domain.service.MissionQueryService; import com.moing.backend.domain.missionArchive.application.dto.req.MissionArchiveReq; import com.moing.backend.domain.missionArchive.application.dto.res.MissionArchiveRes; import com.moing.backend.domain.missionArchive.application.mapper.MissionArchiveMapper; import com.moing.backend.domain.missionArchive.domain.entity.MissionArchive; -import com.moing.backend.domain.missionArchive.domain.service.MissionArchiveDeleteService; import com.moing.backend.domain.missionArchive.domain.service.MissionArchiveQueryService; import com.moing.backend.domain.missionArchive.domain.service.MissionArchiveSaveService; -import com.moing.backend.domain.missionState.application.service.MissionStateUseCase; -import com.moing.backend.domain.missionState.domain.service.MissionStateSaveService; -import com.moing.backend.domain.missionHeart.domain.service.MissionHeartQueryService; import com.moing.backend.domain.missionArchive.exception.NoAccessMissionArchiveException; import com.moing.backend.domain.team.domain.entity.Team; import lombok.RequiredArgsConstructor; @@ -33,18 +26,11 @@ public class MissionArchiveUpdateUseCase { private final MissionArchiveSaveService missionArchiveSaveService; private final MissionArchiveQueryService missionArchiveQueryService; - private final MissionArchiveDeleteService missionArchiveDeleteService; - private final MissionHeartQueryService missionHeartQueryService; private final MissionQueryService missionQueryService; private final MemberGetService memberGetService; - private final IssuePresignedUrlUseCase getPresignedUrlUseCase; - - private final MissionStateSaveService missionStateSaveService; - private final MissionStateUseCase missionStateUseCase; - // 미션 재인증 (수정하기도 포함됨) -> 사용하지 않음 public MissionArchiveRes updateArchive(String userSocialId, Long missionId, MissionArchiveReq missionReq) { diff --git a/src/main/java/com/moing/backend/domain/missionArchive/domain/constant/MissionArchiveResponseMessage.java b/src/main/java/com/moing/backend/domain/missionArchive/domain/constant/MissionArchiveResponseMessage.java index 4be74d90..88ab1b4d 100644 --- a/src/main/java/com/moing/backend/domain/missionArchive/domain/constant/MissionArchiveResponseMessage.java +++ b/src/main/java/com/moing/backend/domain/missionArchive/domain/constant/MissionArchiveResponseMessage.java @@ -14,6 +14,7 @@ public enum MissionArchiveResponseMessage { READ_TEAM_ARCHIVE_SUCCESS("팀원 미션 인증 현황 조회를 완료 했습니다."), HEART_UPDATE_SUCCESS("미션 인증 좋아요를 성공적으로 눌렀습니다."), MISSION_ARCHIVE_PEOPLE_STATUS_SUCCESS("미션 인증 성공한 인원 상태 조회를 완료 했습니다."), + MISSION_ARCHIVE_MY_STATUS_SUCCESS("미션 인증 성공한 나의 현황 조회를 완료 했습니다."), ACTIVE_SINGLE_MISSION_SUCCESS("진행 중인 모든 한번 인증 미션 조회를 완료 했습니다."), ACTIVE_REPEAT_MISSION_SUCCESS("진행 중인 모든 반복 인증 미션 조회를 완료 했습니다."), ACTIVE_TEAM_SINGLE_MISSION_SUCCESS("진행 중인 팀별 한번 인증 미션 조회를 완료 했습니다."), diff --git a/src/main/java/com/moing/backend/domain/missionArchive/domain/entity/MissionArchive.java b/src/main/java/com/moing/backend/domain/missionArchive/domain/entity/MissionArchive.java index 9cc2a7bf..2a60411f 100644 --- a/src/main/java/com/moing/backend/domain/missionArchive/domain/entity/MissionArchive.java +++ b/src/main/java/com/moing/backend/domain/missionArchive/domain/entity/MissionArchive.java @@ -3,7 +3,6 @@ import com.moing.backend.domain.member.domain.entity.Member; import com.moing.backend.domain.mission.domain.entity.Mission; -import com.moing.backend.domain.mission.domain.entity.constant.MissionStatus; import com.moing.backend.domain.missionArchive.application.dto.req.MissionArchiveReq; import com.moing.backend.domain.missionHeart.domain.entity.MissionHeart; import com.moing.backend.global.entity.BaseTimeEntity; @@ -39,15 +38,19 @@ public class MissionArchive extends BaseTimeEntity { // 1회 미션을 저장 @Enumerated(value = EnumType.STRING) private MissionArchiveStatus status; - @Column(nullable = false, columnDefinition="TEXT", length = 4000) private String archive; //링크, 글, 사진 뭐든 가능 private Long count; // 횟수 + @Column(nullable = true, columnDefinition="TEXT", length = 1000) + private String contents; + @OneToMany(mappedBy = "missionArchive", cascade = CascadeType.REMOVE) private List heartList = new ArrayList<>(); + //반정규화 + private Long commentNum; public void updateArchive(MissionArchiveReq missionArchiveReq) { this.archive = missionArchiveReq.getArchive(); @@ -58,6 +61,13 @@ public void updateCount(Long count) { this.count = count; } + public void incrComNum() { + this.commentNum++; + } + + public void decrComNum() { + this.commentNum--; + } } diff --git a/src/main/java/com/moing/backend/domain/missionArchive/domain/repository/MissionArchiveCustomRepositoryImpl.java b/src/main/java/com/moing/backend/domain/missionArchive/domain/repository/MissionArchiveCustomRepositoryImpl.java index 9e016dfe..b222e0f2 100644 --- a/src/main/java/com/moing/backend/domain/missionArchive/domain/repository/MissionArchiveCustomRepositoryImpl.java +++ b/src/main/java/com/moing/backend/domain/missionArchive/domain/repository/MissionArchiveCustomRepositoryImpl.java @@ -37,7 +37,7 @@ import static com.moing.backend.domain.mission.domain.entity.QMission.mission; import static com.moing.backend.domain.missionArchive.domain.entity.QMissionArchive.missionArchive; -import static com.moing.backend.domain.missionState.domain.entity.QMissionState.missionState; +//import static com.moing.backend.domain.missionState.domain.entity.QMissionState.missionState; import static com.moing.backend.domain.teamMember.domain.entity.QTeamMember.teamMember; @Slf4j @@ -68,13 +68,13 @@ public Optional> findSingleMissionInComplete(Long me .from(mission) .where(mission.notIn (JPAExpressions - .select(missionState.mission) - .from(missionState) - .where(missionState.member.memberId.eq(memberId), - missionState.mission.team.teamId.eq(teamId), - missionState.mission.type.eq(MissionType.ONCE), - missionState.mission.status.eq(MissionStatus.SUCCESS) - .or(missionState.mission.status.eq(MissionStatus.ONGOING)) + .select(missionArchive.mission) + .from(missionArchive) + .where(missionArchive.member.memberId.eq(memberId), + missionArchive.mission.team.teamId.eq(teamId), + missionArchive.mission.type.eq(MissionType.ONCE), + missionArchive.mission.status.eq(MissionStatus.SUCCESS) + .or(missionArchive.mission.status.eq(MissionStatus.ONGOING)) )), mission.type.eq(MissionType.ONCE), mission.status.eq(MissionStatus.ONGOING).or(mission.status.eq(MissionStatus.WAIT)), @@ -269,16 +269,16 @@ public Optional> findRepeatMissionArchivesByMemberId mission.id, mission.title, // missionState.count().coalesce(0L).as("done"), - missionState.count(), + missionArchive.count(), mission.number, mission.way.stringValue(), mission.status.stringValue(), isReadExpression.as("isRead") )) .from(mission) - .leftJoin(missionState) - .on(missionState.mission.eq(mission), - missionState.member.memberId.eq(memberId), + .leftJoin(missionArchive) + .on(missionArchive.mission.eq(mission), + missionArchive.member.memberId.eq(memberId), dateInRange ) .where( @@ -288,7 +288,7 @@ public Optional> findRepeatMissionArchivesByMemberId ) .groupBy(mission.id,mission.number) // .having(missionState.count().lt(mission.number)) // HAVING 절을 사용하여 조건 적용 - .orderBy(missionState.count().desc()) + .orderBy(missionArchive.count().desc()) .fetch()); } @@ -401,8 +401,8 @@ private BooleanExpression createRepeatTypeConditionByState() { LocalDate startOfWeek = now.with(TemporalAdjusters.previousOrSame(firstDayOfWeek)); LocalDate endOfWeek = startOfWeek.plusDays(6); - BooleanExpression dateInRange = missionState.createdDate.goe(startOfWeek.atStartOfDay()) - .and(missionState.createdDate.loe(endOfWeek.atStartOfDay().plusDays(1).minusNanos(1))); + BooleanExpression dateInRange = missionArchive.createdDate.goe(startOfWeek.atStartOfDay()) + .and(missionArchive.createdDate.loe(endOfWeek.atStartOfDay().plusDays(1).minusNanos(1))); // 조건이 MissionType.REPEAT 인 경우에만 날짜 범위 조건 적용 return dateInRange.and(dateInRange); diff --git a/src/main/java/com/moing/backend/domain/missionArchive/domain/repository/MissionArchiveRepository.java b/src/main/java/com/moing/backend/domain/missionArchive/domain/repository/MissionArchiveRepository.java index 7d9726a6..280bf848 100644 --- a/src/main/java/com/moing/backend/domain/missionArchive/domain/repository/MissionArchiveRepository.java +++ b/src/main/java/com/moing/backend/domain/missionArchive/domain/repository/MissionArchiveRepository.java @@ -1,85 +1,18 @@ package com.moing.backend.domain.missionArchive.domain.repository; -import com.moing.backend.domain.history.application.dto.response.MemberIdAndToken; -import com.moing.backend.domain.member.domain.entity.Member; -import com.moing.backend.domain.mission.domain.entity.constant.MissionStatus; import com.moing.backend.domain.missionArchive.domain.entity.MissionArchive; -import com.moing.backend.domain.missionArchive.domain.entity.MissionArchiveStatus; -import com.querydsl.core.Tuple; import feign.Param; -import org.hibernate.annotations.NamedNativeQuery; -import org.hibernate.annotations.Parameter; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; -import javax.persistence.ColumnResult; -import javax.persistence.ConstructorResult; -import javax.persistence.SqlResultSetMapping; import java.util.List; -import java.util.Map; import java.util.Optional; @Repository public interface MissionArchiveRepository extends JpaRepository,MissionArchiveCustomRepository { - @Query("select m from MissionArchive as m where m.member =:memberId" ) - Optional> findByMemberId(@Param("memberId") Long memberId); - @Query("select m from MissionArchive as m where m.mission.id = :missionId and m.member.memberId =:memberId order by m.createdDate") Optional> findArchivesByMissionIdAndMemberId(@Param("memberId") Long memberId, @Param("missionId")Long missionId); - @Query("select m from MissionArchive as m where m.mission.id = :missionId and m.member.memberId =:memberId") - Optional findByMissionIdAndMemberId(@Param("memberId") Long memberId, @Param("missionId")Long missionId); - - - @Query("select m from MissionArchive as m where m.mission.id IN :missionIds and m.member.memberId =:memberId") - Optional> findRepeatMissionArchivesByMission (@Param("memberId") Long memberId, @Param("missionIds") List missionIds); - - -// @Query(value = "SELECT distinct tmSub.fcm_token, tmSub.member_id" + -// "FROM ( " + -// " SELECT distinct COALESCE(tm.member_id, 0) AS member_id, t.team_id, me.fcm_token " + -// " FROM mission m " + -// " LEFT JOIN team t ON m.team_id = t.team_id " + -// " LEFT JOIN team_member tm ON t.team_id = tm.team_id AND tm.is_deleted = 'False' " + -// " LEFT JOIN member me on tm.member_id = me.member_id " + -// " ) tmSub " + -// " LEFT JOIN mission m ON NOT (m.status = 'END' OR m.status = 'SUCCESS') and m.team_id = tmSub.team_id " + -// " LEFT JOIN mission_archive ms ON m.mission_id = ms.mission_id and ms.member_id = tmSub.member_id " + -// "GROUP BY tmSub.member_id, m.mission_id, m.number " + -// "having COUNT(ms.mission_archive_id) < m.number", nativeQuery = true) -// Optional> findHavingRemainMissions(); - - - @Query(value = "SELECT distinct COALESCE(tmSub.fcm_token,'undef') as fcmToken, tmSub.member_id as memberId " + - "FROM (SELECT distinct COALESCE(tm.member_id, 0) AS member_id, t.team_id, me.fcm_token " + - "FROM mission m " + - "LEFT JOIN team t ON m.team_id = t.team_id " + - "LEFT JOIN team_member tm ON t.team_id = tm.team_id AND tm.is_deleted = 'False' " + - "LEFT JOIN member me on tm.member_id = me.member_id) tmSub " + - "LEFT JOIN mission m ON NOT (m.status = 'END' OR m.status = 'SUCCESS') and m.team_id = tmSub.team_id " + - "LEFT JOIN mission_archive ms ON m.mission_id = ms.mission_id and ms.member_id = tmSub.member_id " + - "GROUP BY tmSub.member_id, m.mission_id, m.number " + - "HAVING COUNT(ms.mission_archive_id) < m.number", nativeQuery = true - ) - Optional>> findHavingRemainMissions(); - - -// @Query(value = "SELECT distinct tmSub.fcm_token as fcmToken, tmSub.member_id as memberId " + -// "FROM (SELECT distinct COALESCE(tm.member_id, 0) AS member_id, t.team_id, me.fcm_token " + -// "FROM mission m " + -// "LEFT JOIN team t ON m.team_id = t.team_id " + -// "LEFT JOIN team_member tm ON t.team_id = tm.team_id AND tm.is_deleted = 'False' " + -// "LEFT JOIN member me on tm.member_id = me.member_id) tmSub " + -// "LEFT JOIN mission m ON NOT (m.status = 'END' OR m.status = 'SUCCESS') and m.team_id = tmSub.team_id " + -// "LEFT JOIN mission_archive ms ON m.mission_id = ms.mission_id and ms.member_id = tmSub.member_id " + -// "GROUP BY tmSub.member_id, m.mission_id, m.number " + -// "HAVING COUNT(ms.mission_archive_id) < m.number", nativeQuery = true -// ) -// Optional> findHavingRemainMissions(); - - - - } diff --git a/src/main/java/com/moing/backend/domain/missionArchive/exception/NoAccessMissionArchiveException.java b/src/main/java/com/moing/backend/domain/missionArchive/exception/NoAccessMissionArchiveException.java index 6ce6ada1..8bb4402e 100644 --- a/src/main/java/com/moing/backend/domain/missionArchive/exception/NoAccessMissionArchiveException.java +++ b/src/main/java/com/moing/backend/domain/missionArchive/exception/NoAccessMissionArchiveException.java @@ -1,10 +1,9 @@ package com.moing.backend.domain.missionArchive.exception; -import com.moing.backend.domain.missionState.exception.MissionStateException; import com.moing.backend.global.response.ErrorCode; import org.springframework.http.HttpStatus; -public class NoAccessMissionArchiveException extends MissionStateException { +public class NoAccessMissionArchiveException extends MissionArchiveException { public NoAccessMissionArchiveException() { super(ErrorCode.NO_MORE_ARCHIVE_ERROR, HttpStatus.NOT_FOUND); diff --git a/src/main/java/com/moing/backend/domain/missionComment/application/mapper/MissionCommentMapper.java b/src/main/java/com/moing/backend/domain/missionComment/application/mapper/MissionCommentMapper.java new file mode 100644 index 00000000..a47b6e68 --- /dev/null +++ b/src/main/java/com/moing/backend/domain/missionComment/application/mapper/MissionCommentMapper.java @@ -0,0 +1,20 @@ +package com.moing.backend.domain.missionComment.application.mapper; + +import com.moing.backend.domain.comment.application.dto.request.CreateCommentRequest; +import com.moing.backend.domain.missionArchive.domain.entity.MissionArchive; +import com.moing.backend.domain.missionComment.domain.entity.MissionComment; +import com.moing.backend.domain.teamMember.domain.entity.TeamMember; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; + +@Component +@RequiredArgsConstructor +public class MissionCommentMapper { + public static MissionComment toMissionComment(TeamMember teamMember, MissionArchive missionArchive, CreateCommentRequest createCommentRequest, boolean isLeader) { + MissionComment missionComment=new MissionComment(); + missionComment.init(createCommentRequest.getContent(),isLeader); + missionComment.updateMissionArchive(missionArchive); + missionComment.updateTeamMember(teamMember); + return missionComment; + } +} \ No newline at end of file diff --git a/src/main/java/com/moing/backend/domain/missionComment/application/service/CreateMissionCommentUseCase.java b/src/main/java/com/moing/backend/domain/missionComment/application/service/CreateMissionCommentUseCase.java new file mode 100644 index 00000000..54a0ef10 --- /dev/null +++ b/src/main/java/com/moing/backend/domain/missionComment/application/service/CreateMissionCommentUseCase.java @@ -0,0 +1,41 @@ +package com.moing.backend.domain.missionComment.application.service; + +import com.moing.backend.domain.boardComment.application.service.SendCommentAlarmUseCase; +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.missionComment.application.mapper.MissionCommentMapper; +import com.moing.backend.domain.missionComment.domain.entity.MissionComment; +import com.moing.backend.domain.missionComment.domain.service.MissionCommentSaveService; +import com.moing.backend.domain.team.application.service.CheckLeaderUseCase; +import com.moing.backend.global.response.BaseMissionServiceResponse; +import com.moing.backend.global.utils.BaseMissionService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import javax.transaction.Transactional; + +@Service +@RequiredArgsConstructor +@Transactional +public class CreateMissionCommentUseCase { + + private final MissionCommentSaveService missionCommentSaveService; + private final BaseMissionService baseMissionService; + private final CheckLeaderUseCase checkLeaderUseCase; + private final SendCommentAlarmUseCase sendCommentAlarmUseCase; + /** + * 게시글 댓글 생성 + */ + public CreateCommentResponse createBoardComment(String socialId, Long teamId, Long missionArchiveId, CreateCommentRequest createCommentRequest) { + // 1. 미션 게시글 댓글 생성 + BaseMissionServiceResponse data = baseMissionService.getCommonData(socialId, teamId, missionArchiveId); + boolean isLeader = checkLeaderUseCase.isTeamLeader(data.getMember(), data.getTeam()); + MissionComment missionComment = missionCommentSaveService.saveComment(MissionCommentMapper.toMissionComment(data.getTeamMember(), data.getMissionArchive(), createCommentRequest, isLeader)); + // 2. 미션 게시글 댓글 개수 증가 + data.getMissionArchive().incrComNum(); +// // 3. 미션 게시글 댓글 알림 +// sendCommentAlarmUseCase.sendNewUploadAlarm(data, missionComment); + return new CreateCommentResponse(missionComment.getMissionCommentId()); + } +} + diff --git a/src/main/java/com/moing/backend/domain/missionComment/application/service/DeleteMissionCommentUseCase.java b/src/main/java/com/moing/backend/domain/missionComment/application/service/DeleteMissionCommentUseCase.java new file mode 100644 index 00000000..0c87c5b4 --- /dev/null +++ b/src/main/java/com/moing/backend/domain/missionComment/application/service/DeleteMissionCommentUseCase.java @@ -0,0 +1,39 @@ +package com.moing.backend.domain.missionComment.application.service; + +import com.moing.backend.domain.boardComment.exception.NotAuthByBoardCommentException; +import com.moing.backend.domain.missionComment.domain.entity.MissionComment; +import com.moing.backend.domain.missionComment.domain.service.MissionCommentDeleteService; +import com.moing.backend.domain.missionComment.domain.service.MissionCommentGetService; +import com.moing.backend.global.response.BaseMissionServiceResponse; +import com.moing.backend.global.utils.BaseMissionService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import javax.transaction.Transactional; + +@Service +@Transactional +@RequiredArgsConstructor +public class DeleteMissionCommentUseCase { + + private final MissionCommentGetService missionCommentGetService; + private final MissionCommentDeleteService missionCommentDeleteService; + private final BaseMissionService baseMissionService; + + /** + * 게시글 댓글 삭제 + */ + + public void deleteMissionComment(String socialId, Long teamId, Long missionArchiveId, Long boardCommentId){ + // 1. 게시글 댓글 조회 + BaseMissionServiceResponse data = baseMissionService.getCommonData(socialId, teamId, missionArchiveId); + MissionComment missionComment =missionCommentGetService.getComment(boardCommentId); + // 2. 게시글 댓글 작성자만 + if (data.getTeamMember() == missionComment.getTeamMember()) { + // 3. 삭제 + missionCommentDeleteService.deleteComment(missionComment); + // 4. 댓글 개수 줄이기 + data.getMissionArchive().decrComNum(); + } else throw new NotAuthByBoardCommentException(); + } +} diff --git a/src/main/java/com/moing/backend/domain/missionComment/application/service/GetMissionCommentUseCase.java b/src/main/java/com/moing/backend/domain/missionComment/application/service/GetMissionCommentUseCase.java new file mode 100644 index 00000000..b3d5ca70 --- /dev/null +++ b/src/main/java/com/moing/backend/domain/missionComment/application/service/GetMissionCommentUseCase.java @@ -0,0 +1,27 @@ +package com.moing.backend.domain.missionComment.application.service; + +import com.moing.backend.domain.comment.application.dto.response.GetCommentResponse; +import com.moing.backend.domain.missionComment.domain.service.MissionCommentGetService; +import com.moing.backend.global.response.BaseMissionServiceResponse; +import com.moing.backend.global.utils.BaseMissionService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import javax.transaction.Transactional; + +@Service +@Transactional +@RequiredArgsConstructor +public class GetMissionCommentUseCase { + + private final MissionCommentGetService missionCommentGetService; + private final BaseMissionService baseMissionService; + + /** + * 게시글 댓글 전체 조회 + */ + public GetCommentResponse getBoardCommentAll(String socialId, Long teamId, Long missionArchiveId){ + BaseMissionServiceResponse data = baseMissionService.getCommonData(socialId, teamId, missionArchiveId); + return missionCommentGetService.getCommentAll(missionArchiveId, data.getTeamMember()); + } +} diff --git a/src/main/java/com/moing/backend/domain/missionComment/application/service/SendMissionAlarmUseCase.java b/src/main/java/com/moing/backend/domain/missionComment/application/service/SendMissionAlarmUseCase.java new file mode 100644 index 00000000..ced7594c --- /dev/null +++ b/src/main/java/com/moing/backend/domain/missionComment/application/service/SendMissionAlarmUseCase.java @@ -0,0 +1,4 @@ +package com.moing.backend.domain.missionComment.application.service; + +public class SendMissionAlarmUseCase { +} diff --git a/src/main/java/com/moing/backend/domain/missionComment/domain/entity/MissionComment.java b/src/main/java/com/moing/backend/domain/missionComment/domain/entity/MissionComment.java new file mode 100644 index 00000000..a3941527 --- /dev/null +++ b/src/main/java/com/moing/backend/domain/missionComment/domain/entity/MissionComment.java @@ -0,0 +1,48 @@ +package com.moing.backend.domain.missionComment.domain.entity; + +import com.moing.backend.domain.comment.domain.entity.Comment; +import com.moing.backend.domain.missionArchive.domain.entity.MissionArchive; +import com.moing.backend.domain.teamMember.domain.entity.TeamMember; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import javax.persistence.*; + +@Entity +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Getter +public class MissionComment extends Comment { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "mission_comment_id") + private Long missionCommentId; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "team_member_id") + private TeamMember teamMember; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "mission_archive_id") + private MissionArchive missionArchive; + + /** + * 연관관계 매핑 + */ + public void updateMissionArchive(MissionArchive missionArchive) { + this.missionArchive=missionArchive; + } + + public void updateTeamMember(TeamMember teamMember) { + this.teamMember = teamMember; + } + + public void init(String content, boolean isLeader){ + this.content=content; + this.isLeader=isLeader; + } +} diff --git a/src/main/java/com/moing/backend/domain/missionComment/domain/repository/MissionCommentCustomRepository.java b/src/main/java/com/moing/backend/domain/missionComment/domain/repository/MissionCommentCustomRepository.java new file mode 100644 index 00000000..253b0654 --- /dev/null +++ b/src/main/java/com/moing/backend/domain/missionComment/domain/repository/MissionCommentCustomRepository.java @@ -0,0 +1,14 @@ +package com.moing.backend.domain.missionComment.domain.repository; + +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 MissionCommentCustomRepository { + GetCommentResponse findMissionCommentAll(Long missionArchiveId, TeamMember teamMember); + + Optional> findNewUploadInfo(Long memberId, Long missionArchiveId); +} diff --git a/src/main/java/com/moing/backend/domain/missionComment/domain/repository/MissionCommentCustomRepositoryImpl.java b/src/main/java/com/moing/backend/domain/missionComment/domain/repository/MissionCommentCustomRepositoryImpl.java new file mode 100644 index 00000000..aecacdad --- /dev/null +++ b/src/main/java/com/moing/backend/domain/missionComment/domain/repository/MissionCommentCustomRepositoryImpl.java @@ -0,0 +1,86 @@ +package com.moing.backend.domain.missionComment.domain.repository; + +import com.moing.backend.domain.block.domain.repository.BlockRepositoryUtils; +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; +import com.querydsl.core.types.ExpressionUtils; +import com.querydsl.core.types.Projections; +import com.querydsl.core.types.dsl.BooleanExpression; +import com.querydsl.jpa.JPAExpressions; +import com.querydsl.jpa.impl.JPAQueryFactory; + +import javax.persistence.EntityManager; +import java.util.List; +import java.util.Optional; + +import static com.moing.backend.domain.member.domain.entity.QMember.member; +import static com.moing.backend.domain.missionComment.domain.entity.QMissionComment.missionComment; +import static com.moing.backend.domain.teamMember.domain.entity.QTeamMember.teamMember; + +public class MissionCommentCustomRepositoryImpl implements MissionCommentCustomRepository{ + + private final JPAQueryFactory queryFactory; + + public MissionCommentCustomRepositoryImpl(EntityManager em) { + this.queryFactory = new JPAQueryFactory(em); + } + + + @Override + public GetCommentResponse findMissionCommentAll(Long missionArchiveId, TeamMember teamMember) { + + BooleanExpression blockCondition = BlockRepositoryUtils.blockCondition(teamMember.getTeamMemberId(), missionComment.teamMember.member.memberId); + + List commentBlocks = queryFactory + .select(new QCommentBlocks( + missionComment.missionCommentId, + missionComment.content, + missionComment.teamMember.member.nickName, + missionComment.isLeader, + missionComment.teamMember.member.profileImage, + ExpressionUtils.as(JPAExpressions + .selectOne() + .from(QTeamMember.teamMember) + .where(QTeamMember.teamMember.eq(teamMember) + .and(QTeamMember.teamMember.eq(missionComment.teamMember))) + .exists(), "isWriter"), + missionComment.teamMember.isDeleted, + missionComment.createdDate, + missionComment.teamMember.member.memberId)) + .from(missionComment) + .leftJoin(missionComment.teamMember, QTeamMember.teamMember) + .leftJoin(missionComment.teamMember.member, member) + .where(missionComment.missionArchive.id.eq(missionArchiveId) + .and(blockCondition)) + .orderBy(missionComment.createdDate.asc()) + .fetch(); + + return new GetCommentResponse(commentBlocks); + } + + @Override + public Optional> findNewUploadInfo(Long memberId, Long missionArchiveId) { + BooleanExpression blockCondition= BlockRepositoryUtils.blockCondition(missionComment.teamMember.member.memberId, memberId); + + List result = queryFactory.select(Projections.constructor(NewUploadInfo.class, + missionComment.teamMember.member.fcmToken, + missionComment.teamMember.member.memberId, + missionComment.teamMember.member.isNewUploadPush, + missionComment.teamMember.member.isSignOut)) + .distinct() + .from(missionComment) + .leftJoin(missionComment.teamMember, teamMember) + .leftJoin(missionComment.teamMember.member, member) + .where(missionComment.missionArchive.id.eq(missionArchiveId) //게시글의 댓글인데 + .and(missionComment.teamMember.member.memberId.ne(memberId)) //나는 포함 안하고 + .and(missionComment.teamMember.isDeleted.eq(false)) //탈퇴한 사람도 포함 안함 + .and(blockCondition)) + .fetch(); + + return result.isEmpty() ? Optional.empty() : Optional.of(result); + } +} diff --git a/src/main/java/com/moing/backend/domain/missionComment/domain/repository/MissionCommentRepository.java b/src/main/java/com/moing/backend/domain/missionComment/domain/repository/MissionCommentRepository.java new file mode 100644 index 00000000..8c7d8e35 --- /dev/null +++ b/src/main/java/com/moing/backend/domain/missionComment/domain/repository/MissionCommentRepository.java @@ -0,0 +1,12 @@ +package com.moing.backend.domain.missionComment.domain.repository; + +import com.moing.backend.domain.missionComment.domain.entity.MissionComment; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.Optional; + +public interface MissionCommentRepository extends JpaRepository, MissionCommentCustomRepository { + + Optional findMissionCommentByMissionCommentId(Long missionCommentId); + +} diff --git a/src/main/java/com/moing/backend/domain/missionComment/domain/service/MissionCommentDeleteService.java b/src/main/java/com/moing/backend/domain/missionComment/domain/service/MissionCommentDeleteService.java new file mode 100644 index 00000000..b41f541a --- /dev/null +++ b/src/main/java/com/moing/backend/domain/missionComment/domain/service/MissionCommentDeleteService.java @@ -0,0 +1,18 @@ +package com.moing.backend.domain.missionComment.domain.service; + +import com.moing.backend.domain.comment.domain.service.CommentDeleteService; +import com.moing.backend.domain.missionComment.domain.entity.MissionComment; +import com.moing.backend.domain.missionComment.domain.repository.MissionCommentRepository; +import com.moing.backend.global.annotation.DomainService; +import lombok.RequiredArgsConstructor; + +@DomainService +@RequiredArgsConstructor +public class MissionCommentDeleteService implements CommentDeleteService { + + private final MissionCommentRepository missionCommentRepository; + @Override + public void deleteComment(MissionComment comment) { + missionCommentRepository.delete(comment); + } +} diff --git a/src/main/java/com/moing/backend/domain/missionComment/domain/service/MissionCommentGetService.java b/src/main/java/com/moing/backend/domain/missionComment/domain/service/MissionCommentGetService.java new file mode 100644 index 00000000..501dfe2b --- /dev/null +++ b/src/main/java/com/moing/backend/domain/missionComment/domain/service/MissionCommentGetService.java @@ -0,0 +1,34 @@ +package com.moing.backend.domain.missionComment.domain.service; + +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.missionComment.domain.entity.MissionComment; +import com.moing.backend.domain.missionComment.domain.repository.MissionCommentRepository; +import com.moing.backend.domain.missionComment.exception.NotFoundByMissionCommentIdException; +import com.moing.backend.domain.teamMember.domain.entity.TeamMember; +import com.moing.backend.global.annotation.DomainService; +import lombok.RequiredArgsConstructor; + +import java.util.List; +import java.util.Optional; +@DomainService +@RequiredArgsConstructor +public class MissionCommentGetService implements CommentGetService { + private final MissionCommentRepository missionCommentRepository; + + @Override + public MissionComment getComment(Long commentId) { + return missionCommentRepository.findMissionCommentByMissionCommentId(commentId).orElseThrow(NotFoundByMissionCommentIdException::new); + } + + @Override + public GetCommentResponse getCommentAll(Long missionArchiveId, TeamMember teamMember) { + return missionCommentRepository.findMissionCommentAll(missionArchiveId, teamMember); + } + + @Override + public Optional> getNewUploadInfo(Long memberId, Long missionArchiveId) { + return missionCommentRepository.findNewUploadInfo(memberId, missionArchiveId); + } +} diff --git a/src/main/java/com/moing/backend/domain/missionComment/domain/service/MissionCommentSaveService.java b/src/main/java/com/moing/backend/domain/missionComment/domain/service/MissionCommentSaveService.java new file mode 100644 index 00000000..a62e2e5a --- /dev/null +++ b/src/main/java/com/moing/backend/domain/missionComment/domain/service/MissionCommentSaveService.java @@ -0,0 +1,19 @@ +package com.moing.backend.domain.missionComment.domain.service; + +import com.moing.backend.domain.comment.domain.service.CommentSaveService; +import com.moing.backend.domain.missionComment.domain.entity.MissionComment; +import com.moing.backend.domain.missionComment.domain.repository.MissionCommentRepository; +import com.moing.backend.global.annotation.DomainService; +import lombok.RequiredArgsConstructor; + +@DomainService +@RequiredArgsConstructor +public class MissionCommentSaveService implements CommentSaveService { + + private final MissionCommentRepository missionCommentRepository; + + @Override + public MissionComment saveComment(MissionComment comment) { + return missionCommentRepository.save(comment); + } +} diff --git a/src/main/java/com/moing/backend/domain/missionComment/exception/MissionCommentException.java b/src/main/java/com/moing/backend/domain/missionComment/exception/MissionCommentException.java new file mode 100644 index 00000000..3079b682 --- /dev/null +++ b/src/main/java/com/moing/backend/domain/missionComment/exception/MissionCommentException.java @@ -0,0 +1,11 @@ +package com.moing.backend.domain.missionComment.exception; + +import com.moing.backend.global.exception.ApplicationException; +import com.moing.backend.global.response.ErrorCode; +import org.springframework.http.HttpStatus; + +public abstract class MissionCommentException extends ApplicationException { + protected MissionCommentException(ErrorCode errorCode, HttpStatus httpStatus) { + super(errorCode, httpStatus); + } +} \ No newline at end of file diff --git a/src/main/java/com/moing/backend/domain/missionComment/exception/NotAuthByMissionCommentException.java b/src/main/java/com/moing/backend/domain/missionComment/exception/NotAuthByMissionCommentException.java new file mode 100644 index 00000000..04e9b114 --- /dev/null +++ b/src/main/java/com/moing/backend/domain/missionComment/exception/NotAuthByMissionCommentException.java @@ -0,0 +1,11 @@ +package com.moing.backend.domain.missionComment.exception; + +import com.moing.backend.global.response.ErrorCode; +import org.springframework.http.HttpStatus; + +public class NotAuthByMissionCommentException extends MissionCommentException { + public NotAuthByMissionCommentException() { + super(ErrorCode.NOT_AUTH_BY_MISSION_COMMENT_ID_ERROR, + HttpStatus.NOT_FOUND); + } +} diff --git a/src/main/java/com/moing/backend/domain/missionComment/exception/NotFoundByMissionCommentIdException.java b/src/main/java/com/moing/backend/domain/missionComment/exception/NotFoundByMissionCommentIdException.java new file mode 100644 index 00000000..94c9fcae --- /dev/null +++ b/src/main/java/com/moing/backend/domain/missionComment/exception/NotFoundByMissionCommentIdException.java @@ -0,0 +1,11 @@ +package com.moing.backend.domain.missionComment.exception; + +import com.moing.backend.global.response.ErrorCode; +import org.springframework.http.HttpStatus; + +public class NotFoundByMissionCommentIdException extends MissionCommentException { + public NotFoundByMissionCommentIdException() { + super(ErrorCode.NOT_FOUND_BY_MISSION_COMMENT_ID_ERROR, + HttpStatus.NOT_FOUND); + } +} diff --git a/src/main/java/com/moing/backend/domain/missionComment/presentation/MissionCommentController.java b/src/main/java/com/moing/backend/domain/missionComment/presentation/MissionCommentController.java new file mode 100644 index 00000000..21b3ac18 --- /dev/null +++ b/src/main/java/com/moing/backend/domain/missionComment/presentation/MissionCommentController.java @@ -0,0 +1,69 @@ +package com.moing.backend.domain.missionComment.presentation; + +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.domain.missionComment.application.service.CreateMissionCommentUseCase; +import com.moing.backend.domain.missionComment.application.service.DeleteMissionCommentUseCase; +import com.moing.backend.domain.missionComment.application.service.GetMissionCommentUseCase; +import com.moing.backend.global.config.security.dto.User; +import com.moing.backend.global.response.SuccessResponse; +import lombok.AllArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.security.core.annotation.AuthenticationPrincipal; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; + +import static com.moing.backend.domain.boardComment.presentattion.constant.BoardCommentResponseMessage.GET_BOARD_COMMENT_ALL_SUCCESS; + +@RestController +@AllArgsConstructor +@RequestMapping("/api/{teamId}/{missionArchiveId}/mcomment") +public class MissionCommentController { + + private final CreateMissionCommentUseCase createMissionCommentUseCase; + private final DeleteMissionCommentUseCase deleteMissionCommentUseCase; + private final GetMissionCommentUseCase getMissionCommentUseCase; + + /** + * 댓글 생성 + * [POST] api/{teamId}/{missionArchiveId}/comment + * 작성자 : 김민수 + */ + @PostMapping + public ResponseEntity> createMissionComment(@AuthenticationPrincipal User user, + @PathVariable Long teamId, + @PathVariable Long missionArchiveId, + @Valid @RequestBody CreateCommentRequest createCommentRequest) { + return ResponseEntity.ok(SuccessResponse.create(BoardCommentResponseMessage.CREATE_BOARD_COMMENT_SUCCESS.getMessage(), this.createMissionCommentUseCase.createBoardComment(user.getSocialId(), teamId, missionArchiveId, createCommentRequest))); + } + + /** + * 댓글 삭제 + * [DELETE] api/{teamId}/{missionArchiveId}/comment/{commentId} + * 작성자 : 김민수 + */ + @DeleteMapping("/{commentId}") + public ResponseEntity deleteMissionComment(@AuthenticationPrincipal User user, + @PathVariable Long teamId, + @PathVariable Long missionArchiveId, + @PathVariable Long commentId) { + this.deleteMissionCommentUseCase.deleteMissionComment(user.getSocialId(), teamId, missionArchiveId, commentId); + return ResponseEntity.ok(SuccessResponse.create(BoardCommentResponseMessage.DELETE_BOARD_COMMENT_SUCCESS.getMessage())); + } + + + /** + * 댓글 전체 조회 + * [GET] api/{teamId}/{missionArchiveId}/mcomment + * 작성자 : 김민수 + */ + @GetMapping + public ResponseEntity> getMissionCommentAll(@AuthenticationPrincipal User user, + @PathVariable Long teamId, + @PathVariable Long missionArchiveId) { + return ResponseEntity.ok(SuccessResponse.create(GET_BOARD_COMMENT_ALL_SUCCESS.getMessage(), this.getMissionCommentUseCase.getBoardCommentAll(user.getSocialId(), teamId, missionArchiveId))); + } +} diff --git a/src/main/java/com/moing/backend/domain/missionState/application/dto/MissionStatusRes.java b/src/main/java/com/moing/backend/domain/missionState/application/dto/MissionStatusRes.java deleted file mode 100644 index 0e12354f..00000000 --- a/src/main/java/com/moing/backend/domain/missionState/application/dto/MissionStatusRes.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.moing.backend.domain.missionState.application.dto; - -public class MissionStatusRes { - - private Long done; - private Long total; - -} diff --git a/src/main/java/com/moing/backend/domain/missionState/application/service/MissionStateScheduleUseCase.java b/src/main/java/com/moing/backend/domain/missionState/application/service/MissionStateScheduleUseCase.java deleted file mode 100644 index 025f790c..00000000 --- a/src/main/java/com/moing/backend/domain/missionState/application/service/MissionStateScheduleUseCase.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.moing.backend.domain.missionState.application.service; - -import com.moing.backend.domain.member.application.service.UpdateRemindAlarmUseCase; -import com.moing.backend.domain.mission.application.service.MissionRemindAlarmUseCase; -import com.moing.backend.domain.mission.application.service.SendMissionStartAlarmUseCase; -import com.moing.backend.domain.mission.domain.entity.Mission; -import com.moing.backend.domain.mission.domain.entity.constant.MissionStatus; -import com.moing.backend.domain.mission.domain.service.MissionQueryService; -import com.moing.backend.domain.missionState.domain.service.MissionStateDeleteService; -import com.moing.backend.domain.missionState.domain.service.MissionStateQueryService; -import com.moing.backend.domain.teamScore.application.service.TeamScoreUpdateUseCase; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.context.annotation.Profile; -import org.springframework.scheduling.annotation.EnableAsync; -import org.springframework.scheduling.annotation.EnableScheduling; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.util.List; - -@Slf4j -@Service -@Transactional -@EnableAsync -@EnableScheduling // 스케줄링 활성화 -@RequiredArgsConstructor -@Profile("prod") -public class MissionStateScheduleUseCase { - - private final MissionStateUseCase missionStateUseCase; - private final MissionRemindAlarmUseCase missionRemindAlarmUseCase; - private final MissionQueryService missionQueryService; - private final UpdateRemindAlarmUseCase updateRemindAlarmUseCase; - - private final TeamScoreUpdateUseCase teamScoreUpdateUseCase; - - private final SendMissionStartAlarmUseCase sendMissionStartAlarmUseCase; - - /** - * 단일 미션 마감 - * 해당 시간 미션 마감 - * 한시간 마다 실행 - */ - @Scheduled(cron = "0 1 * * * *") - public void singleMissionEndRoutine() { - - List missionByDueTo = missionQueryService.findMissionByDueTo(); - - for (Mission mission : missionByDueTo) { - mission.updateStatus(MissionStatus.END); - } - - } - - - @Scheduled(cron = "0 0 20 * * *") - public void MissionRemindAlarm() { - missionRemindAlarmUseCase.sendRemindMissionAlarm(); - } - - -// @Scheduled(cron = "0 0 17 * * *") -// public void UpdatePushAlarm() { -// updateRemindAlarmUseCase.sendUpdateAppPushAlarm(); -// } - -} diff --git a/src/main/java/com/moing/backend/domain/missionState/application/service/MissionStateUseCase.java b/src/main/java/com/moing/backend/domain/missionState/application/service/MissionStateUseCase.java deleted file mode 100644 index 66615bca..00000000 --- a/src/main/java/com/moing/backend/domain/missionState/application/service/MissionStateUseCase.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.moing.backend.domain.missionState.application.service; - -import com.moing.backend.domain.member.domain.entity.Member; -import com.moing.backend.domain.mission.domain.entity.Mission; -import com.moing.backend.domain.mission.domain.entity.constant.MissionStatus; -import com.moing.backend.domain.mission.domain.entity.constant.MissionType; -import com.moing.backend.domain.mission.domain.service.MissionQueryService; -import com.moing.backend.domain.missionArchive.domain.entity.MissionArchive; -import com.moing.backend.domain.missionState.domain.service.MissionStateDeleteService; -import com.moing.backend.domain.missionState.domain.service.MissionStateQueryService; -import com.moing.backend.domain.missionState.domain.service.MissionStateSaveService; -import com.moing.backend.domain.teamScore.application.service.TeamScoreUpdateUseCase; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -@Slf4j -@Service -@Transactional -@RequiredArgsConstructor -public class MissionStateUseCase { - - // 미션 종료 직전인지 확인 - // missionId, missionstate num mission.team.personum - - private final MissionQueryService missionQueryService; - private final MissionStateQueryService missionStateQueryService; - private final MissionStateSaveService missionStateSaveService; - private final MissionStateDeleteService missionStateDeleteService; - - private final TeamScoreUpdateUseCase teamScoreUpdateUseCase; - - - /* - 모든 모임원이 미션을 완료했는지 여부 확인 - */ - - public void updateMissionState(Member member, Mission mission, MissionArchive missionArchive) { - missionStateSaveService.saveMissionState(member,mission, missionArchive.getStatus()); - - } - - - - - -} diff --git a/src/main/java/com/moing/backend/domain/missionState/domain/entity/MissionState.java b/src/main/java/com/moing/backend/domain/missionState/domain/entity/MissionState.java deleted file mode 100644 index 22a550b8..00000000 --- a/src/main/java/com/moing/backend/domain/missionState/domain/entity/MissionState.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.moing.backend.domain.missionState.domain.entity; - -import com.moing.backend.domain.member.domain.entity.Member; -import com.moing.backend.domain.mission.domain.entity.Mission; -import com.moing.backend.domain.mission.domain.entity.constant.MissionStatus; -import com.moing.backend.domain.missionArchive.domain.entity.MissionArchiveStatus; -import com.moing.backend.global.entity.BaseTimeEntity; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -import javax.persistence.*; - -@Entity -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Builder -public class MissionState extends BaseTimeEntity { - - @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "missionState_id") - private Long id; - - @ManyToOne(fetch = FetchType.LAZY) - private Mission mission; - @OneToOne - private Member member; - - @Enumerated(value = EnumType.STRING) - private MissionArchiveStatus status; - -} diff --git a/src/main/java/com/moing/backend/domain/missionState/domain/entity/Status.java b/src/main/java/com/moing/backend/domain/missionState/domain/entity/Status.java deleted file mode 100644 index 56f082a8..00000000 --- a/src/main/java/com/moing/backend/domain/missionState/domain/entity/Status.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.moing.backend.domain.missionState.domain.entity; - -public enum Status { - SUCCESS,FAIL -} diff --git a/src/main/java/com/moing/backend/domain/missionState/domain/repository/MissionStateCustomRepository.java b/src/main/java/com/moing/backend/domain/missionState/domain/repository/MissionStateCustomRepository.java deleted file mode 100644 index 01166d64..00000000 --- a/src/main/java/com/moing/backend/domain/missionState/domain/repository/MissionStateCustomRepository.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.moing.backend.domain.missionState.domain.repository; - -import com.moing.backend.domain.member.domain.entity.Member; -import com.moing.backend.domain.mission.domain.entity.Mission; -import com.moing.backend.domain.missionState.domain.entity.MissionState; -import org.springframework.stereotype.Repository; - -import java.util.List; -import java.util.Optional; - -@Repository -public interface MissionStateCustomRepository { - - int getCountsByMissionId(Long missionId) ; - - List findByMissionId(List missionId); - List findByMissionId(Long missionId); - - Optional> findFinishMission(); - - Optional findMissionStateByMemberAndMission(Member member, Mission mission); - - - -} diff --git a/src/main/java/com/moing/backend/domain/missionState/domain/repository/MissionStateCustomRepositoryImpl.java b/src/main/java/com/moing/backend/domain/missionState/domain/repository/MissionStateCustomRepositoryImpl.java deleted file mode 100644 index 93cde112..00000000 --- a/src/main/java/com/moing/backend/domain/missionState/domain/repository/MissionStateCustomRepositoryImpl.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.moing.backend.domain.missionState.domain.repository; - -import com.moing.backend.domain.member.domain.entity.Member; -import com.moing.backend.domain.mission.domain.entity.Mission; -import com.moing.backend.domain.mission.domain.entity.constant.MissionStatus; -import com.moing.backend.domain.mission.domain.entity.constant.MissionType; -import com.moing.backend.domain.missionArchive.domain.entity.MissionArchiveStatus; -import com.moing.backend.domain.missionState.domain.entity.MissionState; -import com.querydsl.core.types.dsl.BooleanExpression; -import com.querydsl.jpa.impl.JPAQueryFactory; - -import javax.persistence.EntityManager; - - -import java.time.DayOfWeek; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.temporal.TemporalAdjusters; -import java.util.List; -import java.util.Optional; - -import static com.moing.backend.domain.missionState.domain.entity.QMissionState.missionState; - -public class MissionStateCustomRepositoryImpl implements MissionStateCustomRepository { - - private final JPAQueryFactory queryFactory; - - public MissionStateCustomRepositoryImpl(EntityManager entityManager) { - this.queryFactory = new JPAQueryFactory(entityManager); - } - - - @Override - public int getCountsByMissionId(Long missionId) { - - LocalDate now = LocalDate.now(); - DayOfWeek firstDayOfWeek = DayOfWeek.MONDAY; // 한 주의 시작일을 월요일로 설정 - LocalDate startOfWeek = now.with(TemporalAdjusters.previousOrSame(firstDayOfWeek)); - LocalDate endOfWeek = startOfWeek.plusDays(6); // 한 주의 마지막일을 일요일로 설정 - - BooleanExpression repeatTypeCondition = (missionState.mission.type.eq(MissionType.REPEAT) - .and(missionState.createdDate.goe(startOfWeek.atStartOfDay())) - .and(missionState.createdDate.loe(endOfWeek.atStartOfDay().plusDays(1).minusNanos(1)))).or(missionState.mission.type.eq(MissionType.ONCE)); - - // 기본 조건 - BooleanExpression baseCondition = missionState.mission.id.eq(missionId); - // 조건 적용 - BooleanExpression finalCondition = baseCondition.and(repeatTypeCondition); - - - return queryFactory - .select(missionState) - .from(missionState) - .where(finalCondition) - .fetch().size(); - } - - @Override - public List findByMissionId(List missionId) { - - return queryFactory - .select(missionState) - .from(missionState) - .where( - missionState.mission.id.in(missionId) - ).fetch(); - - } - @Override - public List findByMissionId(Long missionId) { - - return queryFactory - .select(missionState) - .from(missionState) - .where( - missionState.mission.id.in(missionId) - ).fetch(); - - } - - @Override - public Optional> findFinishMission() { - return Optional.ofNullable(queryFactory - .select(missionState) - .from(missionState) - .where( - missionState.mission.dueTo.ne(LocalDateTime.now()), - missionState.mission.status.eq(MissionStatus.ONGOING) - - ).fetch() - ); - } - - public Optional findMissionStateByMemberAndMission(Member member, Mission mission) { - return Optional.ofNullable(queryFactory - .selectFrom(missionState) - .where(missionState.mission.eq(mission), - missionState.member.eq(member)) - .orderBy(missionState.createdDate.desc()) - .fetchFirst()); - } - -} diff --git a/src/main/java/com/moing/backend/domain/missionState/domain/repository/MissionStateRepository.java b/src/main/java/com/moing/backend/domain/missionState/domain/repository/MissionStateRepository.java deleted file mode 100644 index 32d06a99..00000000 --- a/src/main/java/com/moing/backend/domain/missionState/domain/repository/MissionStateRepository.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.moing.backend.domain.missionState.domain.repository; - -import com.moing.backend.domain.missionState.domain.entity.MissionState; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -@Repository -public interface MissionStateRepository extends JpaRepository,MissionStateCustomRepository { -} diff --git a/src/main/java/com/moing/backend/domain/missionState/domain/service/MissionStateDeleteService.java b/src/main/java/com/moing/backend/domain/missionState/domain/service/MissionStateDeleteService.java deleted file mode 100644 index b99aa8b0..00000000 --- a/src/main/java/com/moing/backend/domain/missionState/domain/service/MissionStateDeleteService.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.moing.backend.domain.missionState.domain.service; - -import com.moing.backend.domain.missionState.domain.entity.MissionState; -import com.moing.backend.domain.missionState.domain.repository.MissionStateRepository; -import com.moing.backend.global.annotation.DomainService; -import lombok.RequiredArgsConstructor; - -import javax.transaction.Transactional; -import java.util.List; - -@DomainService -@Transactional -@RequiredArgsConstructor -public class MissionStateDeleteService { - - private final MissionStateRepository missionStateRepository; - - public void deleteMissionState(List missionStates) { - - missionStateRepository.deleteAll(missionStates); - } - public void deleteMissionState(MissionState missionStates) { - - missionStateRepository.delete(missionStates); - } - - public void deleteMissionStateByMission(Long missionId) { - - List missionStates = missionStateRepository.findByMissionId(missionId); - missionStateRepository.deleteAll(missionStates); - } -} diff --git a/src/main/java/com/moing/backend/domain/missionState/domain/service/MissionStateQueryService.java b/src/main/java/com/moing/backend/domain/missionState/domain/service/MissionStateQueryService.java deleted file mode 100644 index 507a9529..00000000 --- a/src/main/java/com/moing/backend/domain/missionState/domain/service/MissionStateQueryService.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.moing.backend.domain.missionState.domain.service; - -import com.moing.backend.domain.member.domain.entity.Member; -import com.moing.backend.domain.mission.domain.entity.Mission; -import com.moing.backend.domain.missionState.domain.entity.MissionState; -import com.moing.backend.domain.missionState.domain.repository.MissionStateRepository; -import com.moing.backend.global.annotation.DomainService; -import lombok.RequiredArgsConstructor; -import com.moing.backend.domain.missionState.exception.NotFoundMissionStateException; -import javax.transaction.Transactional; -import java.util.List; - -@DomainService -@Transactional -@RequiredArgsConstructor -public class MissionStateQueryService { - - private final MissionStateRepository missionStateRepository; - - public int stateCountByMissionId(Long missionId) { - return missionStateRepository.getCountsByMissionId(missionId); - } - - public List findByMissionId(List missionId) { - return missionStateRepository.findByMissionId(missionId); - } - - public List findFinishMission() { - return missionStateRepository.findFinishMission().orElseThrow(NotFoundMissionStateException::new); - } - - public MissionState findMissionState(Member member, Mission mission) { - return missionStateRepository.findMissionStateByMemberAndMission(member, mission).orElseThrow(NotFoundMissionStateException::new); - } - - -} diff --git a/src/main/java/com/moing/backend/domain/missionState/domain/service/MissionStateSaveService.java b/src/main/java/com/moing/backend/domain/missionState/domain/service/MissionStateSaveService.java deleted file mode 100644 index 1a1fc6e9..00000000 --- a/src/main/java/com/moing/backend/domain/missionState/domain/service/MissionStateSaveService.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.moing.backend.domain.missionState.domain.service; - -import com.moing.backend.domain.member.domain.entity.Member; -import com.moing.backend.domain.mission.domain.entity.Mission; -import com.moing.backend.domain.mission.domain.entity.constant.MissionStatus; -import com.moing.backend.domain.missionArchive.domain.entity.MissionArchive; -import com.moing.backend.domain.missionArchive.domain.entity.MissionArchiveStatus; -import com.moing.backend.domain.missionState.domain.entity.MissionState; -import com.moing.backend.domain.missionState.domain.entity.Status; -import com.moing.backend.domain.missionState.domain.repository.MissionStateRepository; -import com.moing.backend.global.annotation.DomainService; -import lombok.RequiredArgsConstructor; - -import javax.transaction.Transactional; - -@DomainService -@Transactional -@RequiredArgsConstructor -public class MissionStateSaveService { - - private final MissionStateRepository missionStateRepository; - - public void saveMissionState(Member member, Mission mission, MissionArchiveStatus status) { - missionStateRepository.save(MissionState.builder() - .mission(mission) - .member(member) - .status(status) - .build()); - } - -} diff --git a/src/main/java/com/moing/backend/domain/missionState/exception/MissionStateException.java b/src/main/java/com/moing/backend/domain/missionState/exception/MissionStateException.java deleted file mode 100644 index 54c72e46..00000000 --- a/src/main/java/com/moing/backend/domain/missionState/exception/MissionStateException.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.moing.backend.domain.missionState.exception; - -import com.moing.backend.global.exception.ApplicationException; -import com.moing.backend.global.response.ErrorCode; -import org.springframework.http.HttpStatus; - -public abstract class MissionStateException extends ApplicationException { - protected MissionStateException(ErrorCode errorCode, HttpStatus httpStatus) { - super(errorCode, httpStatus); - } -} diff --git a/src/main/java/com/moing/backend/domain/missionState/exception/NotFoundMissionStateException.java b/src/main/java/com/moing/backend/domain/missionState/exception/NotFoundMissionStateException.java deleted file mode 100644 index 2baae393..00000000 --- a/src/main/java/com/moing/backend/domain/missionState/exception/NotFoundMissionStateException.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.moing.backend.domain.missionState.exception; - -import com.moing.backend.global.response.ErrorCode; -import org.springframework.http.HttpStatus; - -public class NotFoundMissionStateException extends MissionStateException{ - public NotFoundMissionStateException() { - super(ErrorCode.NOT_FOUND_END_MISSION, HttpStatus.NOT_FOUND); - - } -} diff --git a/src/main/java/com/moing/backend/domain/report/application/service/ReportCreateUseCase.java b/src/main/java/com/moing/backend/domain/report/application/service/ReportCreateUseCase.java index 999140b9..d96b35ee 100644 --- a/src/main/java/com/moing/backend/domain/report/application/service/ReportCreateUseCase.java +++ b/src/main/java/com/moing/backend/domain/report/application/service/ReportCreateUseCase.java @@ -3,7 +3,6 @@ import com.moing.backend.domain.board.application.dto.request.UpdateBoardRequest; import com.moing.backend.domain.board.domain.entity.Board; import com.moing.backend.domain.board.domain.service.BoardGetService; -import com.moing.backend.domain.boardComment.application.dto.request.CreateBoardCommentRequest; import com.moing.backend.domain.boardComment.domain.entity.BoardComment; import com.moing.backend.domain.boardComment.domain.service.BoardCommentGetService; import com.moing.backend.domain.member.domain.service.MemberGetService; @@ -13,7 +12,6 @@ import com.moing.backend.domain.missionArchive.domain.entity.MissionArchive; import com.moing.backend.domain.missionArchive.domain.entity.MissionArchiveStatus; import com.moing.backend.domain.missionArchive.domain.service.MissionArchiveQueryService; -import com.moing.backend.domain.missionState.domain.entity.MissionState; import com.moing.backend.domain.report.application.mapper.ReportMapper; import com.moing.backend.domain.report.domain.entity.Report; import com.moing.backend.domain.report.domain.entity.constant.ReportType; @@ -56,12 +54,10 @@ public Long createReport(String socialId, Long targetId, String reportType) { .build()); } else if (reportType.equals(ReportType.COMMENT.name())) { - BoardComment boardComment = boardCommentGetService.getBoardComment(targetId); + BoardComment boardComment = boardCommentGetService.getComment(targetId); targetMemberNickName = boardComment.getTeamMember().getMember().getNickName(); + boardComment.updateContent(REPORT_BOARD_MESSAGE); - boardComment.updateBoardComment(CreateBoardCommentRequest.builder() - .content(REPORT_BOARD_MESSAGE) - .build()); } else { MissionArchive missionArchive = missionArchiveQueryService.findByMissionArchiveId(targetId); diff --git a/src/main/java/com/moing/backend/domain/team/presentation/TeamController.java b/src/main/java/com/moing/backend/domain/team/presentation/TeamController.java index 8e24226f..12de51b9 100644 --- a/src/main/java/com/moing/backend/domain/team/presentation/TeamController.java +++ b/src/main/java/com/moing/backend/domain/team/presentation/TeamController.java @@ -137,4 +137,16 @@ public ResponseEntity> getTeamCount(@Authe return ResponseEntity.ok(SuccessResponse.create(GET_TEAM_COUNT_SUCCESS.getMessage(), this.getTeamUseCase.getTeamCount(user.getSocialId(),teamId))); } + @PostMapping(value = "/test", name = "테스트") + public void test() { + Thread thread1 = new Thread(() -> { + this.signInTeamUseCase.signInTeam("KAKAO@tester01", 1L); + }); + Thread thread2 = new Thread(() -> { + this.signInTeamUseCase.signInTeam("KAKAO@tester01", 1L); + }); + thread1.start(); + thread2.start(); + } + } diff --git a/src/main/java/com/moing/backend/domain/teamScore/application/service/TeamScoreGetUseCase.java b/src/main/java/com/moing/backend/domain/teamScore/application/service/TeamScoreGetUseCase.java index a51f4026..18246a4c 100644 --- a/src/main/java/com/moing/backend/domain/teamScore/application/service/TeamScoreGetUseCase.java +++ b/src/main/java/com/moing/backend/domain/teamScore/application/service/TeamScoreGetUseCase.java @@ -1,16 +1,9 @@ package com.moing.backend.domain.teamScore.application.service; -import com.moing.backend.domain.mission.domain.entity.Mission; -import com.moing.backend.domain.mission.domain.service.MissionQueryService; -import com.moing.backend.domain.missionState.domain.service.MissionStateQueryService; -import com.moing.backend.domain.team.domain.entity.Team; -import com.moing.backend.domain.team.domain.service.TeamGetService; -import com.moing.backend.domain.team.domain.service.TeamSaveService; import com.moing.backend.domain.teamScore.application.dto.TeamScoreRes; import com.moing.backend.domain.teamScore.domain.entity.TeamScore; import com.moing.backend.domain.teamScore.domain.service.TeamScoreQueryService; -import com.moing.backend.domain.teamScore.domain.service.TeamScoreSaveService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -30,13 +23,9 @@ public TeamScoreRes getTeamScoreInfo(Long teamId) { Long level = teamScore.getLevel(); Long score = teamScore.getScore(); - // 70 레벨 이상은 경험치 120 되어야 레벨업 가능. level을 각 레벨 별 필요한 경험치 수에 따르 퍼센트로 계산 - if (level > 70) { - score = ( score / 120 ) * 100; - } return TeamScoreRes.builder() - .score(score) + .score(score%100) .level(level) .build(); diff --git a/src/main/java/com/moing/backend/domain/teamScore/application/service/TeamScoreLogicUseCase.java b/src/main/java/com/moing/backend/domain/teamScore/application/service/TeamScoreLogicUseCase.java new file mode 100644 index 00000000..1fc3566d --- /dev/null +++ b/src/main/java/com/moing/backend/domain/teamScore/application/service/TeamScoreLogicUseCase.java @@ -0,0 +1,80 @@ +//package com.moing.backend.domain.teamScore.application.service; +// +// +//import com.moing.backend.domain.mission.domain.entity.Mission; +//import com.moing.backend.domain.mission.domain.service.MissionQueryService; +//import com.moing.backend.domain.missionState.domain.service.MissionArchiveStateQueryService; +//import com.moing.backend.domain.team.domain.entity.Team; +//import com.moing.backend.domain.team.domain.service.TeamGetService; +//import com.moing.backend.domain.team.domain.service.TeamSaveService; +//import com.moing.backend.domain.teamScore.application.dto.TeamScoreRes; +//import com.moing.backend.domain.teamScore.domain.entity.TeamScore; +//import com.moing.backend.domain.teamScore.domain.service.TeamScoreQueryService; +//import com.moing.backend.domain.teamScore.domain.service.TeamScoreSaveService; +//import lombok.RequiredArgsConstructor; +//import lombok.extern.slf4j.Slf4j; +//import org.springframework.stereotype.Service; +//import org.springframework.transaction.annotation.Transactional; +//@Slf4j +//@Service +//@RequiredArgsConstructor +//public class TeamScoreLogicUseCase { +// +// private final MissionQueryService missionQueryService; +// private final TeamScoreQueryService teamScoreQueryService; +// private final MissionArchiveStateQueryService missionArchiveStateQueryService; +// +// public TeamScoreRes getTeamScoreInfo(Long teamId) { +// +// return TeamScoreRes.builder() +// .score(getScore(teamId)) +// .level(getLevel(teamId)) +// .build() +// ; +// } +// +// @Transactional +// public Long updateTeamScore(Long missionId) { +// Mission mission = missionQueryService.findMissionById(missionId); +// Team team = mission.getTeam(); +// TeamScore teamScore = teamScoreQueryService.findTeamScoreByTeam(team.getTeamId()); +// +// teamScore.updateScore(getScoreByMission(mission)); +// teamScore.levelUp(); +// +// return teamScore.getScore(); +// } +// +// public Long getScore(Long teamId) { +// return teamScoreQueryService.findTeamScoreByTeam(teamId).getScore(); +// } +// +// public Long getLevel(Long teamId) { +// return teamScoreQueryService.findTeamScoreByTeam(teamId).getLevel(); +// } +// +// public Long getScoreByMission(Mission mission) { +// float total = totalPeople(mission); +// float done = donePeople(mission); +// +// if (done == 0) { +// return 0L; +// } else { +// return (long) ((done / total * 100) / 5); +// } +// +// } +// +// public float donePeople(Mission mission) { +// return Float.valueOf(missionArchiveStateQueryService.stateCountByMissionId(mission.getId())); +// } +// +// public float totalPeople(Mission mission) { +// return Float.valueOf(mission.getTeam().getNumOfMember()); +// +// } +// +// +// +// +//} diff --git a/src/main/java/com/moing/backend/domain/teamScore/application/service/TeamScoreUpdateUseCase.java b/src/main/java/com/moing/backend/domain/teamScore/application/service/TeamScoreUpdateUseCase.java index 04c88904..9b1c548a 100644 --- a/src/main/java/com/moing/backend/domain/teamScore/application/service/TeamScoreUpdateUseCase.java +++ b/src/main/java/com/moing/backend/domain/teamScore/application/service/TeamScoreUpdateUseCase.java @@ -73,5 +73,4 @@ public void gainScoreOfBonus(Mission mission) { - } diff --git a/src/main/java/com/moing/backend/global/response/BaseMissionServiceResponse.java b/src/main/java/com/moing/backend/global/response/BaseMissionServiceResponse.java new file mode 100644 index 00000000..f0ee645d --- /dev/null +++ b/src/main/java/com/moing/backend/global/response/BaseMissionServiceResponse.java @@ -0,0 +1,19 @@ +package com.moing.backend.global.response; + +import com.moing.backend.domain.member.domain.entity.Member; +import com.moing.backend.domain.missionArchive.domain.entity.MissionArchive; +import com.moing.backend.domain.team.domain.entity.Team; +import com.moing.backend.domain.teamMember.domain.entity.TeamMember; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@AllArgsConstructor +@NoArgsConstructor +public class BaseMissionServiceResponse { + private Member member; + private Team team; + private MissionArchive missionArchive; + private TeamMember teamMember; +} diff --git a/src/main/java/com/moing/backend/global/response/ErrorCode.java b/src/main/java/com/moing/backend/global/response/ErrorCode.java index fc28ead7..72516a96 100644 --- a/src/main/java/com/moing/backend/global/response/ErrorCode.java +++ b/src/main/java/com/moing/backend/global/response/ErrorCode.java @@ -2,7 +2,6 @@ import lombok.AllArgsConstructor; import lombok.Getter; -import org.springframework.http.HttpStatus; @Getter @AllArgsConstructor @@ -63,6 +62,10 @@ public enum ErrorCode { NOT_FOUND_BY_BOARD_COMMENT_ID_ERROR("BC0001","해당 boardCommentId인 댓글이 존재하지 않습니다."), NOT_AUTH_BY_BOARD_COMMENT_ID_ERROR("BC0002","권한이 없습니다."), + //미션 댓글 관련 에러 코드 + NOT_FOUND_BY_MISSION_COMMENT_ID_ERROR("MC0001", "해당 missionCommentId인 댓글이 존재하지 않습니다."), + NOT_AUTH_BY_MISSION_COMMENT_ID_ERROR("MC0002", "권한이 없습니다."), + //알림 관련 에러 코드 NOT_FOUND_BY_ALARM_HISOTRY_ID_ERROR("AH0001","해당 alarmHistoryId인 알림이 존재하지 않습니다."), diff --git a/src/main/java/com/moing/backend/global/utils/BaseMissionService.java b/src/main/java/com/moing/backend/global/utils/BaseMissionService.java new file mode 100644 index 00000000..84311b40 --- /dev/null +++ b/src/main/java/com/moing/backend/global/utils/BaseMissionService.java @@ -0,0 +1,32 @@ +package com.moing.backend.global.utils; + +import com.moing.backend.domain.member.domain.entity.Member; +import com.moing.backend.domain.member.domain.service.MemberGetService; +import com.moing.backend.domain.missionArchive.domain.entity.MissionArchive; +import com.moing.backend.domain.missionArchive.domain.service.MissionArchiveQueryService; +import com.moing.backend.domain.team.domain.entity.Team; +import com.moing.backend.domain.team.domain.service.TeamGetService; +import com.moing.backend.domain.teamMember.domain.entity.TeamMember; +import com.moing.backend.domain.teamMember.domain.service.TeamMemberGetService; +import com.moing.backend.global.response.BaseMissionServiceResponse; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@RequiredArgsConstructor +@Service +public class BaseMissionService { + + private final MemberGetService memberGetService; + private final TeamGetService teamGetService; + private final MissionArchiveQueryService missionArchiveQueryService; + private final TeamMemberGetService teamMemberGetService; + + public BaseMissionServiceResponse getCommonData(String socialId, Long teamId, Long missionArchiveId){ + Member member = memberGetService.getMemberBySocialId(socialId); + Team team = teamGetService.getTeamByTeamId(teamId); + MissionArchive missionArchive=missionArchiveQueryService.findByMissionArchiveId(missionArchiveId); + TeamMember teamMember = teamMemberGetService.getTeamMember(member, team); + + return new BaseMissionServiceResponse(member, team, missionArchive, teamMember); + } +} diff --git a/src/test/java/com/moing/backend/domain/boardComment/presentation/BoardCommentControllerTest.java b/src/test/java/com/moing/backend/domain/boardComment/presentation/BoardCommentControllerTest.java index 0b8ea674..0d14b897 100644 --- a/src/test/java/com/moing/backend/domain/boardComment/presentation/BoardCommentControllerTest.java +++ b/src/test/java/com/moing/backend/domain/boardComment/presentation/BoardCommentControllerTest.java @@ -1,14 +1,14 @@ package com.moing.backend.domain.boardComment.presentation; import com.moing.backend.config.CommonControllerTest; -import com.moing.backend.domain.boardComment.application.dto.request.CreateBoardCommentRequest; -import com.moing.backend.domain.boardComment.application.dto.response.CommentBlocks; -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.BoardCommentController; +import com.moing.backend.domain.comment.application.dto.request.CreateCommentRequest; +import com.moing.backend.domain.comment.application.dto.response.CommentBlocks; +import com.moing.backend.domain.comment.application.dto.response.CreateCommentResponse; +import com.moing.backend.domain.comment.application.dto.response.GetCommentResponse; import org.junit.jupiter.api.Test; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.mock.mockito.MockBean; @@ -44,14 +44,14 @@ public void create_board_comment() throws Exception { //given Long teamId = 1L; Long boardId = 1L; - CreateBoardCommentRequest input = CreateBoardCommentRequest.builder() + CreateCommentRequest input = CreateCommentRequest.builder() .content("게시글 내용") .build(); String body = objectMapper.writeValueAsString(input); - CreateBoardCommentResponse output = CreateBoardCommentResponse.builder() - .boardCommentId(1L) + CreateCommentResponse output = CreateCommentResponse.builder() + .commentId(1L) .build(); given(createBoardCommentUseCase.createBoardComment(any(), any(), any(), any())).willReturn(output); @@ -83,7 +83,7 @@ public void create_board_comment() throws Exception { responseFields( fieldWithPath("isSuccess").description("true"), fieldWithPath("message").description("댓글을 생성했습니다"), - fieldWithPath("data.boardCommentId").description("생성한 boardCommentId") + fieldWithPath("data.commentId").description("생성한 boardCommentId") ) ) ); @@ -135,7 +135,7 @@ public void get_board_comment_all() throws Exception { Long boardId = 1L; CommentBlocks commentBlock = CommentBlocks.builder() - .boardCommentId(1L) + .commentId(1L) .content("댓글 내용") .writerIsLeader(true) .writerNickName("작성자 닉네임") @@ -148,7 +148,7 @@ public void get_board_comment_all() throws Exception { commentBlocks.add(commentBlock); - GetBoardCommentResponse output = new GetBoardCommentResponse(commentBlocks); + GetCommentResponse output = new GetCommentResponse(commentBlocks); given(getBoardCommentUseCase.getBoardCommentAll(any(), any(), any())).willReturn(output); @@ -176,7 +176,7 @@ public void get_board_comment_all() throws Exception { responseFields( fieldWithPath("isSuccess").description("true"), fieldWithPath("message").description("댓글 목록을 모두 조회했습니다."), - fieldWithPath("data.commentBlocks[].boardCommentId").description("댓글 아이디"), + fieldWithPath("data.commentBlocks[].commentId").description("댓글 아이디"), fieldWithPath("data.commentBlocks[].content").description("댓글 내용"), fieldWithPath("data.commentBlocks[].writerIsLeader").description("작성자 소모임장 여부"), fieldWithPath("data.commentBlocks[].writerNickName").description("작성자 닉네임"), diff --git a/src/test/java/com/moing/backend/domain/mission/representation/MissionControllerTest.java b/src/test/java/com/moing/backend/domain/mission/representation/MissionControllerTest.java index 83d8cc49..5ec529f4 100644 --- a/src/test/java/com/moing/backend/domain/mission/representation/MissionControllerTest.java +++ b/src/test/java/com/moing/backend/domain/mission/representation/MissionControllerTest.java @@ -9,19 +9,14 @@ import com.moing.backend.domain.mission.application.service.MissionDeleteUseCase; import com.moing.backend.domain.mission.application.service.MissionReadUseCase; import com.moing.backend.domain.mission.application.service.MissionUpdateUseCase; -import com.moing.backend.domain.mission.domain.repository.MissionRepository; import com.moing.backend.domain.mission.domain.service.MissionQueryService; import com.moing.backend.domain.mission.presentation.MissionController; import org.junit.jupiter.api.Test; -import org.mockito.Mock; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.MediaType; import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders; -import org.springframework.restdocs.payload.JsonFieldType; import org.springframework.test.web.servlet.ResultActions; -import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import org.springframework.test.web.servlet.result.MockMvcResultMatchers; import static com.moing.backend.domain.mission.presentation.constant.MissionResponseMessage.CONFIRM_MISSION_SUCCESS; @@ -35,7 +30,6 @@ import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; @WebMvcTest(MissionController.class) public class MissionControllerTest extends CommonControllerTest { @@ -366,7 +360,7 @@ public class MissionControllerTest extends CommonControllerTest { .isLeader(Boolean.FALSE) .build(); - given(missionUpdateUseCase.updateMissionStatus(any(),any())).willReturn(output); + given(missionUpdateUseCase.terminateMissionByUser(any(),any())).willReturn(output); Long teamId = 2L; Long missionId = 1L; diff --git a/src/test/java/com/moing/backend/domain/missionArchive/representation/MissionArchiveControllerTest.java b/src/test/java/com/moing/backend/domain/missionArchive/representation/MissionArchiveControllerTest.java index 97ea9614..d05c8dd6 100644 --- a/src/test/java/com/moing/backend/domain/missionArchive/representation/MissionArchiveControllerTest.java +++ b/src/test/java/com/moing/backend/domain/missionArchive/representation/MissionArchiveControllerTest.java @@ -1,7 +1,6 @@ package com.moing.backend.domain.missionArchive.representation; import com.moing.backend.config.CommonControllerTest; -import com.moing.backend.domain.missionArchive.application.dto.req.MissionArchiveHeartReq; import com.moing.backend.domain.missionArchive.application.dto.req.MissionArchiveReq; import com.moing.backend.domain.missionArchive.application.dto.res.*; import com.moing.backend.domain.missionArchive.application.service.*; @@ -52,6 +51,7 @@ public class MissionArchiveControllerTest extends CommonControllerTest { MissionArchiveReq input = MissionArchiveReq.builder() .status("COMPLETE/SKIP") .archive("content[s3 Link / text / link]") + .contents("contents") .build(); String body = objectMapper.writeValueAsString(input); @@ -65,6 +65,8 @@ public class MissionArchiveControllerTest extends CommonControllerTest { .count(1L) .heartStatus("[True/False]") .hearts(1L) + .contents("contents") + .comments(1L) .build(); given(missionArchiveCreateUseCase.createArchive(any(),any(),any())).willReturn(output); @@ -93,7 +95,10 @@ public class MissionArchiveControllerTest extends CommonControllerTest { ), requestFields( fieldWithPath("status").description("미션 인증 상태 [COMPLETE/SKIP]"), - fieldWithPath("archive").description("미션 인증물 [s3URL/text/링크] ") + fieldWithPath("archive").description("미션 인증물 [s3URL/text/링크] "), + fieldWithPath("contents").description("미션 인증 문구 [null 허용] ") + + ), responseFields( fieldWithPath("isSuccess").description("true"), @@ -105,8 +110,11 @@ public class MissionArchiveControllerTest extends CommonControllerTest { fieldWithPath("data.status").description("미션 인증 상태"), fieldWithPath("data.count").description("미션 인증 횟수"), fieldWithPath("data.hearts").description("미션 인증 좋아요 수"), - fieldWithPath("data.heartStatus").description("미션 인증 좋아요 상태") - ) + fieldWithPath("data.heartStatus").description("미션 인증 좋아요 상태"), + fieldWithPath("data.contents").description("미션 인증 문구"), + fieldWithPath("data.comments").description("미션 댓글 개수") + + ) ) ) .andReturn(); @@ -119,6 +127,7 @@ public class MissionArchiveControllerTest extends CommonControllerTest { MissionArchiveReq input = MissionArchiveReq.builder() .status("COMPLETE/SKIP") .archive("content[s3 Link / text / link]") + .contents("contents") .build(); String body = objectMapper.writeValueAsString(input); @@ -132,6 +141,8 @@ public class MissionArchiveControllerTest extends CommonControllerTest { .count(1L) .heartStatus("[True/False]") .hearts(1L) + .contents("contents") + .comments(1L) .build(); given(missionArchiveUpdateUseCase.updateArchive(any(),any(),any())).willReturn(output); @@ -160,7 +171,9 @@ public class MissionArchiveControllerTest extends CommonControllerTest { ), requestFields( fieldWithPath("status").description("미션 인증 상태 [COMPLETE/SKIP]"), - fieldWithPath("archive").description("미션 인증물 [s3URL/text/링크] ") + fieldWithPath("archive").description("미션 인증물 [s3URL/text/링크] "), + fieldWithPath("contents").description("미션 인증 문구 [null 허용] ") + ), responseFields( fieldWithPath("isSuccess").description("true"), @@ -173,8 +186,11 @@ public class MissionArchiveControllerTest extends CommonControllerTest { fieldWithPath("data.status").description("미션 인증 상태"), fieldWithPath("data.count").description("미션 인증 횟수"), fieldWithPath("data.heartStatus").description("미션 인증 좋아요 상태"), - fieldWithPath("data.hearts").description("미션 인증 좋아요 수") - ) + fieldWithPath("data.hearts").description("미션 인증 좋아요 수"), + fieldWithPath("data.contents").description("미션 인증 문구"), + fieldWithPath("data.comments").description("미션 댓글 개수") + + ) ) ) .andReturn(); @@ -236,6 +252,8 @@ public class MissionArchiveControllerTest extends CommonControllerTest { .count(1L) .heartStatus("[True/False]") .hearts(1L) + .contents("contents") + .comments(1L) .build()); MyMissionArchiveRes output = MyMissionArchiveRes.builder() @@ -278,7 +296,9 @@ public class MissionArchiveControllerTest extends CommonControllerTest { fieldWithPath("data.archives[].status").description("미션 인증 상태"), fieldWithPath("data.archives[].count").description("미션 인증 횟수"), fieldWithPath("data.archives[].heartStatus").description("미션 인증 좋아요 상태"), - fieldWithPath("data.archives[].hearts").description("미션 인증 좋아요 수") + fieldWithPath("data.archives[].hearts").description("미션 인증 좋아요 수"), + fieldWithPath("data.archives[].contents").description("미션 인증 문구"), + fieldWithPath("data.archives[].comments").description("미션 댓글 개수") ) @@ -304,6 +324,8 @@ public class MissionArchiveControllerTest extends CommonControllerTest { .heartStatus("[True/False]") .hearts(3) .makerId(1L) + .contents("contents") + .comments(1L) .build()); given(missionArchiveReadUseCase.getPersonalArchive(any(),any())).willReturn(output); @@ -343,7 +365,10 @@ public class MissionArchiveControllerTest extends CommonControllerTest { fieldWithPath("data[].count").description("미션 인증 횟수"), fieldWithPath("data[].heartStatus").description("미션 인증 좋아요 상태 "), fieldWithPath("data[].hearts").description("미션 인증 좋아요 수 "), - fieldWithPath("data[].makerId").description("미션 인증한 사람 ") + fieldWithPath("data[].makerId").description("미션 인증한 사람 "), + fieldWithPath("data[].contents").description("미션 인증 문구"), + fieldWithPath("data[].comments").description("미션 인증 댓글 수") + ) @@ -433,7 +458,7 @@ public class MissionArchiveControllerTest extends CommonControllerTest { ), responseFields( fieldWithPath("isSuccess").description("true"), - fieldWithPath("message").description(MISSION_ARCHIVE_PEOPLE_STATUS_SUCCESS.getMessage()), + fieldWithPath("message").description(MISSION_ARCHIVE_MY_STATUS_SUCCESS.getMessage()), fieldWithPath("data.total").description("전체 미션 참여자"), fieldWithPath("data.done").description("미션 인증 완료한 미션 참여자 ") diff --git a/src/test/java/com/moing/backend/domain/missionArchive/representation/MissionGatherControllerTest.java b/src/test/java/com/moing/backend/domain/missionArchive/representation/MissionGatherControllerTest.java index 410eafee..93ff8e5d 100644 --- a/src/test/java/com/moing/backend/domain/missionArchive/representation/MissionGatherControllerTest.java +++ b/src/test/java/com/moing/backend/domain/missionArchive/representation/MissionGatherControllerTest.java @@ -1,8 +1,7 @@ package com.moing.backend.domain.missionArchive.representation; import com.moing.backend.config.CommonControllerTest; -import com.moing.backend.domain.mission.application.dto.res.GatherRepeatMissionRes; -import com.moing.backend.domain.mission.application.dto.res.GatherSingleMissionRes; +import com.moing.backend.domain.mission.application.dto.res.*; import com.moing.backend.domain.mission.application.service.MissionGatherBoardUseCase; import com.moing.backend.domain.missionArchive.application.dto.res.MissionArchivePhotoRes; import com.moing.backend.domain.missionArchive.application.dto.res.MyTeamsRes; @@ -24,8 +23,7 @@ import static org.mockito.BDDMockito.given; import static org.springframework.restdocs.headers.HeaderDocumentation.headerWithName; import static org.springframework.restdocs.headers.HeaderDocumentation.requestHeaders; -import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; -import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; +import static org.springframework.restdocs.payload.PayloadDocumentation.*; @WebMvcTest(MissionGatherController.class) public class MissionGatherControllerTest extends CommonControllerTest { @@ -44,7 +42,9 @@ public class MissionGatherControllerTest extends CommonControllerTest { .dueTo("2023-09-03T21:32:33.888") .teamName("team name") .missionTitle("mission title") - .status("WAIT/ONGOING/END/FAIL/SUCCESS") + .status("WAIT/ONGOING/SKIP/COMPLETE") + .done("0") + .total("5") .build()); given(missionGatherBoardUseCase.getAllActiveSingleMissions(any())).willReturn(output); @@ -74,8 +74,9 @@ public class MissionGatherControllerTest extends CommonControllerTest { fieldWithPath("data[].dueTo").description("미션 마감 시각"), fieldWithPath("data[].teamName").description("팀 이름"), fieldWithPath("data[].missionTitle").description("미션 제목"), - fieldWithPath("data[].status").description("미션 상태") - + fieldWithPath("data[].status").description("WAIT/ONGOING=인증하지 않음 SKIP/COMPLETE=인증 완료"), + fieldWithPath("data[].done").description("미션 인증 한 인원수"), + fieldWithPath("data[].total").description("팀 전체 인원수") ) ) @@ -95,7 +96,9 @@ public class MissionGatherControllerTest extends CommonControllerTest { .missionTitle("mission title") .doneNum("0") .totalNum("0") - .status("WAIT/ONGOING/END/FAIL/SUCCESS") + .status("WAIT/ONGOING/SKIP/COMPLETE") + .donePeople("0") + .totalPeople("0") .build()); given(missionGatherBoardUseCase.getAllActiveRepeatMissions(any())).willReturn(output); @@ -124,9 +127,11 @@ public class MissionGatherControllerTest extends CommonControllerTest { fieldWithPath("data[].teamId").description("팀 아이디"), fieldWithPath("data[].teamName").description("팀 이름"), fieldWithPath("data[].missionTitle").description("미션 제목"), - fieldWithPath("data[].doneNum").description("완료한 횟수"), + fieldWithPath("data[].doneNum").description("내가 완료한 횟수"), fieldWithPath("data[].totalNum").description("전체 횟수"), - fieldWithPath("data[].status").description("미션 상태") + fieldWithPath("data[].status").description("미션 상태"), + fieldWithPath("data[].donePeople").description("미션 완료한 인원수"), + fieldWithPath("data[].totalPeople").description("팀 전체 인원수") ) @@ -146,7 +151,9 @@ public class MissionGatherControllerTest extends CommonControllerTest { .dueTo("2023-09-03T21:32:33.888") .teamName("team name") .missionTitle("mission title") - .status("WAIT/ONGOING/END/FAIL/SUCCESS") + .status("WAIT/ONGOING/SKIP/COMPLETE") + .done("0") + .total("5") .build()); given(missionGatherBoardUseCase.getTeamActiveSingleMissions(any(),any())).willReturn(output); @@ -177,8 +184,9 @@ public class MissionGatherControllerTest extends CommonControllerTest { fieldWithPath("data[].dueTo").description("미션 마감 시각"), fieldWithPath("data[].teamName").description("팀 이름"), fieldWithPath("data[].missionTitle").description("미션 제목"), - fieldWithPath("data[].status").description("미션 상태") - + fieldWithPath("data[].status").description("WAIT/ONGOING=인증하지 않음 SKIP/COMPLETE=인증 완료"), + fieldWithPath("data[].done").description("미션 인증 한 인원수"), + fieldWithPath("data[].total").description("팀 전체 인원수") ) ) @@ -198,7 +206,9 @@ public class MissionGatherControllerTest extends CommonControllerTest { .missionTitle("mission title") .doneNum("0") .totalNum("0") - .status("WAIT/ONGOING/END/FAIL/SUCCESS") + .status("WAIT/ONGOING/SKIP/COMPLETE") + .donePeople("0") + .totalPeople("0") .build()); given(missionGatherBoardUseCase.getTeamActiveRepeatMissions(any(),any())).willReturn(output); @@ -230,7 +240,9 @@ public class MissionGatherControllerTest extends CommonControllerTest { fieldWithPath("data[].missionTitle").description("미션 제목"), fieldWithPath("data[].doneNum").description("완료한 횟수"), fieldWithPath("data[].totalNum").description("전체 횟수"), - fieldWithPath("data[].status").description("미션 상태") + fieldWithPath("data[].status").description("미션 상태"), + fieldWithPath("data[].donePeople").description("미션 완료한 인원수"), + fieldWithPath("data[].totalPeople").description("팀 전체 인원수") ) diff --git a/src/test/java/com/moing/backend/domain/missionComment/domain/MissionRepositoryTest.java b/src/test/java/com/moing/backend/domain/missionComment/domain/MissionRepositoryTest.java new file mode 100644 index 00000000..ee4c9b6c --- /dev/null +++ b/src/test/java/com/moing/backend/domain/missionComment/domain/MissionRepositoryTest.java @@ -0,0 +1,22 @@ +package com.moing.backend.domain.missionComment.domain; + +import com.moing.backend.domain.missionComment.domain.repository.MissionCommentRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.transaction.annotation.Transactional; + +@SpringBootTest +@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) +@ActiveProfiles("dev") +@Transactional +public class MissionRepositoryTest { + + @Autowired + MissionCommentRepository missionCommentRepository; + public void create_Mission_Comment(){ + + } + +} diff --git a/src/test/java/com/moing/backend/domain/missionComment/presentation/MissionCommentControllerTest.java b/src/test/java/com/moing/backend/domain/missionComment/presentation/MissionCommentControllerTest.java new file mode 100644 index 00000000..072bc3eb --- /dev/null +++ b/src/test/java/com/moing/backend/domain/missionComment/presentation/MissionCommentControllerTest.java @@ -0,0 +1,192 @@ +package com.moing.backend.domain.missionComment.presentation; + +import com.moing.backend.config.CommonControllerTest; +import com.moing.backend.domain.comment.application.dto.request.CreateCommentRequest; +import com.moing.backend.domain.comment.application.dto.response.CommentBlocks; +import com.moing.backend.domain.comment.application.dto.response.CreateCommentResponse; +import com.moing.backend.domain.comment.application.dto.response.GetCommentResponse; +import com.moing.backend.domain.missionComment.application.service.CreateMissionCommentUseCase; +import com.moing.backend.domain.missionComment.application.service.DeleteMissionCommentUseCase; +import com.moing.backend.domain.missionComment.application.service.GetMissionCommentUseCase; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.http.MediaType; +import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders; +import org.springframework.test.web.servlet.ResultActions; + +import java.util.ArrayList; +import java.util.List; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.given; +import static org.springframework.restdocs.headers.HeaderDocumentation.headerWithName; +import static org.springframework.restdocs.headers.HeaderDocumentation.requestHeaders; +import static org.springframework.restdocs.payload.PayloadDocumentation.*; +import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; +import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@WebMvcTest(MissionCommentController.class) +public class MissionCommentControllerTest extends CommonControllerTest { + + @MockBean + private CreateMissionCommentUseCase createMissionCommentUseCase; + @MockBean + private DeleteMissionCommentUseCase deleteMissionCommentUseCase; + @MockBean + private GetMissionCommentUseCase getMissionCommentUseCase; + + @Test + public void create_mission_comment() throws Exception { + + //given + Long teamId = 1L; + Long missionArchiveId = 1L; + CreateCommentRequest input = CreateCommentRequest.builder() + .content("게시글 내용") + .build(); + + String body = objectMapper.writeValueAsString(input); + + CreateCommentResponse output = CreateCommentResponse.builder() + .commentId(1L) + .build(); + + given(createMissionCommentUseCase.createBoardComment(any(), any(), any(), any())).willReturn(output); + + + //when + ResultActions actions = mockMvc.perform(RestDocumentationRequestBuilders. + post("/api/{teamId}/{missionArchiveId}/mcomment", teamId, missionArchiveId) + .header("Authorization", "Bearer ACCESS_TOKEN") + .contentType(MediaType.APPLICATION_JSON) + .content(body) + ); + + //then + actions + .andExpect(status().isOk()) + .andDo( + restDocs.document( + requestHeaders( + headerWithName("Authorization").description("접근 토큰") + ), + pathParameters( + parameterWithName("teamId").description("팀 아이디"), + parameterWithName("missionArchiveId").description("미션 게시물 아이디") + ), + requestFields( + fieldWithPath("content").description("댓글 내용") + ), + responseFields( + fieldWithPath("isSuccess").description("true"), + fieldWithPath("message").description("댓글을 생성했습니다"), + fieldWithPath("data.commentId").description("생성한 boardCommentId") + ) + ) + ); + } + + @Test + public void delete_mission_comment() throws Exception { + + //given + Long teamId = 1L; + Long boardId = 1L; + Long missionArchiveId = 1L; + + + //when + ResultActions actions = mockMvc.perform(RestDocumentationRequestBuilders. + delete("/api/{teamId}/{missionArchiveId}/mcomment/{boardCommentId}", teamId, boardId, missionArchiveId) + .header("Authorization", "Bearer ACCESS_TOKEN") + .contentType(MediaType.APPLICATION_JSON) + ); + + //then + actions + .andExpect(status().isOk()) + .andDo( + restDocs.document( + requestHeaders( + headerWithName("Authorization").description("접근 토큰") + ), + pathParameters( + parameterWithName("teamId").description("팀 아이디"), + parameterWithName("missionArchiveId").description("미션 게시글 아이디"), + parameterWithName("boardCommentId").description("댓글 아이디") + ), + responseFields( + fieldWithPath("isSuccess").description("true"), + fieldWithPath("message").description("댓글을 삭제했습니다") + ) + ) + ); + } + + + @Test + public void get_board_comment_all() throws Exception { + //given + List commentBlocks = new ArrayList<>(); + Long teamId = 1L; + Long boardId = 1L; + + CommentBlocks commentBlock = CommentBlocks.builder() + .commentId(1L) + .content("댓글 내용") + .writerIsLeader(true) + .writerNickName("작성자 닉네임") + .writerProfileImage("작성자 프로필 이미지") + .writerIsDeleted(false) + .isWriter(true) + .createdDate("2023/12/05 23:29") + .makerId(1L) + .build(); + + commentBlocks.add(commentBlock); + + GetCommentResponse output = new GetCommentResponse(commentBlocks); + + given(getMissionCommentUseCase.getBoardCommentAll(any(), any(), any())).willReturn(output); + + + //when + ResultActions actions = mockMvc.perform(RestDocumentationRequestBuilders. + get("/api/{teamId}/{missionArchiveId}/mcomment", teamId, boardId) + .header("Authorization", "Bearer ACCESS_TOKEN") + .contentType(MediaType.APPLICATION_JSON) + ); + + + //then + actions + .andExpect(status().isOk()) + .andDo( + restDocs.document( + requestHeaders( + headerWithName("Authorization").description("접근 토큰") + ), + pathParameters( + parameterWithName("teamId").description("팀 아이디"), + parameterWithName("missionArchiveId").description("게시글 아이디") + ), + responseFields( + fieldWithPath("isSuccess").description("true"), + fieldWithPath("message").description("댓글 목록을 모두 조회했습니다."), + fieldWithPath("data.commentBlocks[].commentId").description("댓글 아이디"), + fieldWithPath("data.commentBlocks[].content").description("댓글 내용"), + fieldWithPath("data.commentBlocks[].writerIsLeader").description("작성자 소모임장 여부"), + fieldWithPath("data.commentBlocks[].writerNickName").description("작성자 닉네임"), + fieldWithPath("data.commentBlocks[].writerProfileImage").description("작성자 프로필 이미지"), + fieldWithPath("data.commentBlocks[].writerIsDeleted").description("작성자 삭제 여부"), + fieldWithPath("data.commentBlocks[].isWriter").description("댓글 작성자 여부"), + fieldWithPath("data.commentBlocks[].createdDate").description("생성 시간"), + fieldWithPath("data.commentBlocks[].makerId").description("작성자 Id") + ) + + ) + ); + } +} diff --git a/src/test/java/com/moing/backend/domain/missionState/domain/service/MissionStateQueryServiceTest.java b/src/test/java/com/moing/backend/domain/missionState/domain/service/MissionStateQueryServiceTest.java index 3e8be90c..e69de29b 100644 --- a/src/test/java/com/moing/backend/domain/missionState/domain/service/MissionStateQueryServiceTest.java +++ b/src/test/java/com/moing/backend/domain/missionState/domain/service/MissionStateQueryServiceTest.java @@ -1,35 +0,0 @@ -//package com.moing.backend.domain.missionState.domain.service; -// -//import com.moing.backend.domain.missionState.application.service.MissionStateUseCase; -//import com.moing.backend.domain.missionState.domain.repository.MissionStateCustomRepository; -//import com.moing.backend.domain.missionState.domain.repository.MissionStateCustomRepositoryImpl; -//import com.moing.backend.domain.missionState.domain.repository.MissionStateRepository; -//import org.junit.jupiter.api.Test; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.boot.test.context.SpringBootTest; -//import org.springframework.boot.test.mock.mockito.MockBean; -// -//import javax.persistence.EntityManager; -// -//import static org.junit.jupiter.api.Assertions.*; -// -//@SpringBootTest -//class MissionStateQueryServiceTest { -// -// -// @MockBean -// MissionStateQueryService missionStateQueryService ; -// @MockBean -// MissionStateCustomRepositoryImpl missionStateCustomRepository ; -// -// -// @Test -// public void missionDonePeople() { -// System.out.println(missionStateQueryService.stateCountByMissionId(4L)); -// } -// -// -// -// -// -//} \ No newline at end of file