-
Notifications
You must be signed in to change notification settings - Fork 6
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 #104 from kssumin/main
[BE/FIX] 조회 조건 추가
- Loading branch information
Showing
15 changed files
with
169 additions
and
96 deletions.
There are no files selected for viewing
48 changes: 0 additions & 48 deletions
48
BE/eeos/src/main/java/com/blackcompany/eeos/common/support/converter/DateConverter.java
This file was deleted.
Oops, something went wrong.
47 changes: 47 additions & 0 deletions
47
BE/eeos/src/main/java/com/blackcompany/eeos/common/utils/DateConverter.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,47 @@ | ||
package com.blackcompany.eeos.common.utils; | ||
|
||
import java.sql.Timestamp; | ||
import java.time.Instant; | ||
import java.time.LocalDate; | ||
import java.time.ZoneId; | ||
import lombok.experimental.UtilityClass; | ||
|
||
@UtilityClass | ||
public class DateConverter { | ||
private static final String KST = "Asia/Seoul"; | ||
|
||
public static Timestamp toEpochSecond(LocalDate localDate) { | ||
if (localDate == null) { | ||
return null; | ||
} | ||
|
||
return Timestamp.valueOf(localDate.atStartOfDay()); | ||
} | ||
|
||
public static Timestamp toEpochSecond(Timestamp epochSecond) { | ||
if (epochSecond == null) { | ||
return null; | ||
} | ||
|
||
LocalDate localDate = toLocalDate(epochSecond); | ||
return toEpochSecond(localDate); | ||
} | ||
|
||
private static LocalDate toLocalDate(Timestamp epochSecond) { | ||
if (epochSecond == null) { | ||
return null; | ||
} | ||
|
||
return epochSecond.toLocalDateTime().toLocalDate(); | ||
} | ||
|
||
public static LocalDate toLocalDate(Long epochMilli) { | ||
if (epochMilli == null) { | ||
return null; | ||
} | ||
|
||
return Instant.ofEpochSecond(epochMilli / 1000) | ||
.atZone(ZoneId.of(KST)) | ||
.toLocalDate(); | ||
} | ||
} |
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
18 changes: 18 additions & 0 deletions
18
...ain/java/com/blackcompany/eeos/program/application/service/ActiveProgramStateService.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,18 @@ | ||
package com.blackcompany.eeos.program.application.service; | ||
|
||
import com.blackcompany.eeos.program.persistence.ProgramEntity; | ||
import com.blackcompany.eeos.program.persistence.ProgramRepository; | ||
import java.sql.Timestamp; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.PageRequest; | ||
|
||
@RequiredArgsConstructor | ||
public class ActiveProgramStateService implements ProgramStateService { | ||
private final ProgramRepository programRepository; | ||
|
||
@Override | ||
public Page<ProgramEntity> getPages(Timestamp now, PageRequest pageRequest) { | ||
return programRepository.findAllByIng(now, pageRequest); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...c/main/java/com/blackcompany/eeos/program/application/service/EndProgramStateService.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,18 @@ | ||
package com.blackcompany.eeos.program.application.service; | ||
|
||
import com.blackcompany.eeos.program.persistence.ProgramEntity; | ||
import com.blackcompany.eeos.program.persistence.ProgramRepository; | ||
import java.sql.Timestamp; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.PageRequest; | ||
|
||
@RequiredArgsConstructor | ||
public class EndProgramStateService implements ProgramStateService { | ||
private final ProgramRepository programRepository; | ||
|
||
@Override | ||
public Page<ProgramEntity> getPages(Timestamp now, PageRequest pageRequest) { | ||
return programRepository.findAllByEnd(now, pageRequest); | ||
} | ||
} |
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
10 changes: 10 additions & 0 deletions
10
.../src/main/java/com/blackcompany/eeos/program/application/service/ProgramStateService.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,10 @@ | ||
package com.blackcompany.eeos.program.application.service; | ||
|
||
import com.blackcompany.eeos.program.persistence.ProgramEntity; | ||
import java.sql.Timestamp; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.PageRequest; | ||
|
||
public interface ProgramStateService { | ||
Page<ProgramEntity> getPages(Timestamp now, PageRequest pageRequest); | ||
} |
26 changes: 26 additions & 0 deletions
26
...src/main/java/com/blackcompany/eeos/program/application/support/ProgramStatusFactory.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,26 @@ | ||
package com.blackcompany.eeos.program.application.support; | ||
|
||
import com.blackcompany.eeos.program.application.domain.ProgramStatus; | ||
import com.blackcompany.eeos.program.application.service.ActiveProgramStateService; | ||
import com.blackcompany.eeos.program.application.service.EndProgramStateService; | ||
import com.blackcompany.eeos.program.application.service.ProgramStateService; | ||
import com.blackcompany.eeos.program.persistence.ProgramRepository; | ||
import java.util.EnumMap; | ||
import java.util.Map; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class ProgramStatusFactory { | ||
private final ProgramRepository programRepository; | ||
|
||
public Map<ProgramStatus, ProgramStateService> make() { | ||
Map<ProgramStatus, ProgramStateService> stateServices = new EnumMap<>(ProgramStatus.class); | ||
|
||
stateServices.put(ProgramStatus.ACTIVE, new ActiveProgramStateService(programRepository)); | ||
stateServices.put(ProgramStatus.END, new EndProgramStateService(programRepository)); | ||
|
||
return stateServices; | ||
} | ||
} |
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