-
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.
Browse files
Browse the repository at this point in the history
#317 [feat] 엔티티 변경으로 인한 종합 일정 시간표 로직 리팩토링
- Loading branch information
Showing
17 changed files
with
267 additions
and
65 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...ain/java/com/asap/server/presentation/controller/dto/request/AvailableTimeRequestDto.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
2 changes: 1 addition & 1 deletion
2
...va/com/asap/server/presentation/controller/dto/request/UserMeetingTimeSaveRequestDto.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
27 changes: 16 additions & 11 deletions
27
src/main/java/com/asap/server/presentation/controller/dto/response/AvailableDatesDto.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,19 +1,24 @@ | ||
package com.asap.server.presentation.controller.dto.response; | ||
|
||
import lombok.AllArgsConstructor; | ||
import com.asap.server.service.time.dto.retrieve.AvailableDatesRetrieveDto; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.ToString; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
@ToString | ||
@AllArgsConstructor | ||
@Builder | ||
public class AvailableDatesDto { | ||
private String month; | ||
private String day; | ||
private String dayOfWeek; | ||
private List<TimeSlotDto> timeSlots; | ||
public record AvailableDatesDto( | ||
String month, | ||
String day, | ||
String dayOfWeek, | ||
List<TimeSlotDto> timeSlots | ||
) { | ||
public static List<AvailableDatesDto> of(final List<AvailableDatesRetrieveDto> retrieveDtos) { | ||
return retrieveDtos.stream().map( | ||
dto -> new AvailableDatesDto( | ||
dto.month(), | ||
dto.day(), | ||
dto.dayOfWeek(), | ||
TimeSlotDto.of(dto.timeSlots()) | ||
)).toList(); | ||
} | ||
} |
40 changes: 12 additions & 28 deletions
40
src/main/java/com/asap/server/presentation/controller/dto/response/TimeSlotDto.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,35 +1,19 @@ | ||
package com.asap.server.presentation.controller.dto.response; | ||
|
||
import lombok.AllArgsConstructor; | ||
import com.asap.server.service.time.dto.retrieve.TimeBlockRetrieveDto; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.ToString; | ||
|
||
import java.util.List; | ||
@Getter | ||
@ToString | ||
@AllArgsConstructor | ||
@Builder | ||
public class TimeSlotDto { | ||
private String time; | ||
private List<String> userNames; | ||
private int colorLevel; | ||
|
||
public void setColorLevel(final int memberCount) { | ||
double ratio = (double) userNames.size() / memberCount; | ||
|
||
if (ratio <= 0.2) { | ||
this.colorLevel = 1; | ||
} else if (ratio <= 0.4) { | ||
this.colorLevel = 2; | ||
} else if (ratio <= 0.6) { | ||
this.colorLevel = 3; | ||
} else if (ratio <= 0.8) { | ||
this.colorLevel = 4; | ||
} else if (ratio <= 1.0) { | ||
this.colorLevel = 5; | ||
} else { | ||
this.colorLevel = 0; | ||
} | ||
@Builder | ||
public record TimeSlotDto ( | ||
String time, | ||
List<String> userNames, | ||
int colorLevel | ||
) { | ||
public static List<TimeSlotDto> of(List<TimeBlockRetrieveDto> retrieveDtos) { | ||
return retrieveDtos.stream().map( | ||
dto -> new TimeSlotDto(dto.time(), dto.userNames(), dto.colorLevel()) | ||
).toList(); | ||
} | ||
} | ||
} |
23 changes: 13 additions & 10 deletions
23
src/main/java/com/asap/server/presentation/controller/dto/response/TimeTableResponseDto.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,17 +1,20 @@ | ||
package com.asap.server.presentation.controller.dto.response; | ||
|
||
import lombok.AllArgsConstructor; | ||
import com.asap.server.service.time.dto.retrieve.TimeTableRetrieveDto; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.ToString; | ||
|
||
import java.util.List; | ||
@Getter | ||
|
||
@Builder | ||
@ToString | ||
@AllArgsConstructor | ||
public class TimeTableResponseDto { | ||
public int memberCount; | ||
public List<String> totalUserNames; | ||
private List<AvailableDatesDto> availableDateTimes; | ||
public record TimeTableResponseDto( | ||
int memberCount, | ||
List<String> totalUserNames, | ||
List<AvailableDatesDto> availableDateTimes | ||
) { | ||
public static TimeTableResponseDto of(final TimeTableRetrieveDto retrieveDto) { | ||
return new TimeTableResponseDto( | ||
retrieveDto.memberCount(), | ||
retrieveDto.totalUserNames(), | ||
AvailableDatesDto.of(retrieveDto.availableDateTimes())); | ||
} | ||
} |
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
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
2 changes: 1 addition & 1 deletion
2
...e/dto/UserMeetingScheduleRegisterDto.java → ...ister/UserMeetingScheduleRegisterDto.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
2 changes: 1 addition & 1 deletion
2
...service/time/dto/UserTimeRegisterDto.java → ...ime/dto/register/UserTimeRegisterDto.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
21 changes: 21 additions & 0 deletions
21
src/main/java/com/asap/server/service/time/dto/retrieve/AvailableDatesRetrieveDto.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,21 @@ | ||
package com.asap.server.service.time.dto.retrieve; | ||
|
||
import com.asap.server.common.utils.DateUtil; | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
|
||
public record AvailableDatesRetrieveDto( | ||
String month, | ||
String day, | ||
String dayOfWeek, | ||
List<TimeBlockRetrieveDto> timeSlots | ||
) { | ||
public static AvailableDatesRetrieveDto of(final LocalDate date, final List<TimeBlockRetrieveDto> timeSlots) { | ||
return new AvailableDatesRetrieveDto( | ||
DateUtil.getMonth(date), | ||
DateUtil.getDay(date), | ||
DateUtil.getDayOfWeek(date), | ||
timeSlots); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/asap/server/service/time/dto/retrieve/TimeBlockRetrieveDto.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.asap.server.service.time.dto.retrieve; | ||
|
||
import java.util.List; | ||
|
||
public record TimeBlockRetrieveDto( | ||
String time, | ||
List<String> userNames, | ||
int colorLevel | ||
) { | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/asap/server/service/time/dto/retrieve/TimeTableRetrieveDto.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,14 @@ | ||
package com.asap.server.service.time.dto.retrieve; | ||
|
||
|
||
import java.util.List; | ||
|
||
public record TimeTableRetrieveDto( | ||
int memberCount, | ||
List<String> totalUserNames, | ||
List<AvailableDatesRetrieveDto> availableDateTimes | ||
) { | ||
public static TimeTableRetrieveDto of(final List<String> totalUserNames, final List<AvailableDatesRetrieveDto> availableDateTimes) { | ||
return new TimeTableRetrieveDto(totalUserNames.size(), totalUserNames, availableDateTimes); | ||
} | ||
} |
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
Oops, something went wrong.