-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: 사용자 자신의 스케줄 조회 API 스펙 변경 #60
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 hidden or 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 hidden or 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
25 changes: 25 additions & 0 deletions
25
...amteam/alter/adapter/inbound/general/schedule/dto/DailyWorkScheduleInquiryRequestDto.java
This file contains hidden or 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,25 @@ | ||
| package com.dreamteam.alter.adapter.inbound.general.schedule.dto; | ||
|
|
||
| import io.swagger.v3.oas.annotations.Parameter; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Data; | ||
| import lombok.NoArgsConstructor; | ||
| import org.springdoc.core.annotations.ParameterObject; | ||
|
|
||
| @Data | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| @ParameterObject | ||
| @Schema(description = "일별 스케줄 조회 요청") | ||
| public class DailyWorkScheduleInquiryRequestDto { | ||
|
|
||
| @Parameter(description = "조회할 연도", required = true, example = "2024") | ||
| private Integer year; | ||
|
|
||
| @Parameter(description = "조회할 월", required = true, example = "5") | ||
| private Integer month; | ||
|
|
||
| @Parameter(description = "조회할 일", required = true, example = "20") | ||
| private Integer day; | ||
| } |
22 changes: 22 additions & 0 deletions
22
...team/alter/adapter/inbound/general/schedule/dto/MonthlyWorkScheduleInquiryRequestDto.java
This file contains hidden or 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,22 @@ | ||
| package com.dreamteam.alter.adapter.inbound.general.schedule.dto; | ||
|
|
||
| import io.swagger.v3.oas.annotations.Parameter; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Data; | ||
| import lombok.NoArgsConstructor; | ||
| import org.springdoc.core.annotations.ParameterObject; | ||
|
|
||
| @Data | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| @ParameterObject | ||
| @Schema(description = "월별 스케줄 조회 요청") | ||
| public class MonthlyWorkScheduleInquiryRequestDto { | ||
|
|
||
| @Parameter(description = "조회할 연도", required = true, example = "2024") | ||
| private Integer year; | ||
|
|
||
| @Parameter(description = "조회할 월", required = true, example = "5") | ||
| private Integer month; | ||
| } |
19 changes: 19 additions & 0 deletions
19
...om/dreamteam/alter/adapter/inbound/general/schedule/dto/MyScheduleMonthlyResponseDto.java
This file contains hidden or 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.dreamteam.alter.adapter.inbound.general.schedule.dto; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Getter | ||
| @Builder | ||
| @Schema(description = "내 월별 스케쥴 응답") | ||
| public class MyScheduleMonthlyResponseDto { | ||
|
|
||
| @Schema(description = "월 총 근무시간", example = "160.5") | ||
| private double totalWorkHoursInMonth; | ||
|
|
||
| @Schema(description = "월별 스케쥴 목록") | ||
| private List<MyScheduleResponseDto> schedules; | ||
| } | ||
This file contains hidden or 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 hidden or 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
38 changes: 38 additions & 0 deletions
38
src/main/java/com/dreamteam/alter/application/workspace/usecase/GetMyDailySchedule.java
This file contains hidden or 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,38 @@ | ||
| package com.dreamteam.alter.application.workspace.usecase; | ||
|
|
||
| import com.dreamteam.alter.adapter.inbound.general.schedule.dto.DailyWorkScheduleInquiryRequestDto; | ||
| import com.dreamteam.alter.adapter.inbound.general.schedule.dto.MyScheduleResponseDto; | ||
| import com.dreamteam.alter.domain.user.context.AppActor; | ||
| import com.dreamteam.alter.domain.workspace.entity.WorkspaceShift; | ||
| import com.dreamteam.alter.domain.workspace.port.inbound.GetMyDailyScheduleUseCase; | ||
| import com.dreamteam.alter.domain.workspace.port.outbound.WorkspaceShiftQueryRepository; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.checkerframework.checker.nullness.qual.MonotonicNonNull; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| import java.util.List; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| @Service("getMyDailySchedule") | ||
| @RequiredArgsConstructor | ||
| @Transactional(readOnly = true) | ||
| public class GetMyDailySchedule implements GetMyDailyScheduleUseCase { | ||
|
|
||
| private final WorkspaceShiftQueryRepository workspaceShiftQueryRepository; | ||
|
|
||
| @Override | ||
| public List<MyScheduleResponseDto> execute(AppActor actor, @MonotonicNonNull DailyWorkScheduleInquiryRequestDto request) { | ||
|
|
||
| List<WorkspaceShift> dailyShifts = workspaceShiftQueryRepository.findByUserAndDate( | ||
| actor.getUser(), | ||
| request.getYear(), | ||
| request.getMonth(), | ||
| request.getDay() | ||
| ); | ||
|
|
||
| return dailyShifts.stream() | ||
| .map(MyScheduleResponseDto::of) | ||
| .collect(Collectors.toList()); | ||
| } | ||
| } |
50 changes: 50 additions & 0 deletions
50
src/main/java/com/dreamteam/alter/application/workspace/usecase/GetMyMonthlySchedule.java
This file contains hidden or 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,50 @@ | ||
| package com.dreamteam.alter.application.workspace.usecase; | ||
|
|
||
| import com.dreamteam.alter.adapter.inbound.general.schedule.dto.MonthlyWorkScheduleInquiryRequestDto; | ||
| import com.dreamteam.alter.adapter.inbound.general.schedule.dto.MyScheduleMonthlyResponseDto; | ||
| import com.dreamteam.alter.adapter.inbound.general.schedule.dto.MyScheduleResponseDto; | ||
| import com.dreamteam.alter.domain.user.context.AppActor; | ||
| import com.dreamteam.alter.domain.workspace.entity.WorkspaceShift; | ||
| import com.dreamteam.alter.domain.workspace.port.inbound.GetMyMonthlyScheduleUseCase; | ||
| import com.dreamteam.alter.domain.workspace.port.outbound.WorkspaceShiftQueryRepository; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.checkerframework.checker.nullness.qual.MonotonicNonNull; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| import java.time.Duration; | ||
| import java.util.List; | ||
|
|
||
| @Service("getMyMonthlySchedule") | ||
| @RequiredArgsConstructor | ||
| @Transactional(readOnly = true) | ||
| public class GetMyMonthlySchedule implements GetMyMonthlyScheduleUseCase { | ||
|
|
||
| private final WorkspaceShiftQueryRepository workspaceShiftQueryRepository; | ||
|
|
||
| @Override | ||
| public MyScheduleMonthlyResponseDto execute(AppActor actor, @MonotonicNonNull MonthlyWorkScheduleInquiryRequestDto request) { | ||
|
|
||
|
|
||
| List<WorkspaceShift> shifts = workspaceShiftQueryRepository.findByUserAndDateRange( | ||
| actor.getUser(), | ||
| request.getYear(), | ||
| request.getMonth() | ||
| ); | ||
|
|
||
| double totalWorkHours = shifts.stream() | ||
| .mapToDouble(shift -> { | ||
| Duration duration = Duration.between(shift.getStartDateTime(), shift.getEndDateTime()); | ||
| return duration.toMinutes() / 60.0; | ||
| }) | ||
| .sum(); | ||
|
|
||
| List<MyScheduleResponseDto> scheduleDtos = shifts.stream() | ||
| .map(MyScheduleResponseDto::of) | ||
| .toList(); | ||
| return MyScheduleMonthlyResponseDto.builder() | ||
| .totalWorkHoursInMonth(totalWorkHours) | ||
| .schedules(scheduleDtos) | ||
| .build(); | ||
| } | ||
| } |
11 changes: 11 additions & 0 deletions
11
...ain/java/com/dreamteam/alter/domain/workspace/port/inbound/GetMyDailyScheduleUseCase.java
This file contains hidden or 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,11 @@ | ||
| package com.dreamteam.alter.domain.workspace.port.inbound; | ||
|
|
||
| import com.dreamteam.alter.adapter.inbound.general.schedule.dto.DailyWorkScheduleInquiryRequestDto; | ||
| import com.dreamteam.alter.adapter.inbound.general.schedule.dto.MyScheduleResponseDto; | ||
| import com.dreamteam.alter.domain.user.context.AppActor; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public interface GetMyDailyScheduleUseCase { | ||
| List<MyScheduleResponseDto> execute(AppActor actor, DailyWorkScheduleInquiryRequestDto request); | ||
| } |
9 changes: 9 additions & 0 deletions
9
...n/java/com/dreamteam/alter/domain/workspace/port/inbound/GetMyMonthlyScheduleUseCase.java
This file contains hidden or 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.dreamteam.alter.domain.workspace.port.inbound; | ||
|
|
||
| import com.dreamteam.alter.adapter.inbound.general.schedule.dto.MonthlyWorkScheduleInquiryRequestDto; | ||
| import com.dreamteam.alter.adapter.inbound.general.schedule.dto.MyScheduleMonthlyResponseDto; | ||
| import com.dreamteam.alter.domain.user.context.AppActor; | ||
|
|
||
| public interface GetMyMonthlyScheduleUseCase { | ||
| MyScheduleMonthlyResponseDto execute(AppActor actor, MonthlyWorkScheduleInquiryRequestDto request); | ||
| } |
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.