-
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 #73 from Modagbul/feat/mission-closing
feat/mission : 미션 관련 전반적인 버그 수정 및 기능 구현
- Loading branch information
Showing
30 changed files
with
597 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,4 +49,5 @@ data.sql | |
#### docs #### | ||
!**/src/main/resources/static/docs/ | ||
*.html | ||
firebase-key.json | ||
|
||
firebase-key.json |
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
55 changes: 55 additions & 0 deletions
55
src/main/java/com/moing/backend/domain/fire/application/service/FireThrowAlarmUseCase.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,55 @@ | ||
package com.moing.backend.domain.fire.application.service; | ||
|
||
import com.moing.backend.domain.member.domain.entity.Member; | ||
import com.moing.backend.global.config.fcm.dto.request.SingleRequest; | ||
import com.moing.backend.global.config.fcm.service.FcmService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
import javax.transaction.Transactional; | ||
|
||
import java.util.Random; | ||
|
||
import static com.moing.backend.global.config.fcm.constant.FireThrowMessage.*; | ||
import static java.lang.Math.random; | ||
|
||
@Service | ||
@Transactional | ||
@RequiredArgsConstructor | ||
public class FireThrowAlarmUseCase { | ||
|
||
private final FcmService fcmService; | ||
|
||
public void sendFireThrowAlarm(Member throwMember, Member receiveMember) { | ||
|
||
Random random = new Random(System.currentTimeMillis()); | ||
String title = getTitle(throwMember.getNickName(), receiveMember.getNickName(), random.nextInt(2)); | ||
|
||
String message = getMessage(throwMember.getNickName(), receiveMember.getNickName(), random.nextInt(2)); | ||
SingleRequest singleRequest = new SingleRequest(receiveMember.getFcmToken(), title, message); | ||
|
||
fcmService.sendSingleDevice(singleRequest); | ||
} | ||
|
||
public String getMessage(String pusher, String receiver, int num) { | ||
|
||
switch (num) { | ||
case 0: return pusher + "님이" + receiver + NEW_FIRE_THROW_MESSAGE1.getMessage(); | ||
case 1: return receiver + "님! " + pusher + NEW_FIRE_THROW_MESSAGE2.getMessage(); | ||
} | ||
return pusher + "님이" + receiver + NEW_FIRE_THROW_MESSAGE1.getMessage(); | ||
} | ||
|
||
public String getTitle(String pusher, String receiver, int num) { | ||
|
||
switch (num) { | ||
case 0: | ||
return NEW_FIRE_THROW_TITLE1.getMessage(); | ||
case 1: | ||
return NEW_FIRE_THROW_TITLE2.getMessage(); | ||
} | ||
return NEW_FIRE_THROW_TITLE1.getMessage(); | ||
} | ||
|
||
|
||
} |
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
4 changes: 0 additions & 4 deletions
4
...main/java/com/moing/backend/domain/mission/application/service/MissionCheckScheduler.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
62 changes: 62 additions & 0 deletions
62
.../java/com/moing/backend/domain/mission/application/service/MissionRemindAlarmUseCase.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,62 @@ | ||
package com.moing.backend.domain.mission.application.service; | ||
|
||
import com.moing.backend.domain.mission.domain.entity.Mission; | ||
import com.moing.backend.global.config.fcm.dto.request.MultiRequest; | ||
import com.moing.backend.global.config.fcm.service.FcmService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
import javax.transaction.Transactional; | ||
|
||
import java.util.Random; | ||
|
||
import static com.moing.backend.global.config.fcm.constant.RemindMissionTitle.*; | ||
import static java.lang.Math.random; | ||
|
||
@Service | ||
@Transactional | ||
@RequiredArgsConstructor | ||
public class MissionRemindAlarmUseCase { | ||
|
||
private final FcmService fcmService; | ||
|
||
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)); | ||
|
||
MultiRequest multiRequest = new MultiRequest(); | ||
} | ||
|
||
public String getTitle(String receiver, int num) { | ||
switch (num) { | ||
case 0: | ||
return receiver + REMIND_MISSION_TITLE1.getMessage(); | ||
case 1: | ||
return receiver + REMIND_MISSION_TITLE2.getMessage(); | ||
case 2: | ||
return receiver + REMIND_MISSION_TITLE3.getMessage(); | ||
case 3: | ||
return receiver + REMIND_MISSION_TITLE4.getMessage(); | ||
} | ||
return receiver + REMIND_MISSION_TITLE4.getMessage(); | ||
|
||
} | ||
public String getMessage(String missionTitle, int num) { | ||
switch (num) { | ||
case 0: | ||
return missionTitle + REMIND_MISSION_MESSAGE1.getMessage(); | ||
case 1: | ||
return missionTitle + REMIND_MISSION_MESSAGE2.getMessage(); | ||
case 2: | ||
return missionTitle + REMIND_MISSION_MESSAGE3.getMessage(); | ||
case 3: | ||
return missionTitle + REMIND_MISSION_MESSAGE4.getMessage(); | ||
} | ||
return missionTitle + REMIND_MISSION_MESSAGE4.getMessage(); | ||
|
||
} | ||
|
||
} |
96 changes: 96 additions & 0 deletions
96
...om/moing/backend/domain/mission/application/service/MissionStateTerminateBatchConfig.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,96 @@ | ||
//package com.moing.backend.domain.mission.application.service; | ||
// | ||
//import com.moing.backend.domain.mission.domain.entity.Mission; | ||
//import com.moing.backend.domain.missionState.domain.entity.MissionState; | ||
//import com.moing.backend.domain.missionState.domain.service.MissionStateDeleteService; | ||
//import com.moing.backend.domain.teamScore.application.service.TeamScoreLogicUseCase; | ||
//import lombok.RequiredArgsConstructor; | ||
//import lombok.extern.slf4j.Slf4j; | ||
//import org.springframework.batch.core.Job; | ||
//import org.springframework.batch.core.Step; | ||
//import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; | ||
//import org.springframework.batch.core.configuration.annotation.JobBuilderFactory; | ||
//import org.springframework.batch.core.configuration.annotation.StepBuilderFactory; | ||
//import org.springframework.batch.core.configuration.annotation.StepScope; | ||
//import org.springframework.batch.item.ItemProcessor; | ||
//import org.springframework.batch.item.database.JpaItemWriter; | ||
//import org.springframework.batch.item.database.JpaPagingItemReader; | ||
//import org.springframework.batch.item.database.builder.JpaItemWriterBuilder; | ||
//import org.springframework.batch.item.database.builder.JpaPagingItemReaderBuilder; | ||
//import org.springframework.context.annotation.Bean; | ||
//import org.springframework.context.annotation.Configuration; | ||
// | ||
//import javax.persistence.EntityManagerFactory; | ||
//import java.util.HashMap; | ||
//import java.util.Map; | ||
// | ||
//@Slf4j | ||
//@Configuration | ||
//@EnableBatchProcessing | ||
//@RequiredArgsConstructor | ||
//public class MissionStateTerminateBatchConfig { | ||
// | ||
// private final JobBuilderFactory jobBuilderFactory; | ||
// private final StepBuilderFactory stepBuilderFactory; | ||
// private final EntityManagerFactory entityManagerFactory; | ||
// | ||
// private final TeamScoreLogicUseCase teamScoreLogicUseCase; | ||
// private final MissionStateDeleteService missionStateDeleteService; | ||
// | ||
// @Bean | ||
// public Job missionTerminateJob() { | ||
// return jobBuilderFactory.get("missionTerminateJob") | ||
// .start(missionTerminateStep()) | ||
// .build(); | ||
// } | ||
// | ||
// @Bean | ||
// public Step missionTerminateStep() { | ||
// return stepBuilderFactory.get("missionTerminateStep") | ||
// .<Mission, Mission>chunk(10) | ||
// .reader(missionReader()) | ||
// .processor(missionProcessor()) | ||
// .writer(missionWriter()) | ||
// .reader(missionStateReader()) | ||
// .processor(missionStateProcessor()) | ||
// .writer(missionStateWriter()) | ||
// .build(); | ||
// } | ||
// | ||
// @Bean | ||
// @StepScope | ||
// public JpaPagingItemReader<Mission,MissionState> missionStateReader() { | ||
// | ||
// Map<String,Object> parameterValues = new HashMap<>(); | ||
// parameterValues.put("missionId", 10000); | ||
// | ||
// .parameterValues(parameterValues) // 쿼리 파라미터 설정 | ||
// | ||
// return new JpaPagingItemReaderBuilder<MissionState>() | ||
// .name("missionStateReader") | ||
// .entityManagerFactory(entityManagerFactory) | ||
// .queryString("SELECT m FROM MissionState m WHERE m.mission_id = :missionId") | ||
// .pageSize(10) | ||
// .build(); | ||
// } | ||
// | ||
// @Bean | ||
// public ItemProcessor<Mission, Mission> missionStateProcessor() { | ||
// return mission -> { | ||
// teamScoreLogicUseCase.updateTeamScore(mission.getId()); | ||
// return mission; | ||
// }; | ||
// } | ||
// | ||
// | ||
// | ||
// @Bean | ||
// public JpaItemWriter<Mission> missionStateWriter() { | ||
// return new JpaItemWriterBuilder<Mission>() | ||
// .entityManagerFactory(entityManagerFactory) | ||
// .build(); | ||
// } | ||
// | ||
// | ||
// | ||
//} |
Oops, something went wrong.