-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 금일 스케줄 목록 조회 API #73
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
Changes from all commits
d598db7
68c85af
05bdef5
c129f89
f86acef
db5e562
5bc1771
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| package com.dreamteam.alter.adapter.inbound.manager.schedule.dto; | ||
|
|
||
| import java.util.List; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| import com.dreamteam.alter.domain.workspace.model.WorkspaceShiftTodayResponse; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import lombok.AccessLevel; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Getter | ||
| @NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
| @AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
| @Builder(access = AccessLevel.PRIVATE) | ||
| @Schema(description = "매니저 금일 근무자 응답") | ||
| public class ManagerTodayScheduleResponseDto { | ||
|
|
||
| @Schema(description = "근무자 ID", example = "1") | ||
| private Long workerId; | ||
|
|
||
| @Schema(description = "근무자 이름", example = "홍길동") | ||
| private String workerName; | ||
|
|
||
| @Schema(description = "근무자 프로필 이미지 S3 URL") | ||
| private String profileImageUrl; | ||
|
|
||
| @Schema(description = "금일 근무 목록") | ||
| private List<ManagerTodayScheduleShiftItem> shifts; | ||
|
|
||
| public static List<ManagerTodayScheduleResponseDto> from(List<WorkspaceShiftTodayResponse> responses) { | ||
| return responses.stream() | ||
| .collect(Collectors.groupingBy(WorkspaceShiftTodayResponse::workerId)) | ||
| .values() | ||
| .stream() | ||
| .map(group -> { | ||
| WorkspaceShiftTodayResponse first = group.getFirst(); | ||
| return ManagerTodayScheduleResponseDto.builder() | ||
| .workerId(first.workerId()) | ||
| .workerName(first.workerName()) | ||
| .profileImageUrl(first.profileImageUrl()) | ||
| .shifts( | ||
| group.stream() | ||
| .map(r -> ManagerTodayScheduleShiftItem.of(r.shiftId(), r.startDateTime(), r.endDateTime())) | ||
| .toList() | ||
| ) | ||
| .build(); | ||
| }) | ||
| .toList(); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| package com.dreamteam.alter.adapter.inbound.manager.schedule.dto; | ||
|
|
||
| import java.time.LocalDateTime; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import lombok.AccessLevel; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Getter | ||
| @NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
| @AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
| @Builder(access = AccessLevel.PRIVATE) | ||
| @Schema(description = "근무 항목") | ||
| public class ManagerTodayScheduleShiftItem { | ||
|
|
||
| @Schema(description = "스케줄 ID", example = "1") | ||
| private Long shiftId; | ||
|
|
||
| @Schema(description = "근무 시작 시간", example = "2024-01-15T09:00:00") | ||
| private LocalDateTime startDateTime; | ||
|
|
||
| @Schema(description = "근무 종료 시간", example = "2024-01-15T18:00:00") | ||
| private LocalDateTime endDateTime; | ||
|
|
||
| public static ManagerTodayScheduleShiftItem of(Long shiftId, LocalDateTime startDateTime, LocalDateTime endDateTime) { | ||
| return ManagerTodayScheduleShiftItem.builder() | ||
| .shiftId(shiftId) | ||
| .startDateTime(startDateTime) | ||
| .endDateTime(endDateTime) | ||
| .build(); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| package com.dreamteam.alter.application.workspace.usecase; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| import com.dreamteam.alter.adapter.inbound.manager.schedule.dto.ManagerTodayScheduleResponseDto; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major 어댑터 DTO 매핑을 컨트롤러 경계로 이동하세요. Application use case가 ♻️ 구조 변경 방향-import com.dreamteam.alter.adapter.inbound.manager.schedule.dto.ManagerTodayScheduleResponseDto;
+import com.dreamteam.alter.domain.workspace.model.WorkspaceShiftTodayResponse;- public List<ManagerTodayScheduleResponseDto> execute(ManagerActor actor, Long workspaceId) {
+ public List<WorkspaceShiftTodayResponse> execute(ManagerActor actor, Long workspaceId) {
if (!workspaceQueryRepository.existsByIdAndManagerUser(workspaceId, actor.getManagerUser())) {
throw new CustomException(ErrorCode.WORKSPACE_NOT_FOUND);
}
- return workspaceShiftQueryRepository.getTodayShiftList(workspaceId).stream()
- .map(ManagerTodayScheduleResponseDto::of)
- .toList();
+ return workspaceShiftQueryRepository.getTodayShiftList(workspaceId);
}As per coding guidelines, Also applies to: 32-34 🤖 Prompt for AI Agents |
||
| import com.dreamteam.alter.common.exception.CustomException; | ||
| import com.dreamteam.alter.common.exception.ErrorCode; | ||
| import com.dreamteam.alter.domain.user.context.ManagerActor; | ||
| import com.dreamteam.alter.domain.workspace.port.inbound.ManagerGetDailyScheduleListUseCase; | ||
| import com.dreamteam.alter.domain.workspace.port.outbound.WorkspaceQueryRepository; | ||
| import com.dreamteam.alter.domain.workspace.port.outbound.WorkspaceShiftQueryRepository; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| @Service("managerGetTodayWorkScheduleList") | ||
| @RequiredArgsConstructor | ||
| @Transactional(readOnly = true) | ||
| public class ManagerGetDailyWorkScheduleList implements ManagerGetDailyScheduleListUseCase { | ||
|
|
||
| private final WorkspaceShiftQueryRepository workspaceShiftQueryRepository; | ||
| private final WorkspaceQueryRepository workspaceQueryRepository; | ||
|
|
||
| @Override | ||
| public List<ManagerTodayScheduleResponseDto> execute(ManagerActor actor, Long workspaceId) { | ||
| if (!workspaceQueryRepository.existsByIdAndManagerUser(workspaceId, actor.getManagerUser())) { | ||
| throw new CustomException(ErrorCode.WORKSPACE_NOT_FOUND); | ||
| } | ||
|
|
||
| return ManagerTodayScheduleResponseDto.from(workspaceShiftQueryRepository.getTodayShiftList(workspaceId)); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package com.dreamteam.alter.domain.workspace.model; | ||
|
|
||
| import java.time.LocalDateTime; | ||
|
|
||
| public record WorkspaceShiftTodayResponse( | ||
| Long shiftId, | ||
| Long workerId, | ||
| String workerName, | ||
| String profileImageUrl, | ||
| LocalDateTime startDateTime, | ||
| LocalDateTime endDateTime | ||
| ) {} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package com.dreamteam.alter.domain.workspace.port.inbound; | ||
|
|
||
| import com.dreamteam.alter.adapter.inbound.manager.schedule.dto.ManagerTodayScheduleResponseDto; | ||
| import com.dreamteam.alter.domain.user.context.ManagerActor; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public interface ManagerGetDailyScheduleListUseCase { | ||
| List<ManagerTodayScheduleResponseDto> execute(ManagerActor actor, Long workspaceId); | ||
|
juny0955 marked this conversation as resolved.
|
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.