-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #281 from Modagbul/MNG-22
MNG-22 : 미션 관련 스케쥴링 추가
- Loading branch information
Showing
8 changed files
with
62 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...ain/java/com/moing/backend/domain/mission/application/service/MissionScheduleUseCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
48 changes: 0 additions & 48 deletions
48
.../java/com/moing/backend/domain/mission/application/service/MissionTerminationUseCase.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 0 additions & 67 deletions
67
...a/com/moing/backend/domain/missionArchive/domain/repository/MissionArchiveRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<MissionArchive, Long>,MissionArchiveCustomRepository { | ||
|
||
@Query("select m from MissionArchive as m where m.member =:memberId" ) | ||
Optional<List<MissionArchive>> 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<List<MissionArchive>> 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<MissionArchive> 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<List<MissionArchive>> findRepeatMissionArchivesByMission (@Param("memberId") Long memberId, @Param("missionIds") List <Long> 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<List<MemberIdAndToken>> 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<List<Map<String, Long>>> 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<List<MemberIdAndToken>> findHavingRemainMissions(); | ||
|
||
|
||
|
||
|
||
} |
Oops, something went wrong.