diff --git a/src/main/java/com/moing/backend/domain/mission/application/dto/req/MissionReq.java b/src/main/java/com/moing/backend/domain/mission/application/dto/req/MissionReq.java index 98962c87..083474cb 100644 --- a/src/main/java/com/moing/backend/domain/mission/application/dto/req/MissionReq.java +++ b/src/main/java/com/moing/backend/domain/mission/application/dto/req/MissionReq.java @@ -1,10 +1,11 @@ package com.moing.backend.domain.mission.application.dto.req; -import lombok.Builder; -import lombok.Getter; +import lombok.*; -@Getter +@AllArgsConstructor @Builder +@NoArgsConstructor +@Getter public class MissionReq { private String title; diff --git a/src/main/java/com/moing/backend/domain/mission/application/service/MissionGatherBoardUseCase.java b/src/main/java/com/moing/backend/domain/mission/application/service/MissionGatherBoardUseCase.java index ba04e12d..f1727911 100644 --- a/src/main/java/com/moing/backend/domain/mission/application/service/MissionGatherBoardUseCase.java +++ b/src/main/java/com/moing/backend/domain/mission/application/service/MissionGatherBoardUseCase.java @@ -5,6 +5,10 @@ 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.domain.service.MissionQueryService; +import com.moing.backend.domain.missionArchive.application.dto.res.MissionArchivePhotoRes; +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 lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -17,7 +21,9 @@ public class MissionGatherBoardUseCase { private final MissionQueryService missionQueryService; + private final MissionArchiveQueryService missionArchiveQueryService; private final MemberGetService memberGetService; + private final TeamGetService teamGetService; public List getAllActiveSingleMissions(String userId) { Long memberId = memberGetService.getMemberBySocialId(userId).getMemberId(); @@ -30,6 +36,15 @@ public List getAllActiveRepeatMissions(String userId) { } + public List getArchivePhotoByTeamRes(String userId) { + Long memberId = memberGetService.getMemberBySocialId(userId).getMemberId(); + + List teamIdByMemberId = teamGetService.getTeamIdByMemberId(memberId); + + return missionArchiveQueryService.findTop5ArchivesByTeam(teamIdByMemberId); + } + + } 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 8b5b7223..972479bb 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 @@ -1,12 +1,11 @@ package com.moing.backend.domain.missionArchive.application.dto.req; -import lombok.Builder; -import lombok.Getter; -import lombok.Setter; +import lombok.*; -@Getter -@Setter +@AllArgsConstructor @Builder +@NoArgsConstructor +@Getter public class MissionArchiveReq { private String status; diff --git a/src/main/java/com/moing/backend/domain/missionArchive/application/dto/res/MissionArchivePhotoRes.java b/src/main/java/com/moing/backend/domain/missionArchive/application/dto/res/MissionArchivePhotoRes.java new file mode 100644 index 00000000..331ae3e1 --- /dev/null +++ b/src/main/java/com/moing/backend/domain/missionArchive/application/dto/res/MissionArchivePhotoRes.java @@ -0,0 +1,17 @@ +package com.moing.backend.domain.missionArchive.application.dto.res; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Builder +@Getter +@NoArgsConstructor +@AllArgsConstructor +public class MissionArchivePhotoRes { + Long teamId; + List photo; +} 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 fb041759..b976e42a 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,15 +1,13 @@ package com.moing.backend.domain.missionArchive.application.dto.res; -import lombok.Builder; -import lombok.Getter; -import lombok.Setter; +import lombok.*; import javax.annotation.Nullable; import java.util.List; - +@AllArgsConstructor @Builder +@NoArgsConstructor @Getter -@Setter public class MissionArchiveRes { private Long archiveId; diff --git a/src/main/java/com/moing/backend/domain/missionArchive/application/dto/res/MissionArchiveStatusRes.java b/src/main/java/com/moing/backend/domain/missionArchive/application/dto/res/MissionArchiveStatusRes.java index 67216a52..89c30696 100644 --- a/src/main/java/com/moing/backend/domain/missionArchive/application/dto/res/MissionArchiveStatusRes.java +++ b/src/main/java/com/moing/backend/domain/missionArchive/application/dto/res/MissionArchiveStatusRes.java @@ -1,10 +1,14 @@ package com.moing.backend.domain.missionArchive.application.dto.res; +import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; +import lombok.NoArgsConstructor; -@Getter +@AllArgsConstructor @Builder +@NoArgsConstructor +@Getter public class MissionArchiveStatusRes { private String total; private String done; 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 cdd4a2d3..01f630d8 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 @@ -1,12 +1,11 @@ package com.moing.backend.domain.missionArchive.application.dto.res; -import lombok.Builder; -import lombok.Getter; -import lombok.Setter; +import lombok.*; -@Getter -@Setter +@AllArgsConstructor @Builder +@NoArgsConstructor +@Getter public class PersonalArchiveRes { private Long archiveId; diff --git a/src/main/java/com/moing/backend/domain/missionArchive/application/service/MissionArchiveReadUseCase.java b/src/main/java/com/moing/backend/domain/missionArchive/application/service/MissionArchiveReadUseCase.java index ceac49f3..afd6c0aa 100644 --- a/src/main/java/com/moing/backend/domain/missionArchive/application/service/MissionArchiveReadUseCase.java +++ b/src/main/java/com/moing/backend/domain/missionArchive/application/service/MissionArchiveReadUseCase.java @@ -4,6 +4,7 @@ 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.service.MissionQueryService; +import com.moing.backend.domain.missionArchive.application.dto.res.MissionArchivePhotoRes; import com.moing.backend.domain.missionArchive.application.dto.res.MissionArchiveRes; import com.moing.backend.domain.missionArchive.application.dto.res.MissionArchiveStatusRes; import com.moing.backend.domain.missionArchive.application.dto.res.PersonalArchiveRes; @@ -11,6 +12,7 @@ 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.repository.TeamRepository; +import com.moing.backend.domain.team.domain.service.TeamGetService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -27,7 +29,7 @@ public class MissionArchiveReadUseCase { private final MemberGetService memberGetService; private final MissionQueryService missionQueryService; private final MissionArchiveQueryService missionArchiveQueryService; - private final TeamRepository teamRepository; + private final TeamGetService teamGetService; // 미션 인증 조회 @@ -35,7 +37,7 @@ public List getMyArchive(String userSocialId, Long missionId) Long memberId = memberGetService.getMemberBySocialId(userSocialId).getMemberId(); - return MissionArchiveMapper.mapToMissionArchiveResList(missionArchiveQueryService.findMyArchive(memberId, missionId),memberId); + return MissionArchiveMapper.mapToMissionArchiveResList(missionArchiveQueryService.findMyArchive(memberId, missionId), memberId); } // 모두의 미션 인증 목록 조회 @@ -44,7 +46,7 @@ public List getPersonalArchive(String userSocialId, Long mis List personalArchives = new ArrayList<>(); Long memberId = memberGetService.getMemberBySocialId(userSocialId).getMemberId(); - return MissionArchiveMapper.mapToPersonalArchiveList(missionArchiveQueryService.findOthersArchive(memberId, missionId),memberId); + return MissionArchiveMapper.mapToPersonalArchiveList(missionArchiveQueryService.findOthersArchive(memberId, missionId), memberId); } public MissionArchiveStatusRes getMissionDoneStatus(Long missionId) { @@ -59,4 +61,6 @@ public MissionArchiveStatusRes getMissionDoneStatus(Long missionId) { } + + } 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 665b9444..c2ef9ad9 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 @@ -15,7 +15,8 @@ public enum MissionArchiveResponseMessage { MISSION_ARCHIVE_PEOPLE_STATUS_SUCCESS("미션 인증 성공한 인원 상태 조회를 완료 했습니다."), ACTIVE_SINGLE_MISSION_SUCCESS("진행 중인 한번 인증 미션 조회를 완료 했습니다."), ACTIVE_REPEAT_MISSION_SUCCESS("진행 중인 반복 인증 미션 조회를 완료 했습니다."), - FINISH_ALL_MISSION_SUCCESS("종료된 미션 조회를 완료하였습니다."); + FINISH_ALL_MISSION_SUCCESS("종료된 미션 조회를 완료하였습니다."), + MISSION_ARCHIVE_BY_TEAM("팀별 미션 인증물 사진 조회를 완료했습니더."); private final String message; 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 06d642b1..fe6014d9 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 @@ -1,9 +1,9 @@ package com.moing.backend.domain.missionArchive.domain.repository; import com.moing.backend.domain.mission.application.dto.res.FinishMissionBoardRes; -import com.moing.backend.domain.mission.application.dto.res.GatherSingleMissionRes; import com.moing.backend.domain.mission.application.dto.res.RepeatMissionBoardRes; import com.moing.backend.domain.mission.domain.entity.constant.MissionStatus; +import com.moing.backend.domain.missionArchive.application.dto.res.MissionArchivePhotoRes; import com.moing.backend.domain.missionArchive.domain.entity.MissionArchive; import com.moing.backend.domain.missionArchive.domain.entity.MissionArchiveStatus; import org.springframework.stereotype.Repository; @@ -24,5 +24,7 @@ public interface MissionArchiveCustomRepository { Optional> findFinishMissionsByStatus(Long memberId, Long teamId); + Optional> findTop5ArchivesByTeam(List teamIds); + } 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 6949157a..a572ae9f 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 @@ -1,23 +1,19 @@ package com.moing.backend.domain.missionArchive.domain.repository; import com.moing.backend.domain.mission.application.dto.res.FinishMissionBoardRes; -import com.moing.backend.domain.mission.application.dto.res.GatherSingleMissionRes; 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.constant.MissionStatus; import com.moing.backend.domain.mission.domain.entity.constant.MissionType; -import com.moing.backend.domain.missionArchive.application.dto.res.MissionArchiveRes; +import com.moing.backend.domain.missionArchive.application.dto.res.MissionArchivePhotoRes; import com.moing.backend.domain.missionArchive.domain.entity.MissionArchive; import com.moing.backend.domain.missionArchive.domain.entity.MissionArchiveStatus; -import com.moing.backend.domain.team.domain.entity.Team; +import com.querydsl.core.Tuple; import com.querydsl.core.types.Expression; import com.querydsl.core.types.Order; import com.querydsl.core.types.OrderSpecifier; import com.querydsl.core.types.Projections; import com.querydsl.core.types.dsl.Expressions; import com.querydsl.jpa.impl.JPAQueryFactory; -import feign.Param; -import org.springframework.data.jpa.repository.Query; import javax.persistence.EntityManager; import java.util.ArrayList; @@ -26,7 +22,6 @@ import static com.moing.backend.domain.mission.domain.entity.QMission.mission; import static com.moing.backend.domain.missionArchive.domain.entity.QMissionArchive.*; -import static com.moing.backend.domain.missionHeart.domain.entity.QMissionHeart.missionHeart; import static javax.swing.Spring.constant; public class MissionArchiveCustomRepositoryImpl implements MissionArchiveCustomRepository { @@ -181,4 +176,38 @@ public Optional> findFinishMissionsByStatus(Long mem } + public Optional> findTop5ArchivesByTeam(List teamIds) { + List queryResults = queryFactory + .select(missionArchive.mission.team.teamId, missionArchive.archive) + .from(missionArchive) + .where(missionArchive.mission.team.teamId.in(teamIds)) + .orderBy(missionArchive.createdDate.desc()) + .limit(14) + .fetch(); + + List resultDTOs = new ArrayList<>(); + + for (Tuple tuple : queryResults) { + Long teamId = tuple.get(missionArchive.mission.team.teamId); + String photo = tuple.get(missionArchive.archive); + + // Check if a TeamPhotoDTO with the same teamId already exists in the list + MissionArchivePhotoRes existingDTO = resultDTOs.stream() + .filter(dto -> dto.getTeamId().equals(teamId)) + .findFirst() + .orElse(null); + + if (existingDTO != null) { + existingDTO.getPhoto().add(photo); + } else { + List photoList = new ArrayList<>(); + photoList.add(photo); + resultDTOs.add(new MissionArchivePhotoRes(teamId, photoList)); + } + } + + return Optional.ofNullable(resultDTOs); + } + + } 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 ff10c3bd..5054882e 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 @@ -5,6 +5,7 @@ import com.moing.backend.domain.mission.application.dto.res.RepeatMissionBoardRes; import com.moing.backend.domain.mission.domain.entity.constant.MissionStatus; import com.moing.backend.domain.mission.domain.repository.MissionRepository; +import com.moing.backend.domain.missionArchive.application.dto.res.MissionArchivePhotoRes; import com.moing.backend.domain.missionArchive.domain.entity.MissionArchive; import com.moing.backend.domain.missionArchive.domain.repository.MissionArchiveRepository; import com.moing.backend.domain.missionArchive.exception.NotFoundMissionArchiveException; @@ -99,6 +100,9 @@ public List findMyFinishMissions(Long memberId, Long team return missionArchiveRepository.findFinishMissionsByStatus(memberId, teamId).orElseThrow(NotFoundMissionArchiveException::new); } + public List findTop5ArchivesByTeam(List teamIds) { + return missionArchiveRepository.findTop5ArchivesByTeam(teamIds).orElse(null); + } 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 c8af182b..88625bb8 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 @@ -1,5 +1,6 @@ package com.moing.backend.domain.missionArchive.presentation; +import com.moing.backend.domain.mission.application.dto.res.GatherRepeatMissionRes; 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.dto.res.MissionArchiveStatusRes; @@ -131,4 +132,6 @@ public ResponseEntity> getMyMissionDone + + } \ No newline at end of file diff --git a/src/main/java/com/moing/backend/domain/missionArchive/presentation/MissionGatherController.java b/src/main/java/com/moing/backend/domain/missionArchive/presentation/MissionGatherController.java index 7a964bd6..639c329a 100644 --- a/src/main/java/com/moing/backend/domain/missionArchive/presentation/MissionGatherController.java +++ b/src/main/java/com/moing/backend/domain/missionArchive/presentation/MissionGatherController.java @@ -5,6 +5,8 @@ import com.moing.backend.domain.mission.application.dto.res.RepeatMissionBoardRes; import com.moing.backend.domain.mission.application.service.MissionArchiveBoardUseCase; 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.service.MissionArchiveReadUseCase; import com.moing.backend.global.config.security.dto.User; import com.moing.backend.global.response.SuccessResponse; import lombok.AllArgsConstructor; @@ -50,4 +52,14 @@ public ResponseEntity>> getMyActive } + @GetMapping("/my-teams") + public ResponseEntity>> getArchivesByTeam(@AuthenticationPrincipal User user) { + return ResponseEntity.ok(SuccessResponse.create(MISSION_ARCHIVE_BY_TEAM.getMessage(), this.missionGatherBoardUseCase.getArchivePhotoByTeamRes(user.getSocialId()))); + } + + + + + + } diff --git a/src/main/java/com/moing/backend/domain/missionHeart/application/dto/MissionHeartRes.java b/src/main/java/com/moing/backend/domain/missionHeart/application/dto/MissionHeartRes.java index ee0634a9..8f403439 100644 --- a/src/main/java/com/moing/backend/domain/missionHeart/application/dto/MissionHeartRes.java +++ b/src/main/java/com/moing/backend/domain/missionHeart/application/dto/MissionHeartRes.java @@ -1,10 +1,14 @@ package com.moing.backend.domain.missionHeart.application.dto; +import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; +import lombok.NoArgsConstructor; -@Getter +@AllArgsConstructor @Builder +@NoArgsConstructor +@Getter public class MissionHeartRes { private Long missionArchiveId; private String missionHeartStatus; 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 d036c41b..095fc040 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 @@ -64,8 +64,8 @@ public class MissionControllerTest extends CommonControllerTest { .rule("rule") .content("content") .number(1) - .type("ONCE") - .way("TEXT") + .type("ONCE/REPEAT") + .way("TEXT/PHOTO/LINK") .build(); String body = objectMapper.writeValueAsString(input); @@ -73,13 +73,13 @@ public class MissionControllerTest extends CommonControllerTest { MissionCreateRes output = MissionCreateRes.builder() .missionId(1L) .title("title") - .dueTo("dueTo") + .dueTo("2023-12-31 23:39:22.333") .rule("rule") .content("content") .number(1) - .type("TEXT") - .status("WAIT") - .way("TEXT") + .type("ONCE/REPEAT") + .status("END/ONGOING/SUCCESS/FAIL") + .way("TEXT/PHOTO/LINK") .build(); given(missionCreateUseCase.createMission(any(),any(),any())).willReturn(output); @@ -110,7 +110,7 @@ public class MissionControllerTest extends CommonControllerTest { fieldWithPath("rule").description("미션 규칙"), fieldWithPath("content").description("미션 내용"), fieldWithPath("number").description("미션 반복 횟수"), - fieldWithPath("type").description("미션 타입"), + fieldWithPath("type").description("미션 유형(단일/반복)"), fieldWithPath("way").description("미션 진행 방법") ), responseFields( @@ -122,8 +122,8 @@ public class MissionControllerTest extends CommonControllerTest { fieldWithPath("data.rule").description("미션 규칙"), fieldWithPath("data.content").description("미션 내용"), fieldWithPath("data.number").description("미션 반복 횟수"), - fieldWithPath("data.type").description("미션 타입"), - fieldWithPath("data.way").description("미션 진행 방법"), + fieldWithPath("data.type").description("미션 유형(단일/반복)"), + fieldWithPath("data.way").description("미션 진행 방법(사진/글/링크)"), fieldWithPath("data.status").description("미션 진행 상태") ) ) @@ -137,7 +137,7 @@ public class MissionControllerTest extends CommonControllerTest { //given MissionReq input = MissionReq.builder() .title("title") - .dueTo("dueTo") + .dueTo("2023-12-31 23:39:22.333") .rule("rule") .content("content") .number(1) @@ -150,12 +150,12 @@ public class MissionControllerTest extends CommonControllerTest { MissionCreateRes output = MissionCreateRes.builder() .missionId(1L) .title("title") - .dueTo("dueTo") + .dueTo("2023-12-31 23:39:22.333") .rule("rule") .content("content") .number(1) - .type("TEXT") - .status("WAIT") + .type("ONCE") + .status("END") .way("TEXT") .build(); @@ -201,9 +201,9 @@ public class MissionControllerTest extends CommonControllerTest { fieldWithPath("data.rule").description("미션 규칙"), fieldWithPath("data.content").description("미션 내용"), fieldWithPath("data.number").description("미션 반복 횟수"), - fieldWithPath("data.type").description("미션 타입"), - fieldWithPath("data.way").description("미션 진행 방법"), - fieldWithPath("data.status").description("미션 진행 상태") + fieldWithPath("data.type").description("미션 유형(ONCE/REPEAT)"), + fieldWithPath("data.way").description("미션 진행 방법(TEXT/PHOTO/LINK)"), + fieldWithPath("data.status").description("미션 진행 상태(END/ONGOING/SUCCESS/FAIL)") ) ) @@ -219,10 +219,10 @@ public class MissionControllerTest extends CommonControllerTest { MissionReadRes output = MissionReadRes.builder() .title("title") - .dueTo("dueTo") + .dueTo("2023-12-31 23:39:22.333") .rule("rule") .content("content") - .type("TEXT") + .type("ONCE") .way("TEXT") .build(); @@ -257,8 +257,8 @@ public class MissionControllerTest extends CommonControllerTest { fieldWithPath("data.dueTo").description("미션 마감 날짜"), fieldWithPath("data.rule").description("미션 규칙"), fieldWithPath("data.content").description("미션 내용"), - fieldWithPath("data.type").description("미션 타입"), - fieldWithPath("data.way").description("미션 진행 방법") + fieldWithPath("data.way").description("미션 진행 방법(TEXT/PHOTO/LINK)"), + fieldWithPath("data.type").description("미션 유형(ONCE/REPEAT)") ) ) @@ -308,7 +308,7 @@ public class MissionControllerTest extends CommonControllerTest { //given - String output = "" ; + String output = "SPORTS/HABIT/TEST/STUDY/READING/ETC" ; given(missionReadUseCase.getTeamCategory(any())).willReturn(output); 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 dfccb93b..0985af75 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 @@ -3,6 +3,8 @@ import com.moing.backend.config.CommonControllerTest; 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.service.MissionArchiveReadUseCase; import com.moing.backend.domain.missionArchive.presentation.MissionGatherController; import org.assertj.core.util.Lists; import org.junit.jupiter.api.Test; @@ -13,6 +15,7 @@ import org.springframework.test.web.servlet.ResultActions; import org.springframework.test.web.servlet.result.MockMvcResultMatchers; +import java.util.ArrayList; import java.util.List; import static com.moing.backend.domain.missionArchive.domain.constant.MissionArchiveResponseMessage.*; @@ -20,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.*; import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; @@ -124,6 +126,49 @@ public class MissionGatherControllerTest extends CommonControllerTest { .andReturn(); } + @Test + public void 미션_모아보기_팀별() throws Exception { + //given + + List objects = new ArrayList<>(); + objects.add("1"); + objects.add("2"); + + List output = Lists.newArrayList(MissionArchivePhotoRes.builder() + .teamId(1L) + .photo(objects) + .build()); + + given(missionGatherBoardUseCase.getArchivePhotoByTeamRes(any())).willReturn(output); + + //when + ResultActions actions = mockMvc.perform(RestDocumentationRequestBuilders. + get("/api/team/my-teams") + .header("Authorization", "Bearer ACCESS_TOKEN") + .contentType(MediaType.APPLICATION_JSON) + + ); + + //then + actions + .andExpect(MockMvcResultMatchers.status().isOk()) + .andDo( + restDocs.document( + requestHeaders( + headerWithName("Authorization").description("접근 토큰") + ), + + responseFields( + fieldWithPath("isSuccess").description("true"), + fieldWithPath("message").description(MISSION_ARCHIVE_BY_TEAM.getMessage()), + fieldWithPath("data[].teamId").description("팀 아이디"), + fieldWithPath("data[].photo[]").description("팀별 미션 인증물 사진들") + ) + ) + ) + .andReturn(); + + }