-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Order #44
Open
jacobhboy
wants to merge
8
commits into
master
Choose a base branch
from
order
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Order #44
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
75b37a5
FEAT: timeTable domain
jacobhboy d20adaa
FEAT: timeTable service
jacobhboy d4f7cf2
FEAT: timeTable scheduler
jacobhboy 9bd9aaa
FEAT: timeTable controller
jacobhboy bdac57f
Merge remote-tracking branch 'origin/master'
jacobhboy 24ce2cc
UPDATE: Post 카테고리로 조회시 OrderType으로 좋아요, 최신순 조회
jacobhboy 9ff3552
UPDATE: comment 카테고리로 조회시 OrderType으로 좋아요, 최신순 조회
jacobhboy 67f93f8
Merge remote-tracking branch 'origin/master'
jacobhboy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,5 @@ | ||
package com.insert.ogbsm.domain.common; | ||
|
||
public enum OrderType { | ||
RECENT, LIKE | ||
} |
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
264 changes: 264 additions & 0 deletions
264
src/main/java/com/insert/ogbsm/domain/timeTable/Period.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,264 @@ | ||
package com.insert.ogbsm.domain.timeTable; | ||
|
||
import com.insert.ogbsm.infra.error.exception.BsmException; | ||
import com.insert.ogbsm.infra.error.exception.ErrorCode; | ||
import com.insert.ogbsm.presentation.timeTable.dto.TimeTableValueRes; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
import java.time.DayOfWeek; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Stream; | ||
|
||
import static java.time.DayOfWeek.*; | ||
|
||
@AllArgsConstructor | ||
@Getter | ||
public enum Period { | ||
// 기숙사 | ||
MORNING_DORM(new Time(0, 0), new Time(6, 30)), | ||
MORNING_DORM_FRIDAY(new Time(0, 0), new Time(7, 30)), | ||
PREPARING_DORM(new Time(6, 50), new Time(7, 30)), | ||
NIGHT_DORM(new Time(20, 40), new Time(24, 0)), | ||
|
||
// 아침운동 | ||
MORNING_EXERSIZE(new Time(6, 30), new Time(6, 50)), | ||
|
||
//아침 자습시간 | ||
MORNING_SELF_STUDY(new Time(8, 5), new Time(8, 30)), | ||
|
||
//시간표 | ||
FIRST(new Time(8, 40), new Time(9, 30)), | ||
SECOND(new Time(9, 40), new Time(10, 30)), | ||
THIRD(new Time(10, 40), new Time(11, 30)), | ||
FOURTH(new Time(11, 40), new Time(12, 30)), | ||
FIFTH(new Time(1, 20), new Time(2, 10)), | ||
SIXTH(new Time(2, 20), new Time(3, 10)), | ||
SEVENTH(new Time(3, 20), new Time(4, 10)), | ||
AFTER_SCHOOL_1(new Time(4, 30), new Time(6, 10)), | ||
AFTER_SCHOOL_2(new Time(7, 0), new Time(8, 40)), | ||
|
||
//조례, 종례 | ||
PRONUNCIATION(new Time(8, 30), new Time(8, 40)), | ||
ANTONYM(new Time(4, 20), new Time(4, 30)), | ||
CLEANING(new Time(4, 10), new Time(4, 20)), | ||
|
||
//쉬는 시간 | ||
BREAK_1(new Time(9, 30), new Time(9, 40)), | ||
BREAK_2(new Time(10, 30), new Time(10, 40)), | ||
BREAK_3(new Time(11, 30), new Time(11, 40)), | ||
BREAK_4(new Time(2, 10), new Time(2, 20)), | ||
BREAK_5(new Time(3, 10), new Time(3, 20)), | ||
|
||
//식사 | ||
BREAKFAST(new Time(7, 30), new Time(8, 5)), | ||
LUNCH(new Time(12, 30), new Time(1, 20)), | ||
DINNER(new Time(6, 10), new Time(7, 0)), | ||
|
||
//금요일 | ||
ANTONYM_FRIDAY(new Time(3, 10), new Time(3, 20)), | ||
GO_HOME(new Time(3, 20), new Time(24, 0)), | ||
|
||
//토요일 | ||
HOME(new Time(0, 0), new Time(24, 0)), | ||
|
||
//일요일 | ||
HOME_SUNDAY(new Time(0, 0), new Time(7, 50)), | ||
DORM_SUNDAY(new Time(7, 50), new Time(24, 0)); | ||
|
||
|
||
final Time startTime; | ||
final Time endTime; | ||
|
||
public static Period get(int period) { | ||
switch (period) { | ||
case 1: | ||
return FIRST; | ||
case 2: | ||
return SECOND; | ||
case 3: | ||
return THIRD; | ||
case 4: | ||
return FOURTH; | ||
case 5: | ||
return FIFTH; | ||
case 6: | ||
return SIXTH; | ||
case 7: | ||
return SEVENTH; | ||
} | ||
throw new BsmException(ErrorCode.NO_PERIOD_MATCHED); | ||
} | ||
|
||
public static Map<DayOfWeek, List<TimeTableValueRes>> getAllPeriod(Map<DayOfWeek, List<TimeTableValueRes>> periodMap) { | ||
setAtLeastSeventhAndBreak(periodMap); | ||
|
||
for (DayOfWeek day : periodMap.keySet()) { | ||
switch (day) { | ||
case MONDAY -> { | ||
List<TimeTableValueRes> monday = getMonday(periodMap.get(day)); | ||
periodMap.replace(day, monday); | ||
} | ||
case TUESDAY -> { | ||
List<TimeTableValueRes> tuesday = getTuesday(periodMap.get(day)); | ||
periodMap.replace(day, tuesday); | ||
} | ||
case WEDNESDAY -> { | ||
List<TimeTableValueRes> wednesday = getWednesday(periodMap.get(day)); | ||
periodMap.replace(day, wednesday); | ||
} | ||
case THURSDAY -> { | ||
List<TimeTableValueRes> thursday = getThursday(periodMap.get(day)); | ||
periodMap.replace(day, thursday); | ||
} | ||
case FRIDAY -> { | ||
List<TimeTableValueRes> friday = getFriday(periodMap.get(day)); | ||
periodMap.replace(day, friday); | ||
} | ||
} | ||
} | ||
List<TimeTableValueRes> saturday = getSaturday(); | ||
List<TimeTableValueRes> sunday = getSunday(); | ||
|
||
periodMap.put(SATURDAY, saturday); | ||
periodMap.put(SUNDAY, sunday); | ||
|
||
return periodMap; | ||
} | ||
|
||
private static void setAtLeastSeventhAndBreak(Map<DayOfWeek, List<TimeTableValueRes>> periodMap) { | ||
for (DayOfWeek day : periodMap.keySet()) { | ||
if (day != FRIDAY) { | ||
List<TimeTableValueRes> timeTableValueRes = periodMap.get(day); | ||
for (int i = periodMap.get(day).size(); i < 7; i++) { | ||
timeTableValueRes.add( | ||
new TimeTableValueRes( | ||
get(i + 1), | ||
"자습", | ||
null | ||
) | ||
); | ||
} | ||
periodMap.replace(day, setBreakAndLunch(timeTableValueRes)); | ||
} | ||
} | ||
} | ||
|
||
public static Map<DayOfWeek, List<TimeTableValueRes>> setAtLeastSeventh(Map<DayOfWeek, List<TimeTableValueRes>> periodMap) { | ||
for (DayOfWeek day : periodMap.keySet()) { | ||
List<TimeTableValueRes> timeTableValueRes = periodMap.get(day); | ||
for (int i = periodMap.get(day).size(); i < 7; i++) { | ||
timeTableValueRes.add( | ||
new TimeTableValueRes( | ||
get(i + 1), | ||
"자습", | ||
null | ||
) | ||
); | ||
} | ||
} | ||
|
||
return periodMap; | ||
} | ||
|
||
private static List<TimeTableValueRes> getMonday(List<TimeTableValueRes> timeTableValueRes) { | ||
List<TimeTableValueRes> monday = setOrdinaryMorning(timeTableValueRes); | ||
return setOrdinaryAfternoon(monday); | ||
|
||
} | ||
|
||
private static List<TimeTableValueRes> getTuesday(List<TimeTableValueRes> timeTableValueRes) { | ||
List<TimeTableValueRes> tuesday = setOrdinaryMorning(timeTableValueRes); | ||
return setOrdinaryAfternoon(tuesday); | ||
} | ||
|
||
private static List<TimeTableValueRes> getWednesday(List<TimeTableValueRes> timeTableValueRes) { | ||
List<TimeTableValueRes> wednesday = setOrdinaryMorning(timeTableValueRes); | ||
return setOrdinaryAfternoon(wednesday); | ||
} | ||
|
||
private static List<TimeTableValueRes> getThursday(List<TimeTableValueRes> timeTableValueRes) { | ||
List<TimeTableValueRes> thursday = setOrdinaryMorning(timeTableValueRes); | ||
return setOrdinaryAfternoon(thursday); | ||
} | ||
|
||
private static List<TimeTableValueRes> setBreakAndLunch(List<TimeTableValueRes> timeTableValueRes) { | ||
timeTableValueRes.add(1, new TimeTableValueRes(BREAK_1, "쉬는 시간", null)); | ||
timeTableValueRes.add(3, new TimeTableValueRes(BREAK_2, "쉬는 시간", null)); | ||
timeTableValueRes.add(5, new TimeTableValueRes(BREAK_3, "쉬는 시간", null)); | ||
timeTableValueRes.add(7, new TimeTableValueRes(LUNCH, "점심 시간", null)); | ||
timeTableValueRes.add(9, new TimeTableValueRes(BREAK_4, "쉬는 시간", null)); | ||
timeTableValueRes.add(11, new TimeTableValueRes(BREAK_5, "쉬는 시간", null)); | ||
|
||
return timeTableValueRes; | ||
} | ||
|
||
private static List<TimeTableValueRes> setOrdinaryMorning(List<TimeTableValueRes> day) { | ||
List<TimeTableValueRes> ordinary = new java.util.ArrayList<>(Stream.of( | ||
new TimeTableValueRes(MORNING_DORM, "기숙사", null), | ||
new TimeTableValueRes(MORNING_EXERSIZE, "아침 운동", null), | ||
new TimeTableValueRes(PREPARING_DORM, "등교 준비", null), | ||
new TimeTableValueRes(BREAKFAST, "아침 식사", null), | ||
new TimeTableValueRes(MORNING_SELF_STUDY, "아침 자습 시간", null), | ||
new TimeTableValueRes(PRONUNCIATION, "조례", null) | ||
).toList()); | ||
|
||
ordinary.addAll(day); | ||
|
||
return ordinary; | ||
} | ||
|
||
private static List<TimeTableValueRes> setOrdinaryAfternoon(List<TimeTableValueRes> day) { | ||
List<TimeTableValueRes> ordinary = Stream.of( | ||
new TimeTableValueRes(CLEANING, "청소 시간", null), | ||
new TimeTableValueRes(ANTONYM, "종례", null), | ||
new TimeTableValueRes(AFTER_SCHOOL_1, "방과후", null), | ||
new TimeTableValueRes(DINNER, "저녁 식사", null), | ||
new TimeTableValueRes(AFTER_SCHOOL_2, "방과후", null), | ||
new TimeTableValueRes(NIGHT_DORM, "기숙사", null) | ||
).toList(); | ||
|
||
day.addAll(ordinary); | ||
|
||
return day; | ||
} | ||
|
||
private static List<TimeTableValueRes> getFriday(List<TimeTableValueRes> timeTableValueRes) { | ||
List<TimeTableValueRes> friday = new java.util.ArrayList<>(Stream.of( | ||
new TimeTableValueRes(MORNING_DORM_FRIDAY, "기숙사", null), | ||
new TimeTableValueRes(BREAKFAST, "아침 식사", null), | ||
new TimeTableValueRes(MORNING_SELF_STUDY, "아침 자습 시간", null), | ||
new TimeTableValueRes(PRONUNCIATION, "조례", null) | ||
).toList()); | ||
|
||
friday.addAll(timeTableValueRes); | ||
|
||
friday.addAll( | ||
List.of( | ||
new TimeTableValueRes(ANTONYM_FRIDAY, "종례", null), | ||
new TimeTableValueRes(GO_HOME, "집", null) | ||
) | ||
); | ||
|
||
return friday; | ||
} | ||
|
||
private static List<TimeTableValueRes> getSaturday() { | ||
return List.of( | ||
new TimeTableValueRes(HOME, "집", null) | ||
); | ||
} | ||
|
||
private static List<TimeTableValueRes> getSunday() { | ||
return List.of( | ||
new TimeTableValueRes(HOME_SUNDAY, "집", null), | ||
new TimeTableValueRes(DORM_SUNDAY, "기숙사", null) | ||
); | ||
} | ||
|
||
public record Time(int hour, int minute) { | ||
|
||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/com/insert/ogbsm/domain/timeTable/TimeTable.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.insert.ogbsm.domain.timeTable; | ||
|
||
import jakarta.persistence.EmbeddedId; | ||
import jakarta.persistence.Entity; | ||
import lombok.AccessLevel; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.LocalDate; | ||
|
||
@Entity | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class TimeTable { | ||
|
||
@EmbeddedId | ||
private TimeTablePk pk; | ||
|
||
private String subject; | ||
|
||
public TimeTable(LocalDate date, int grade, int classNumber, Period period, String subject) { | ||
this.pk = new TimeTablePk(date, grade, classNumber, period); | ||
this.subject = subject; | ||
} | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/com/insert/ogbsm/domain/timeTable/TimeTablePk.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,35 @@ | ||
package com.insert.ogbsm.domain.timeTable; | ||
|
||
import jakarta.persistence.Embeddable; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.io.Serializable; | ||
import java.time.LocalDate; | ||
|
||
@Getter | ||
@EqualsAndHashCode(onlyExplicitlyIncluded = true) | ||
@Embeddable | ||
@NoArgsConstructor | ||
public class TimeTablePk implements Serializable { | ||
|
||
@EqualsAndHashCode.Include | ||
private LocalDate date; | ||
|
||
@EqualsAndHashCode.Include | ||
private int grade; | ||
|
||
@EqualsAndHashCode.Include | ||
private int classNumber; | ||
|
||
@EqualsAndHashCode.Include | ||
private Period period; | ||
|
||
public TimeTablePk(LocalDate date, int grade, int classNumber, Period period) { | ||
this.date = date; | ||
this.grade = grade; | ||
this.classNumber = classNumber; | ||
this.period = period; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/insert/ogbsm/domain/timeTable/repo/TimeTableDao.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.insert.ogbsm.domain.timeTable.repo; | ||
|
||
import com.insert.ogbsm.presentation.timeTable.dto.TimeTableValueRes; | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
|
||
public interface TimeTableDao { | ||
List<TimeTableValueRes> findByGradeAndClassNumber(int grade, int classNumber, List<LocalDate> startAndEndOfWeek); | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/com/insert/ogbsm/domain/timeTable/repo/TimeTableDaoImpl.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,28 @@ | ||
package com.insert.ogbsm.domain.timeTable.repo; | ||
|
||
import com.insert.ogbsm.presentation.timeTable.dto.QTimeTableValueRes; | ||
import com.insert.ogbsm.presentation.timeTable.dto.TimeTableValueRes; | ||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
|
||
import static com.insert.ogbsm.domain.timeTable.QTimeTable.timeTable; | ||
|
||
@RequiredArgsConstructor | ||
public class TimeTableDaoImpl implements TimeTableDao { | ||
private final JPAQueryFactory jpaQueryFactory; | ||
|
||
@Override | ||
public List<TimeTableValueRes> findByGradeAndClassNumber(int grade, int classNumber, List<LocalDate> startAndEndOfWeek) { | ||
return jpaQueryFactory | ||
.select(new QTimeTableValueRes(timeTable.pk.period, timeTable.subject, timeTable.pk.date)) | ||
.from(timeTable) | ||
.where(timeTable.pk.grade.eq(grade) | ||
.and(timeTable.pk.classNumber.eq(classNumber))) | ||
.where(timeTable.pk.date.between(startAndEndOfWeek.get(0), startAndEndOfWeek.get(1))) | ||
.orderBy(timeTable.pk.date.asc(), timeTable.pk.period.asc()) | ||
.fetch(); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pageable에 OrderBy를 사용하지 않은 이유가 있나요??