diff --git a/src/docs/asciidoc/Mission-API.adoc b/src/docs/asciidoc/Mission-API.adoc index 8a63b7e7..3cdf3e8d 100644 --- a/src/docs/asciidoc/Mission-API.adoc +++ b/src/docs/asciidoc/Mission-API.adoc @@ -34,3 +34,9 @@ operation::mission-controller-test/미션_추천[snippets='http-request,path-par --- +[[Mission-종료]] +=== Mission 종료 +operation::mission-controller-test/미션_종료[snippets='http-request,path-parameters,request-fields,http-response,response-fields'] + +--- + diff --git a/src/main/java/com/moing/backend/domain/mission/application/dto/res/MissionCreateRes.java b/src/main/java/com/moing/backend/domain/mission/application/dto/res/MissionCreateRes.java index 59338e38..39d07123 100644 --- a/src/main/java/com/moing/backend/domain/mission/application/dto/res/MissionCreateRes.java +++ b/src/main/java/com/moing/backend/domain/mission/application/dto/res/MissionCreateRes.java @@ -20,4 +20,6 @@ public class MissionCreateRes { private String status; private String way; + private Boolean isLeader; + } diff --git a/src/main/java/com/moing/backend/domain/mission/application/dto/res/MissionReadRes.java b/src/main/java/com/moing/backend/domain/mission/application/dto/res/MissionReadRes.java index 14b85380..22aeac19 100644 --- a/src/main/java/com/moing/backend/domain/mission/application/dto/res/MissionReadRes.java +++ b/src/main/java/com/moing/backend/domain/mission/application/dto/res/MissionReadRes.java @@ -1,10 +1,12 @@ package com.moing.backend.domain.mission.application.dto.res; +import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; @Getter @Builder +@AllArgsConstructor public class MissionReadRes { private String title; @@ -16,4 +18,6 @@ public class MissionReadRes { private String type; private String way; + private Boolean isLeader; + } diff --git a/src/main/java/com/moing/backend/domain/mission/application/mapper/MissionMapper.java b/src/main/java/com/moing/backend/domain/mission/application/mapper/MissionMapper.java index 756ac7e5..01da4b6b 100644 --- a/src/main/java/com/moing/backend/domain/mission/application/mapper/MissionMapper.java +++ b/src/main/java/com/moing/backend/domain/mission/application/mapper/MissionMapper.java @@ -47,6 +47,7 @@ public static MissionCreateRes mapToMissionCreateRes(Mission mission) { .type(mission.getType().name()) .status(mission.getStatus().name()) .number(mission.getNumber()) + .isLeader(Boolean.TRUE) .build(); } diff --git a/src/main/java/com/moing/backend/domain/mission/application/service/MissionReadUseCase.java b/src/main/java/com/moing/backend/domain/mission/application/service/MissionReadUseCase.java index 7092685a..6ed68694 100644 --- a/src/main/java/com/moing/backend/domain/mission/application/service/MissionReadUseCase.java +++ b/src/main/java/com/moing/backend/domain/mission/application/service/MissionReadUseCase.java @@ -27,9 +27,7 @@ public class MissionReadUseCase { public MissionReadRes getMission(String userSocialId, Long missionId) { Member member = memberGetService.getMemberBySocialId(userSocialId); - - Mission mission = missionQueryService.findMissionById(missionId); - return MissionMapper.mapToMissionReadRes(mission); + return missionQueryService.findMissionByIds(member.getMemberId(),missionId); } public String getTeamCategory(Long teamId) { 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 fefc9c0c..0e41b413 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 @@ -4,11 +4,14 @@ import com.moing.backend.domain.member.domain.service.MemberGetService; import com.moing.backend.domain.mission.application.dto.req.MissionReq; import com.moing.backend.domain.mission.application.dto.res.MissionCreateRes; +import com.moing.backend.domain.mission.application.dto.res.MissionReadRes; import com.moing.backend.domain.mission.application.mapper.MissionMapper; 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.mission.domain.service.MissionSaveService; +import com.moing.backend.domain.mission.exception.NoAccessCreateMission; import com.moing.backend.global.util.SecurityUtils; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -23,7 +26,7 @@ public class MissionUpdateUseCase { private final MissionQueryService missionQueryService; private final MemberGetService memberGetService; - public MissionCreateRes updateMission(String userSocialId,Long missionId, MissionReq missionReq) { + public MissionCreateRes updateMission(String userSocialId, Long missionId, MissionReq missionReq) { Member member = memberGetService.getMemberBySocialId(userSocialId); @@ -36,4 +39,20 @@ public MissionCreateRes updateMission(String userSocialId,Long missionId, Missio } + public MissionReadRes updateMissionStatus(String userSocialId, Long missionId) { + + + Member member = memberGetService.getMemberBySocialId(userSocialId); + + Mission findMission = missionQueryService.findMissionById(missionId); + + if (findMission.getTeam().getLeaderId().equals(member.getMemberId())) { + findMission.updateStatus(MissionStatus.END); + } else { + throw new NoAccessCreateMission(); + } + + return MissionMapper.mapToMissionReadRes(findMission); + + } } diff --git a/src/main/java/com/moing/backend/domain/mission/application/service/SendMissionCreateAlarmUseCase.java b/src/main/java/com/moing/backend/domain/mission/application/service/SendMissionCreateAlarmUseCase.java index 3edc96e8..b0a82df3 100644 --- a/src/main/java/com/moing/backend/domain/mission/application/service/SendMissionCreateAlarmUseCase.java +++ b/src/main/java/com/moing/backend/domain/mission/application/service/SendMissionCreateAlarmUseCase.java @@ -5,13 +5,16 @@ import com.moing.backend.domain.mission.domain.entity.Mission; import com.moing.backend.domain.team.domain.entity.Team; import com.moing.backend.domain.teamMember.domain.service.TeamMemberGetService; +import com.moing.backend.global.config.fcm.dto.event.FcmEvent; import com.moing.backend.global.config.fcm.dto.request.MultiRequest; import com.moing.backend.global.config.fcm.service.FcmService; import com.moing.backend.global.response.BaseServiceResponse; import lombok.RequiredArgsConstructor; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.stereotype.Service; import javax.transaction.Transactional; +import java.util.EventListener; import java.util.List; import java.util.Optional; @@ -24,20 +27,16 @@ public class SendMissionCreateAlarmUseCase { private final TeamMemberGetService teamMemberGetService; - private final FcmService fcmService; + private final ApplicationEventPublisher eventPublisher; public void sendNewMissionUploadAlarm(Member member, Mission mission) { Team team = mission.getTeam(); - Optional> fcmTokensExceptMe = teamMemberGetService.getFcmTokensExceptMe(team.getTeamId(), member.getMemberId()); - String title = team.getName() + " " + NEW_SINGLE_MISSION_COMING.getTitle(); String message = mission.getTitle(); Optional> fcmTokens = teamMemberGetService.getFcmTokensExceptMe(team.getTeamId(), member.getMemberId()); if (fcmTokens.isPresent() && !fcmTokens.get().isEmpty()) { - MultiRequest toMultiRequest = new MultiRequest(fcmTokens.get(), title, message); - fcmService.sendMultipleDevices(toMultiRequest); - + eventPublisher.publishEvent(new FcmEvent(title, message, fcmTokens.get())); } } } 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 df199e4a..66177310 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 @@ -84,8 +84,4 @@ public void setTeam(Team team) { public void updateStatus(MissionStatus missionStatus) { this.status = missionStatus; } - - public void makeEnd() { - this.status = MissionStatus.END; - } } diff --git a/src/main/java/com/moing/backend/domain/mission/domain/repository/MissionCustomRepository.java b/src/main/java/com/moing/backend/domain/mission/domain/repository/MissionCustomRepository.java index 4ba36e8a..e0610615 100644 --- a/src/main/java/com/moing/backend/domain/mission/domain/repository/MissionCustomRepository.java +++ b/src/main/java/com/moing/backend/domain/mission/domain/repository/MissionCustomRepository.java @@ -2,6 +2,7 @@ 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.MissionReadRes; import com.moing.backend.domain.mission.domain.entity.Mission; import com.moing.backend.domain.mission.domain.entity.constant.MissionStatus; import org.springframework.stereotype.Repository; @@ -25,5 +26,7 @@ public interface MissionCustomRepository { boolean findRepeatMissionsByTeamId(Long teamId); + Optional findByIds(Long memberId, Long missionId); + } \ No newline at end of file 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 f8834e6f..e35e1b7d 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 @@ -2,11 +2,13 @@ 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.MissionReadRes; 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.missionState.domain.entity.QMissionState; import com.querydsl.core.types.Projections; +import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.jpa.JPAExpressions; import com.querydsl.jpa.impl.JPAQueryFactory; @@ -138,4 +140,26 @@ public boolean findRepeatMissionsByTeamId(Long teamId) { ).fetchCount() > 2; } + @Override + public Optional findByIds(Long memberId, Long missionId) { + + + BooleanExpression isLeader = mission.team.leaderId.eq(memberId); + + return Optional.ofNullable(queryFactory + .select(Projections.constructor(MissionReadRes.class, + mission.title, + mission.dueTo.stringValue(), + mission.rule, + mission.content, + mission.type.stringValue(), + mission.way.stringValue(), + isLeader)) + .from(mission) + .where(mission.id.eq(missionId)) + .fetchOne() + ); + } + + } diff --git a/src/main/java/com/moing/backend/domain/mission/domain/service/MissionQueryService.java b/src/main/java/com/moing/backend/domain/mission/domain/service/MissionQueryService.java index ef0a716b..136f5c43 100644 --- a/src/main/java/com/moing/backend/domain/mission/domain/service/MissionQueryService.java +++ b/src/main/java/com/moing/backend/domain/mission/domain/service/MissionQueryService.java @@ -3,6 +3,7 @@ import com.moing.backend.domain.member.domain.entity.Member; 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.MissionReadRes; 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.exception.*; @@ -28,6 +29,9 @@ public class MissionQueryService { public Mission findMissionById(Long missionId) { return missionRepository.findById(missionId).orElseThrow(NotFoundMissionException::new); } + public MissionReadRes findMissionByIds(Long memberId, Long missionId) { + return missionRepository.findByIds(memberId,missionId).orElseThrow(NotFoundMissionException::new); + } public Long findMissionsCountByTeam(Long teamId) { return missionRepository.findMissionsCountByTeam(teamId); 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 12362a25..531e7ef5 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 @@ -64,6 +64,16 @@ public ResponseEntity> updateMission(@Authenti return ResponseEntity.ok(SuccessResponse.create(UPDATE_MISSION_SUCCESS.getMessage(), this.missionUpdateUseCase.updateMission(user.getSocialId(),missionId, missionReq))); } + /** + * 미션 종료 + * [PUT] {teamId}/missions/{missionId}/end + * 작성자 : 정승연 + */ + @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))); + } + /** * 미션 삭제 * [DELETE] {teamId}/missions/{missionId} @@ -86,4 +96,9 @@ public ResponseEntity> recommendMission(@AuthenticationP } + + + + + } diff --git a/src/main/java/com/moing/backend/domain/mission/presentation/constant/MissionResponseMessage.java b/src/main/java/com/moing/backend/domain/mission/presentation/constant/MissionResponseMessage.java index 757a41d4..1adb30cf 100644 --- a/src/main/java/com/moing/backend/domain/mission/presentation/constant/MissionResponseMessage.java +++ b/src/main/java/com/moing/backend/domain/mission/presentation/constant/MissionResponseMessage.java @@ -9,6 +9,7 @@ public enum MissionResponseMessage { CREATE_MISSION_SUCCESS("미션 생성을 완료 했습니다"), READ_MISSION_SUCCESS("미션 조회를 완료 했습니다"), UPDATE_MISSION_SUCCESS("미션 수정을 완료 했습니다"), + END_MISSION_SUCCESS("미션 종료를 완료 했습니다"), DELETE_MISSION_SUCCESS("미션 삭제를 완료 했습니다"), RECOMMEND_MISSION_SUCCESS("미션 추천을 위한 팀 카테고리를 조회 했습니다"); 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 d4df05e9..ddf6df7a 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 @@ -51,7 +51,7 @@ public class MissionArchiveDeleteUseCase { private final MissionStateQueryService missionStateQueryService; - public Long deleteArchive(String userSocialId, Long missionId) { + public Long deleteArchive(String userSocialId, Long missionId,Long count) { Member member = memberGetService.getMemberBySocialId(userSocialId); Long memberId = member.getMemberId(); @@ -63,7 +63,7 @@ public Long deleteArchive(String userSocialId, Long missionId) { } - MissionArchive deleteArchive = missionArchiveQueryService.findMyArchive(memberId, missionId).get(0); + MissionArchive deleteArchive = missionArchiveQueryService.findOneMyArchive(memberId, missionId,count).get(0); missionArchiveDeleteService.deleteMissionArchive(deleteArchive); MissionState missionState = missionStateQueryService.findMissionState(member, mission); diff --git a/src/main/java/com/moing/backend/domain/missionArchive/domain/repository/MissionArchiveCustomRepository.java b/src/main/java/com/moing/backend/domain/missionArchive/domain/repository/MissionArchiveCustomRepository.java index 1818b2ed..d46cea25 100644 --- a/src/main/java/com/moing/backend/domain/missionArchive/domain/repository/MissionArchiveCustomRepository.java +++ b/src/main/java/com/moing/backend/domain/missionArchive/domain/repository/MissionArchiveCustomRepository.java @@ -16,6 +16,7 @@ public interface MissionArchiveCustomRepository { Optional> findSingleMissionInComplete(Long memberId, Long teamId, MissionStatus status,OrderCondition orderCondition); Optional> findSingleMissionComplete(Long memberId, Long teamId, MissionStatus status,OrderCondition orderCondition); Optional> findMyArchives(Long memberId,Long missionId); + Optional> findOneMyArchives(Long memberId,Long missionId,Long count); Optional> findOthersArchives(Long memberId, Long missionId) ; 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 293ec640..4a87d55b 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 @@ -109,6 +109,23 @@ private OrderSpecifier[] createOrderSpecifier(OrderCondition orderCondition) { } @Override + public Optional> findOneMyArchives(Long memberId,Long missionId,Long count) { + + return Optional.ofNullable(queryFactory + .select(missionArchive) + .from(missionArchive) + .where( + missionArchive.mission.id.eq(missionId), + missionArchive.member.memberId.eq(memberId), + missionArchive.count.eq(count) + ) + .orderBy(missionArchive.createdDate.desc()) + .fetch() + + ); + } + + @Override public Optional> findMyArchives(Long memberId,Long missionId) { return Optional.ofNullable(queryFactory diff --git a/src/main/java/com/moing/backend/domain/missionArchive/domain/service/MissionArchiveQueryService.java b/src/main/java/com/moing/backend/domain/missionArchive/domain/service/MissionArchiveQueryService.java index 04f924c3..9e081919 100644 --- a/src/main/java/com/moing/backend/domain/missionArchive/domain/service/MissionArchiveQueryService.java +++ b/src/main/java/com/moing/backend/domain/missionArchive/domain/service/MissionArchiveQueryService.java @@ -41,9 +41,19 @@ public MissionArchive findArchive(Long memberId, Long missionId) { public List findMyArchive(Long memberId, Long missionId) { Optional> optional = missionArchiveRepository.findMyArchives(memberId, missionId); + + if (optional.isPresent() && optional.get().size() == 0) { + return new ArrayList<>(); + } else { + return optional.get(); + } + } + public List findOneMyArchive(Long memberId, Long missionId, Long count) { + + Optional> optional = missionArchiveRepository.findMyArchives(memberId, missionId); + if (optional.isPresent() && optional.get().size() == 0) { return new ArrayList<>(); -// throw new NotFoundMissionArchiveException(); } else { return optional.get(); } diff --git a/src/main/java/com/moing/backend/domain/missionArchive/presentation/MissionArchiveController.java b/src/main/java/com/moing/backend/domain/missionArchive/presentation/MissionArchiveController.java index 04c6ba67..1bf57b83 100644 --- a/src/main/java/com/moing/backend/domain/missionArchive/presentation/MissionArchiveController.java +++ b/src/main/java/com/moing/backend/domain/missionArchive/presentation/MissionArchiveController.java @@ -73,11 +73,12 @@ public ResponseEntity> updateArchive(@Authent * 작성자 : 정승연 **/ - @DeleteMapping() + @DeleteMapping("/{count}") public ResponseEntity> deleteArchive(@AuthenticationPrincipal User user, - @PathVariable("teamId") Long teamId, - @PathVariable("missionId") Long missionId) { - return ResponseEntity.ok(SuccessResponse.create(UPDATE_ARCHIVE_SUCCESS.getMessage(), this.missionArchiveDeleteUseCase.deleteArchive(user.getSocialId(), missionId))); + @PathVariable("teamId") Long teamId, + @PathVariable("missionId") Long missionId, + @PathVariable("count") Long count) { + return ResponseEntity.ok(SuccessResponse.create(DELETE_ARCHIVE_SUCCESS.getMessage(), this.missionArchiveDeleteUseCase.deleteArchive(user.getSocialId(), missionId,count))); } /** 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 index 57d5b21c..8cfa4b54 100644 --- 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 @@ -109,6 +109,7 @@ public void RepeatMissionStart() { // @Scheduled(cron = "8 0 0 * * *") // public void MissionRemindAlarm() { // +// // missionRemindAlarmUseCase.sendRemindMissionAlarm(); // } } diff --git a/src/main/java/com/moing/backend/domain/team/application/dto/response/GetTeamCountResponse.java b/src/main/java/com/moing/backend/domain/team/application/dto/response/GetTeamCountResponse.java index e6ad022b..b4bd207a 100644 --- a/src/main/java/com/moing/backend/domain/team/application/dto/response/GetTeamCountResponse.java +++ b/src/main/java/com/moing/backend/domain/team/application/dto/response/GetTeamCountResponse.java @@ -20,7 +20,7 @@ public void updateCount(Long count){ } public void updateMemberName(String nickName){ - this.memberName=memberName; + this.memberName=nickName; } @QueryProjection diff --git a/src/main/java/com/moing/backend/domain/teamMember/domain/repository/TeamMemberCustomRepository.java b/src/main/java/com/moing/backend/domain/teamMember/domain/repository/TeamMemberCustomRepository.java index ff212d46..89b22d3b 100644 --- a/src/main/java/com/moing/backend/domain/teamMember/domain/repository/TeamMemberCustomRepository.java +++ b/src/main/java/com/moing/backend/domain/teamMember/domain/repository/TeamMemberCustomRepository.java @@ -10,7 +10,6 @@ public interface TeamMemberCustomRepository { List findMemberIdsByTeamId(Long teamId); Optional> findFcmTokensByTeamIdAndMemberId(Long teamId, Long memberId); - Optional> findFcmTokensByTeamId(Long teamId); List findTeamMemberInfoByTeamId(Long teamId); List findTeamMemberByMemberId(Long memberId); } diff --git a/src/main/java/com/moing/backend/domain/teamMember/domain/repository/TeamMemberCustomRepositoryImpl.java b/src/main/java/com/moing/backend/domain/teamMember/domain/repository/TeamMemberCustomRepositoryImpl.java index b692fcee..7942c58f 100644 --- a/src/main/java/com/moing/backend/domain/teamMember/domain/repository/TeamMemberCustomRepositoryImpl.java +++ b/src/main/java/com/moing/backend/domain/teamMember/domain/repository/TeamMemberCustomRepositoryImpl.java @@ -37,18 +37,8 @@ public Optional> findFcmTokensByTeamIdAndMemberId(Long teamId, Long .from(teamMember) .where(teamMember.team.teamId.eq(teamId) .and(teamMember.member.isNewUploadPush.eq(true)) - .and(teamMember.member.memberId.ne(memberId))) - .fetch(); - - return result.isEmpty() ? Optional.empty() : Optional.of(result); - } - - @Override - public Optional> findFcmTokensByTeamId(Long teamId) { - List result = queryFactory.select(teamMember.member.fcmToken) - .from(teamMember) - .where(teamMember.team.teamId.eq(teamId) - .and(teamMember.member.isNewUploadPush.eq(true))) + .and(teamMember.member.memberId.ne(memberId)) + .and(teamMember.isDeleted.eq(false))) .fetch(); return result.isEmpty() ? Optional.empty() : Optional.of(result); diff --git a/src/main/java/com/moing/backend/domain/teamMember/domain/service/TeamMemberGetService.java b/src/main/java/com/moing/backend/domain/teamMember/domain/service/TeamMemberGetService.java index 138d8d0f..2b9dfee2 100644 --- a/src/main/java/com/moing/backend/domain/teamMember/domain/service/TeamMemberGetService.java +++ b/src/main/java/com/moing/backend/domain/teamMember/domain/service/TeamMemberGetService.java @@ -29,10 +29,6 @@ public Optional> getFcmTokensExceptMe(Long teamId, Long memberId) { return teamMemberRepository.findFcmTokensByTeamIdAndMemberId(teamId, memberId); } - public Optional> getFcmTokens(Long teamId) { - return teamMemberRepository.findFcmTokensByTeamId(teamId); - } - public List getTeamMemberInfo(Long teamId){ return teamMemberRepository.findTeamMemberInfoByTeamId(teamId); } 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 095fc040..e1736dfd 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 @@ -80,6 +80,7 @@ public class MissionControllerTest extends CommonControllerTest { .type("ONCE/REPEAT") .status("END/ONGOING/SUCCESS/FAIL") .way("TEXT/PHOTO/LINK") + .isLeader(Boolean.FALSE) .build(); given(missionCreateUseCase.createMission(any(),any(),any())).willReturn(output); @@ -124,7 +125,8 @@ public class MissionControllerTest extends CommonControllerTest { fieldWithPath("data.number").description("미션 반복 횟수"), fieldWithPath("data.type").description("미션 유형(단일/반복)"), fieldWithPath("data.way").description("미션 진행 방법(사진/글/링크)"), - fieldWithPath("data.status").description("미션 진행 상태") + fieldWithPath("data.status").description("미션 진행 상태"), + fieldWithPath("data.isLeader").description("소모임장 여부") ) ) ) @@ -157,6 +159,7 @@ public class MissionControllerTest extends CommonControllerTest { .type("ONCE") .status("END") .way("TEXT") + .isLeader(Boolean.FALSE) .build(); given(missionUpdateUseCase.updateMission(any(),any(),any())).willReturn(output); @@ -203,7 +206,8 @@ public class MissionControllerTest extends CommonControllerTest { fieldWithPath("data.number").description("미션 반복 횟수"), fieldWithPath("data.type").description("미션 유형(ONCE/REPEAT)"), fieldWithPath("data.way").description("미션 진행 방법(TEXT/PHOTO/LINK)"), - fieldWithPath("data.status").description("미션 진행 상태(END/ONGOING/SUCCESS/FAIL)") + fieldWithPath("data.status").description("미션 진행 상태(END/ONGOING/SUCCESS/FAIL)"), + fieldWithPath("data.isLeader").description("소모임장 여부") ) ) @@ -224,6 +228,7 @@ public class MissionControllerTest extends CommonControllerTest { .content("content") .type("ONCE") .way("TEXT") + .isLeader(Boolean.FALSE) .build(); given(missionReadUseCase.getMission(any(),any())).willReturn(output); @@ -258,7 +263,9 @@ public class MissionControllerTest extends CommonControllerTest { fieldWithPath("data.rule").description("미션 규칙"), fieldWithPath("data.content").description("미션 내용"), fieldWithPath("data.way").description("미션 진행 방법(TEXT/PHOTO/LINK)"), - fieldWithPath("data.type").description("미션 유형(ONCE/REPEAT)") + fieldWithPath("data.type").description("미션 유형(ONCE/REPEAT)"), + fieldWithPath("data.isLeader").description("소모임장인지 여부") + ) ) @@ -342,4 +349,62 @@ public class MissionControllerTest extends CommonControllerTest { .andReturn(); } + + @Test + public void 미션_종료() throws Exception { + //given + + + MissionReadRes output = MissionReadRes.builder() + .title("title") + .dueTo("2023-12-31 23:39:22.333") + .rule("rule") + .content("content") + .type("ONCE") + .way("TEXT") + .isLeader(Boolean.FALSE) + .build(); + + given(missionUpdateUseCase.updateMissionStatus(any(),any())).willReturn(output); + + Long teamId = 2L; + Long missionId = 1L; + //when + ResultActions actions = mockMvc.perform(RestDocumentationRequestBuilders. + put("/api/team/{teamId}/missions/{missionId}/end",teamId,missionId) + .header("Authorization", "Bearer ACCESS_TOKEN") + .contentType(MediaType.APPLICATION_JSON) + + ); + + //then + actions + .andExpect(MockMvcResultMatchers.status().isOk()) + .andDo( + restDocs.document( + requestHeaders( + headerWithName("Authorization").description("접근 토큰") + ), + pathParameters( + parameterWithName("teamId").description("팀 아이디"), + parameterWithName("missionId").description("미션 아이디") + ), + responseFields( + fieldWithPath("isSuccess").description("true"), + fieldWithPath("message").description("로그인을 했습니다"), + fieldWithPath("data.title").description("미션 제목"), + fieldWithPath("data.dueTo").description("미션 마감 날짜"), + fieldWithPath("data.rule").description("미션 규칙"), + fieldWithPath("data.content").description("미션 내용"), + fieldWithPath("data.way").description("미션 진행 방법(TEXT/PHOTO/LINK)"), + fieldWithPath("data.type").description("미션 유형(ONCE/REPEAT)"), + fieldWithPath("data.isLeader").description("소모임장 여부") + + ) + ) + ) + .andReturn(); + + } + } 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 cc139084..bef311b4 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 @@ -188,13 +188,14 @@ public class MissionArchiveControllerTest extends CommonControllerTest { //given Long output = 1L; - given(missionArchiveDeleteUseCase.deleteArchive(any(),any())).willReturn(output); + Long count =1L; + given(missionArchiveDeleteUseCase.deleteArchive(any(),any(),any())).willReturn(output); Long teamId = 1L; Long missionId = 1L; //when ResultActions actions = mockMvc.perform(RestDocumentationRequestBuilders. - delete("/api/team/{teamId}/missions/{missionId}/archive",teamId,missionId) + delete("/api/team/{teamId}/missions/{missionId}/archive/{count}",teamId,missionId,count) .header("Authorization", "Bearer ACCESS_TOKEN") .contentType(MediaType.APPLICATION_JSON) ); @@ -209,11 +210,12 @@ public class MissionArchiveControllerTest extends CommonControllerTest { ), pathParameters( parameterWithName("teamId").description("팀 아이디"), - parameterWithName("missionId").description("미션 아이디") + parameterWithName("missionId").description("미션 아이디"), + parameterWithName("count").description("반복미션 횟수(단일 미션일 경우 1, 반복미션일 경우 n") ), responseFields( fieldWithPath("isSuccess").description("true"), - fieldWithPath("message").description(UPDATE_ARCHIVE_SUCCESS), + fieldWithPath("message").description(DELETE_ARCHIVE_SUCCESS), fieldWithPath("data").description("삭제한 미션 인증 아이디(무시)") ) )