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 61fb3d1e..1e651bdd 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 @@ -22,40 +22,44 @@ public class MissionRemindAlarmUseCase { public void sendRemindMissionAlarm(Mission mission) { + + Random random = new Random(System.currentTimeMillis()); - String title = getTitle("receiver",random.nextInt(4)); - String message = getMessage(mission.getTitle(),random.nextInt(4)); + + + String title = getTitle(random.nextInt(4)); + String message = getMessage(random.nextInt(4)); MultiRequest multiRequest = new MultiRequest(); } - public String getTitle(String receiver, int num) { + public String getTitle(int num) { switch (num) { case 0: - return receiver + REMIND_MISSION_TITLE1.getMessage(); + return REMIND_MISSION_TITLE1.getMessage(); case 1: - return receiver + REMIND_MISSION_TITLE2.getMessage(); + return REMIND_MISSION_TITLE2.getMessage(); case 2: - return receiver + REMIND_MISSION_TITLE3.getMessage(); + return REMIND_MISSION_TITLE3.getMessage(); case 3: - return receiver + REMIND_MISSION_TITLE4.getMessage(); + return REMIND_MISSION_TITLE4.getMessage(); } - return receiver + REMIND_MISSION_TITLE4.getMessage(); + return REMIND_MISSION_TITLE4.getMessage(); } - public String getMessage(String missionTitle, int num) { + public String getMessage(int num) { switch (num) { case 0: - return missionTitle + REMIND_MISSION_MESSAGE1.getMessage(); + return REMIND_MISSION_MESSAGE1.getMessage(); case 1: - return missionTitle + REMIND_MISSION_MESSAGE2.getMessage(); + return REMIND_MISSION_MESSAGE2.getMessage(); case 2: - return missionTitle + REMIND_MISSION_MESSAGE3.getMessage(); + return REMIND_MISSION_MESSAGE3.getMessage(); case 3: - return missionTitle + REMIND_MISSION_MESSAGE4.getMessage(); + return REMIND_MISSION_MESSAGE4.getMessage(); } - return missionTitle + REMIND_MISSION_MESSAGE4.getMessage(); + return REMIND_MISSION_MESSAGE4.getMessage(); } 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 66177310..f99d2e9e 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 @@ -5,6 +5,7 @@ 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.missionArchive.domain.entity.MissionArchive; +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; @@ -49,6 +50,9 @@ public class Mission extends BaseTimeEntity { @OneToMany(mappedBy = "mission") List missionArchiveList = new ArrayList<>(); + + @OneToMany(mappedBy = "mission") + List missionStateList = new ArrayList<>(); @Builder public Mission(String title, LocalDateTime dueTo, String rule, String content, int number, Team team, MissionType type, MissionStatus status, MissionWay way) { 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 e35e1b7d..d19c1a12 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 @@ -6,10 +6,12 @@ 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.QMissionArchive; 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.JPQLQuery; import com.querydsl.jpa.impl.JPAQueryFactory; import javax.persistence.EntityManager; @@ -58,15 +60,17 @@ public Optional> findRepeatMissionByMemberId(Long m .leftJoin(missionArchive) .on(missionArchive.mission.eq(mission), missionArchive.member.memberId.eq(memberId) -// ,missionArchive.count.max().loe(missionArchive.mission.number) ) .where( mission.team.teamId.in(teams), mission.status.eq(MissionStatus.ONGOING), mission.type.eq(MissionType.REPEAT) + ) - .groupBy(mission.id) - .orderBy(missionArchive.count().desc()) + .groupBy(mission.id,mission.number) +// .having(missionArchive.count().lt(mission.number)) // HAVING 절을 사용하여 조건 적용 + + .orderBy(missionArchive.count().desc()) .fetch()); } 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 b154c6ce..31c9b26f 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 @@ -19,6 +19,8 @@ public class MissionArchiveRes { private String heartStatus; private Long hearts; + private boolean isAbleToEdit; + } 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 493c1448..a3c684dc 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 @@ -39,6 +39,7 @@ public class MissionArchive extends BaseTimeEntity { // 1회 미션을 저장 @Enumerated(value = EnumType.STRING) private MissionArchiveStatus status; + @Column(nullable = false, columnDefinition="TEXT", length = 4000) private String archive; //링크, 글, 사진 뭐든 가능 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 d46cea25..3bd7464f 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,5 +1,6 @@ package com.moing.backend.domain.missionArchive.domain.repository; +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; @@ -31,4 +32,7 @@ public interface MissionArchiveCustomRepository { Boolean findMyArchivesToday(Long memberId,Long missionId); + Optional> findPeopleRemainMission(); + + } 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 4a87d55b..4ac50f5d 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,5 +1,6 @@ package com.moing.backend.domain.missionArchive.domain.repository; +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; @@ -22,6 +23,7 @@ import org.springframework.data.jpa.repository.Query; import javax.persistence.EntityManager; +import javax.swing.text.html.Option; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; @@ -30,7 +32,11 @@ 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.missionState.domain.entity.QMissionState.missionState; +import static com.moing.backend.domain.team.domain.entity.QTeam.team; +import static com.moing.backend.domain.teamMember.domain.entity.QTeamMember.teamMember; import static javax.swing.Spring.constant; +import static org.springframework.data.jpa.domain.Specification.where; + @Slf4j public class MissionArchiveCustomRepositoryImpl implements MissionArchiveCustomRepository { @@ -294,5 +300,26 @@ public Boolean findMyArchivesToday(Long memberId, Long missionId) { } + public Optional> findPeopleRemainMission() { + return Optional.ofNullable(queryFactory + .select(teamMember.member.nickName).distinct() + .from(teamMember) + .join(teamMember.team, team) + .join(team.missions, mission) + .join(mission.missionStateList,missionState) + .where(missionState.isNull()) + .fetch()); +// .where( +// // active 한 미션 필터링 +// (((mission.status.eq(MissionStatus.ONGOING).or(mission.status.eq(MissionStatus.WAIT))).and(mission.type.eq(MissionType.ONCE))) +// .or((mission.status.eq(MissionStatus.ONGOING)).and(mission.type.eq(MissionType.REPEAT)))), +// // 인증하지 않은값 +// missionState.id.isNull() + + +// ).fetch()); + } + + } 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 804a5b01..4b6065b5 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 @@ -7,10 +7,12 @@ 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 java.util.List; import java.util.Optional; +@Repository public interface MissionArchiveRepository extends JpaRepository,MissionArchiveCustomRepository { @Query("select m from MissionArchive as m where m.member =:memberId" ) diff --git a/src/main/java/com/moing/backend/domain/missionArchive/domain/service/MissionArchiveScheduleQueryService.java b/src/main/java/com/moing/backend/domain/missionArchive/domain/service/MissionArchiveScheduleQueryService.java new file mode 100644 index 00000000..e2f8585c --- /dev/null +++ b/src/main/java/com/moing/backend/domain/missionArchive/domain/service/MissionArchiveScheduleQueryService.java @@ -0,0 +1,25 @@ +package com.moing.backend.domain.missionArchive.domain.service; + +import com.moing.backend.domain.member.domain.entity.Member; +import com.moing.backend.domain.missionArchive.application.dto.res.MissionArchiveRes; +import com.moing.backend.domain.missionArchive.domain.repository.MissionArchiveRepository; +import com.moing.backend.global.annotation.DomainService; +import lombok.RequiredArgsConstructor; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +@DomainService +@Transactional +@RequiredArgsConstructor +public class MissionArchiveScheduleQueryService { + + + private final MissionArchiveRepository missionArchiveRepository; + + public List getRemainMissionPeople() { + return missionArchiveRepository.findPeopleRemainMission().orElseThrow(); + } + + +} 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 c5e61787..3f0a41f5 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,6 +1,5 @@ package com.moing.backend.domain.missionArchive.presentation; - import com.moing.backend.domain.member.domain.entity.Member; import com.moing.backend.domain.mission.application.dto.res.GatherRepeatMissionRes; import com.moing.backend.domain.missionArchive.application.dto.req.MissionArchiveReq; @@ -10,7 +9,9 @@ import com.moing.backend.domain.missionArchive.application.dto.res.PersonalArchiveRes; import com.moing.backend.domain.missionArchive.application.service.*; + import com.moing.backend.domain.missionArchive.domain.service.MissionArchiveDeleteService; + import com.moing.backend.domain.missionHeart.application.dto.MissionHeartRes; import com.moing.backend.domain.missionHeart.application.service.MissionHeartUseCase; import com.moing.backend.global.config.security.dto.User; 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 index 788b602c..22a550b8 100644 --- 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 @@ -23,7 +23,7 @@ public class MissionState extends BaseTimeEntity { @Column(name = "missionState_id") private Long id; - @OneToOne(fetch = FetchType.LAZY) + @ManyToOne(fetch = FetchType.LAZY) private Mission mission; @OneToOne private Member member; diff --git a/src/main/java/com/moing/backend/global/config/fcm/constant/RemindMissionTitle.java b/src/main/java/com/moing/backend/global/config/fcm/constant/RemindMissionTitle.java index d387ca59..662d90e9 100644 --- a/src/main/java/com/moing/backend/global/config/fcm/constant/RemindMissionTitle.java +++ b/src/main/java/com/moing/backend/global/config/fcm/constant/RemindMissionTitle.java @@ -7,16 +7,16 @@ @RequiredArgsConstructor public enum RemindMissionTitle { - REMIND_MISSION_TITLE1("님, 오늘도 좋은하루!"), - REMIND_MISSION_TITLE2("님, 잊으신 건 아니죠?\uD83D\uDC40"), - REMIND_MISSION_TITLE3("님, 좋은 아침이에요! ☀\uFE0F"), + REMIND_MISSION_TITLE1("오늘도 좋은 하루 보내세요!"), + REMIND_MISSION_TITLE2("혹시 ... 잊으신 건 아니죠?\uD83D\uDC40"), + REMIND_MISSION_TITLE3("좋은 아침이에요! ☀\uFE0F"), REMIND_MISSION_TITLE4("오늘의 열정이 타오르불\uD83D\uDD25"), - REMIND_MISSION_MESSAGE1(" 도전과 함께⚡\uFE0F "), - REMIND_MISSION_MESSAGE2(" 인증을 모임원들이 기다리고 있어요!"), - REMIND_MISSION_MESSAGE3(" 수행하고 이번주도 도전해요👊 "), - REMIND_MISSION_MESSAGE4(" 도전하고 성취감 뿜뿜💪 "); + REMIND_MISSION_MESSAGE1(" 자기계발 미션 도전과 함께⚡\uFE0F "), + REMIND_MISSION_MESSAGE2(" 미션 인증을 모임원들이 기다리고 있어요!"), + REMIND_MISSION_MESSAGE3(" 미션 인증하고 이번주도 도전해요👊 "), + REMIND_MISSION_MESSAGE4(" 미션 도전하고 성취감 뿜뿜💪 "); private final String message; diff --git a/src/test/java/com/moing/backend/domain/missionArchive/domain/repository/MissionArchiveCustomRepositoryImplTest.java b/src/test/java/com/moing/backend/domain/missionArchive/domain/repository/MissionArchiveCustomRepositoryImplTest.java new file mode 100644 index 00000000..37889c66 --- /dev/null +++ b/src/test/java/com/moing/backend/domain/missionArchive/domain/repository/MissionArchiveCustomRepositoryImplTest.java @@ -0,0 +1,29 @@ +//package com.moing.backend.domain.missionArchive.domain.repository; +// +//import com.querydsl.jpa.impl.JPAQueryFactory; +//import org.junit.jupiter.api.Test; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.boot.test.context.SpringBootTest; +// +//import javax.persistence.EntityManager; +//import java.util.List; +//import java.util.Optional; +// +//import static com.moing.backend.domain.mission.domain.entity.QMission.mission; +//import static com.moing.backend.domain.missionState.domain.entity.QMissionState.missionState; +//@SpringBootTest +//class MissionArchiveCustomRepositoryImplTest { +// +// @Autowired +// EntityManager em; +// +// @Autowired +// private MissionArchiveRepository missionArchiveRepository; +// +// @Test +// void findPeopleRemainMission() { +// +// System.out.println("!!!"+ missionArchiveRepository.findPeopleRemainMission()); +// +// } +//} \ No newline at end of file