diff --git a/cider-api/src/main/java/com/cmc/domains/certify/service/CertifyService.java b/cider-api/src/main/java/com/cmc/domains/certify/service/CertifyService.java index 16067e3..324c181 100644 --- a/cider-api/src/main/java/com/cmc/domains/certify/service/CertifyService.java +++ b/cider-api/src/main/java/com/cmc/domains/certify/service/CertifyService.java @@ -13,6 +13,7 @@ import com.cmc.domains.certify.repository.CertifyRepository; import com.cmc.domains.certifyLike.repository.CertifyLikeRepository; import com.cmc.domains.challenge.repository.ChallengeRepository; +import com.cmc.domains.image.certifyExample.repository.CertifyExampleImageRepository; import com.cmc.domains.member.repository.MemberRepository; import com.cmc.domains.participate.repository.ParticipateRepository; import com.cmc.member.Member; @@ -34,6 +35,7 @@ public class CertifyService { private final ChallengeRepository challengeRepository; private final MemberRepository memberRepository; private final CertifyLikeRepository certifyLikeRepository; + private final CertifyExampleImageRepository certifyExampleImageRepository; // 인증 생성 public Certify create(Long challengeId, String certifyName, String certifyContent, Long memberId) { @@ -130,16 +132,17 @@ public void deleteChallenge(Long memberId, Long challengeId) { } // TODO : 생성자 검토 -// for(Participate participate : member.getParticipates()){ -// if(participate.getChallenge().equals(challenge)){ -// if(!participate.getIsCreator()){ -// throw new CiderException("챌린지를 삭제할 권한이 없습니다."); -// } -// else{ -// challengeRepository.deleteById(challengeId); -// } -// } -// } + for(Participate participate : member.getParticipates()){ + if(participate.getChallenge().equals(challenge)){ + if(!participate.getIsCreator()){ + throw new CiderException("챌린지를 삭제할 권한이 없습니다."); + } + else{ + certifyExampleImageRepository.deleteAll(challenge.getCertifyExampleImageList()); + challengeRepository.deleteById(challengeId); + } + } + } } private Challenge findChallengeOrThrow(Long challengeId){ diff --git a/cider-api/src/main/java/com/cmc/domains/challenge/dto/response/my/OngoingChallengeResponseDto.java b/cider-api/src/main/java/com/cmc/domains/challenge/dto/response/my/OngoingChallengeResponseDto.java index 9b2fa61..d9183fc 100644 --- a/cider-api/src/main/java/com/cmc/domains/challenge/dto/response/my/OngoingChallengeResponseDto.java +++ b/cider-api/src/main/java/com/cmc/domains/challenge/dto/response/my/OngoingChallengeResponseDto.java @@ -5,6 +5,7 @@ import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; +import lombok.extern.slf4j.Slf4j; import java.time.LocalDateTime; import java.time.temporal.ChronoUnit; @@ -13,6 +14,7 @@ @Data @Builder @AllArgsConstructor +@Slf4j public class OngoingChallengeResponseDto { @Schema(description = "챌린지 제목", example = "소비습관 고치기") @@ -32,6 +34,7 @@ public class OngoingChallengeResponseDto { public static OngoingChallengeResponseDto from(Challenge challenge, Integer certifyNum){ + log.info("challengeID :::::::: " + challenge.getChallengeId()); return new OngoingChallengeResponseDtoBuilder() .challengeName(challenge.getChallengeName()) .challengeBranch(String.valueOf(challenge.getChallengeBranch())) diff --git a/cider-api/src/main/java/com/cmc/domains/challenge/repository/ChallengeCustomRepositoryImpl.java b/cider-api/src/main/java/com/cmc/domains/challenge/repository/ChallengeCustomRepositoryImpl.java index 5aa9aff..c872a1b 100644 --- a/cider-api/src/main/java/com/cmc/domains/challenge/repository/ChallengeCustomRepositoryImpl.java +++ b/cider-api/src/main/java/com/cmc/domains/challenge/repository/ChallengeCustomRepositoryImpl.java @@ -206,6 +206,8 @@ public List getMyOngoingChallenge(Long memberId) { return jpaQueryFactory.selectFrom(challenge) .leftJoin(participate).on(challenge.challengeId.eq(participate.challenge.challengeId)) .where(participate.participateStatus.eq(ParticipateStatus.ONGOING) + .and(participate.challenge.challengeStatus.eq(ChallengeStatus.POSSIBLE) + .or(participate.challenge.challengeStatus.eq(ChallengeStatus.IMPOSSIBLE))) .and(participate.member.memberId.eq(memberId))) .fetch(); }