-
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 #48 from Do-Farming/feat/minjoo/dailyMissionSchedu…
…lar/#39 dailyRank insert
- Loading branch information
Showing
11 changed files
with
167 additions
and
10 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
src/main/java/com/hana/api/dailyRank/repository/DailyRankRepository.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,12 @@ | ||
package com.hana.api.dailyRank.repository; | ||
|
||
import com.hana.api.dailyRank.entity.DailyRank; | ||
import com.hana.api.group.entity.Group; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
|
||
public interface DailyRankRepository extends JpaRepository<DailyRank, Long> { | ||
} |
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
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
9 changes: 9 additions & 0 deletions
9
src/main/java/com/hana/api/weeklyRate/repository/WeeklyRateRepository.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,9 @@ | ||
package com.hana.api.weeklyRate.repository; | ||
|
||
import com.hana.api.weeklyRate.entity.WeeklyRate; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface WeeklyRateRepository extends JpaRepository<WeeklyRate, Long> { | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/com/hana/api/weeklyRate/service/WeeklyRateService.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,24 @@ | ||
package com.hana.api.weeklyRate.service; | ||
|
||
import com.hana.api.challenge.entity.ChallengeRecord; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.time.LocalDate; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class WeeklyRateService { | ||
|
||
@Transactional | ||
public void insertDailyChallengeRecord() { | ||
LocalDate today = LocalDate.now(); | ||
int randomNumber = (int) (Math.random() * 3); | ||
ChallengeRecord challengeRecord = ChallengeRecord.builder() | ||
.challengeDate(today.plusDays(1).atStartOfDay()) | ||
.challengeType(randomNumber).build(); | ||
} | ||
} |
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
46 changes: 46 additions & 0 deletions
46
src/main/java/com/hana/common/job/challenge/InsertWeeklyRateConfig.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,46 @@ | ||
package com.hana.common.job.challenge; | ||
|
||
import com.hana.common.job.InsertDailyChallengeTasklet; | ||
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.DuplicateJobException; | ||
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; | ||
import org.springframework.batch.core.configuration.annotation.JobScope; | ||
import org.springframework.batch.core.configuration.support.DefaultBatchConfiguration; | ||
import org.springframework.batch.core.job.builder.JobBuilder; | ||
import org.springframework.batch.core.repository.JobRepository; | ||
import org.springframework.batch.core.step.builder.StepBuilder; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.transaction.PlatformTransactionManager; | ||
|
||
import java.time.LocalDate; | ||
|
||
@Configuration | ||
@RequiredArgsConstructor | ||
@EnableBatchProcessing | ||
@Slf4j | ||
public class InsertWeeklyRateConfig extends DefaultBatchConfiguration { | ||
|
||
private final JobRepository jobRepository; | ||
private final PlatformTransactionManager transactionManager; | ||
private final InsertWeeklyRateTasklet insertWeeklyTasklet; | ||
|
||
@Bean | ||
public Job insertWeeklyRateJob() { | ||
return new JobBuilder("insertWeeklyJob", jobRepository) | ||
.start(insertWeeklyRateStep()) | ||
.build(); | ||
} | ||
|
||
@Bean | ||
@JobScope | ||
public Step insertWeeklyRateStep() { | ||
return new StepBuilder("insertWeeklyStep", jobRepository) | ||
.tasklet(insertWeeklyTasklet, transactionManager) | ||
.build(); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/com/hana/common/job/challenge/InsertWeeklyRateTasklet.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,19 @@ | ||
package com.hana.common.job.challenge; | ||
|
||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.batch.core.StepContribution; | ||
import org.springframework.batch.core.scope.context.ChunkContext; | ||
import org.springframework.batch.core.step.tasklet.Tasklet; | ||
import org.springframework.batch.repeat.RepeatStatus; | ||
import org.springframework.stereotype.Component; | ||
|
||
@RequiredArgsConstructor | ||
@Component | ||
public class InsertWeeklyRateTasklet implements Tasklet { | ||
|
||
@Override | ||
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { | ||
return null; | ||
} | ||
} |
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