Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.dreamteam.alter.adapter.inbound.manager.schedule.controller;

import java.util.List;

import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
Expand All @@ -12,14 +15,17 @@
import org.springframework.web.bind.annotation.RestController;

import com.dreamteam.alter.adapter.inbound.common.dto.CommonApiResponse;
import com.dreamteam.alter.adapter.inbound.manager.schedule.dto.FixedWorkerScheduleResponseDto;
import com.dreamteam.alter.adapter.inbound.manager.schedule.dto.UpdateWorkerScheduleRequestDto;
import com.dreamteam.alter.adapter.inbound.manager.workspace.dto.CreateWorkerScheduleRequestDto;
import com.dreamteam.alter.application.aop.ManagerActionContext;
import com.dreamteam.alter.domain.user.context.ManagerActor;
import com.dreamteam.alter.domain.workspace.port.inbound.ManagerCreateFixedWorkerScheduleUseCase;
import com.dreamteam.alter.domain.workspace.port.inbound.ManagerDeleteFixedWorkerScheduleUseCase;
import com.dreamteam.alter.domain.workspace.port.inbound.ManagerGetFixedWorkerScheduleListUseCase;
import com.dreamteam.alter.domain.workspace.port.inbound.ManagerUpdateFixedWorkerScheduleUseCase;

import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;

Expand All @@ -30,10 +36,18 @@
@RequestMapping("/manager/workspaces/{workspaceId}/fixed-worker-schedules")
public class ManagerFixedWorkerScheduleController implements ManagerFixedWorkerScheduleControllerSpec {

@Resource(name = "managerCreateFixedWorkerSchedule")
private final ManagerCreateFixedWorkerScheduleUseCase managerCreateFixedWorkerSchedule;
private final ManagerUpdateFixedWorkerScheduleUseCase managerUpdateWorkerSchedule;

@Resource(name = "managerUpdateFixedWorkerSchedule")
private final ManagerUpdateFixedWorkerScheduleUseCase managerUpdateFixedWorkerSchedule;

@Resource(name = "managerDeleteFixedWorkerSchedule")
private final ManagerDeleteFixedWorkerScheduleUseCase managerDeleteFixedWorkerSchedule;

@Resource(name = "managerGetFixedWorkerScheduleList")
private final ManagerGetFixedWorkerScheduleListUseCase managerGetFixedWorkerScheduleList;

@Override
@PostMapping
public ResponseEntity<CommonApiResponse<Void>> createWorkerSchedule(
Expand All @@ -53,7 +67,7 @@ public ResponseEntity<CommonApiResponse<Void>> updateWorkerSchedule(
@RequestBody @Valid UpdateWorkerScheduleRequestDto request
) {
ManagerActor actor = ManagerActionContext.getInstance().getActor();
managerUpdateWorkerSchedule.execute(actor, workspaceId, workerScheduleId, request);
managerUpdateFixedWorkerSchedule.execute(actor, workspaceId, workerScheduleId, request);
return ResponseEntity.ok(CommonApiResponse.empty());
}

Expand All @@ -67,4 +81,13 @@ public ResponseEntity<CommonApiResponse<Void>> deleteWorkerSchedule(
managerDeleteFixedWorkerSchedule.execute(actor, workspaceId, workerScheduleId);
return ResponseEntity.ok(CommonApiResponse.empty());
}

@Override
@GetMapping
public ResponseEntity<CommonApiResponse<List<FixedWorkerScheduleResponseDto>>> getWorkerScheduleList(
@PathVariable Long workspaceId
) {
ManagerActor actor = ManagerActionContext.getInstance().getActor();
return ResponseEntity.ok(CommonApiResponse.of(managerGetFixedWorkerScheduleList.execute(actor, workspaceId)));
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package com.dreamteam.alter.adapter.inbound.manager.schedule.controller;

import java.util.List;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;

import com.dreamteam.alter.adapter.inbound.common.dto.CommonApiResponse;
import com.dreamteam.alter.adapter.inbound.common.dto.ErrorResponse;
import com.dreamteam.alter.adapter.inbound.manager.schedule.dto.FixedWorkerScheduleResponseDto;
import com.dreamteam.alter.adapter.inbound.manager.schedule.dto.UpdateWorkerScheduleRequestDto;
import com.dreamteam.alter.adapter.inbound.manager.workspace.dto.CreateWorkerScheduleRequestDto;

Expand Down Expand Up @@ -130,4 +133,22 @@ ResponseEntity<CommonApiResponse<Void>> deleteWorkerSchedule(
@PathVariable Long workspaceId,
@PathVariable Long workerScheduleId
);

@Operation(summary = "매니저 - 근무자 고정 스케줄 목록 조회", description = "업장의 활성화된 모든 고정 스케줄 목록을 반환합니다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "고정 스케줄 목록 조회 성공"),
@ApiResponse(responseCode = "404", description = "404 Error 실패 케이스",
content = @Content(
mediaType = "application/json",
schema = @Schema(implementation = ErrorResponse.class),
examples = {
@ExampleObject(
name = "존재하지 않는 업장입니다.",
value = "{\"code\" : \"B019\"}"
),
})),
})
ResponseEntity<CommonApiResponse<List<FixedWorkerScheduleResponseDto>>> getWorkerScheduleList(
@PathVariable Long workspaceId
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.dreamteam.alter.adapter.inbound.manager.schedule.dto;

import java.time.DayOfWeek;
import java.time.LocalTime;

import com.dreamteam.alter.domain.workspace.entity.WorkspaceWorkerSchedule;
import com.dreamteam.alter.domain.workspace.type.WorkspaceWorkerScheduleStatus;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor(access = AccessLevel.PRIVATE)
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Schema(description = "고정 근무 스케줄 응답")
public class FixedWorkerScheduleResponseDto {
@Schema(description = "고정 스케줄 ID", example = "1")
private Long id;

@Schema(description = "업장 근무자 ID", example = "10")
private Long workspaceWorkerId;

@Schema(description = "시작 요일", example = "MONDAY")
private DayOfWeek startDayOfWeek;

@Schema(description = "시작 시간", example = "09:00:00")
private LocalTime startTime;

@Schema(description = "종료 요일", example = "MONDAY")
private DayOfWeek endDayOfWeek;

@Schema(description = "종료 시간", example = "18:00:00")
private LocalTime endTime;

@Schema(description = "스케줄 상태", example = "ACTIVATED")
private WorkspaceWorkerScheduleStatus status;

public static FixedWorkerScheduleResponseDto of(WorkspaceWorkerSchedule s) {
return new FixedWorkerScheduleResponseDto(
s.getId(),
s.getWorkspaceWorker().getId(),
s.getStartDayOfWeek(),
s.getStartTime(),
s.getEndDayOfWeek(),
s.getEndTime(),
s.getStatus()
);
}
}
Original file line number Diff line number Diff line change
@@ -1,26 +1,37 @@
package com.dreamteam.alter.adapter.inbound.manager.workspace.controller;

import java.util.List;

import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.dreamteam.alter.adapter.inbound.common.dto.CommonApiResponse;
import com.dreamteam.alter.adapter.inbound.common.dto.CursorPageRequestDto;
import com.dreamteam.alter.adapter.inbound.common.dto.CursorPaginatedApiResponse;
import com.dreamteam.alter.adapter.inbound.manager.workspace.dto.*;
import com.dreamteam.alter.adapter.inbound.manager.workspace.dto.ManagerWorkspaceListResponseDto;
import com.dreamteam.alter.adapter.inbound.manager.workspace.dto.ManagerWorkspaceManagerListResponseDto;
import com.dreamteam.alter.adapter.inbound.manager.workspace.dto.ManagerWorkspaceResponseDto;
import com.dreamteam.alter.adapter.inbound.manager.workspace.dto.ManagerWorkspaceWorkerListFilterDto;
import com.dreamteam.alter.adapter.inbound.manager.workspace.dto.ManagerWorkspaceWorkerListResponseDto;
import com.dreamteam.alter.adapter.inbound.manager.workspace.dto.UpdateFixedScheduleDateRequestDto;
import com.dreamteam.alter.application.aop.ManagerActionContext;
import com.dreamteam.alter.domain.user.context.ManagerActor;
import com.dreamteam.alter.domain.workspace.port.inbound.ManagerGetWorkspaceListUseCase;
import com.dreamteam.alter.domain.workspace.port.inbound.ManagerGetWorkspaceManagerListUseCase;
import com.dreamteam.alter.domain.workspace.port.inbound.ManagerGetWorkspaceUseCase;
import com.dreamteam.alter.domain.workspace.port.inbound.ManagerGetWorkspaceWorkerListUseCase;
import com.dreamteam.alter.domain.workspace.port.inbound.ManagerGetWorkspaceManagerListUseCase;
import com.dreamteam.alter.domain.workspace.port.inbound.ManagerUpdateFixedScheduleDateUseCase;

import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/manager/workspaces")
Expand All @@ -41,6 +52,9 @@ public class ManagerWorkspaceController implements ManagerWorkspaceControllerSpe
@Resource(name = "managerGetWorkspaceManagerList")
private final ManagerGetWorkspaceManagerListUseCase managerGetWorkspaceManagerList;

@Resource(name = "managerUpdateFixedScheduleDate")
private final ManagerUpdateFixedScheduleDateUseCase managerUpdateFixedScheduleDate;

@Override
@GetMapping
public ResponseEntity<CommonApiResponse<List<ManagerWorkspaceListResponseDto>>> getWorkspaceList() {
Expand Down Expand Up @@ -82,4 +96,14 @@ public ResponseEntity<CommonApiResponse<CursorPaginatedApiResponse<ManagerWorksp
return ResponseEntity.ok(CommonApiResponse.of(managerGetWorkspaceManagerList.execute(actor, workspaceId, pageRequest)));
}

@Override
@PatchMapping("/{workspaceId}/fixed-schedule")
public ResponseEntity<CommonApiResponse<Void>> updateFixedScheduleDate(
@PathVariable Long workspaceId,
@RequestBody @Valid UpdateFixedScheduleDateRequestDto request
) {
ManagerActor actor = ManagerActionContext.getInstance().getActor();
managerUpdateFixedScheduleDate.execute(actor, workspaceId, request);
return ResponseEntity.ok(CommonApiResponse.empty());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@
import com.dreamteam.alter.adapter.inbound.common.dto.CursorPageRequestDto;
import com.dreamteam.alter.adapter.inbound.common.dto.CursorPaginatedApiResponse;
import com.dreamteam.alter.adapter.inbound.manager.workspace.dto.*;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;

import com.dreamteam.alter.adapter.inbound.common.dto.ErrorResponse;

import java.util.List;

Expand Down Expand Up @@ -50,6 +57,35 @@ ResponseEntity<CommonApiResponse<CursorPaginatedApiResponse<ManagerWorkspaceMana
CursorPageRequestDto pageRequest
);

@Operation(summary = "매니저 - 업장 고정근무 생성 기준일 수정", description = "다음 달 고정근무 스케줄 자동 생성 기준일(1~31)을 수정합니다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "기준일 수정 성공"),
@ApiResponse(responseCode = "400", description = "400 Error 실패 케이스",
content = @Content(
mediaType = "application/json",
schema = @Schema(implementation = ErrorResponse.class),
examples = {
@ExampleObject(
name = "1~31 범위를 벗어난 값입니다.",
value = "{\"code\" : \"B001\"}"
),
})),
@ApiResponse(responseCode = "404", description = "404 Error 실패 케이스",
content = @Content(
mediaType = "application/json",
schema = @Schema(implementation = ErrorResponse.class),
examples = {
@ExampleObject(
name = "존재하지 않는 업장입니다.",
value = "{\"code\" : \"B019\"}"
),
})),
})
ResponseEntity<CommonApiResponse<Void>> updateFixedScheduleDate(
@PathVariable Long workspaceId,
@RequestBody @Valid UpdateFixedScheduleDateRequestDto request
);

// 업장 근무자 상세 정보 조회

// 업장 근무자 상태 변경
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ public class ManagerWorkspaceResponseDto {
@Schema(description = "업장 경도", example = "126.9780")
private BigDecimal longitude;

@Schema(description = "다음달 고정근무 생성일", example = "20")
private int nextMonthShiftGenDay;

@NotNull
@Schema(description = "업장 등록 일시", example = "2023-10-01T12:00:00")
private LocalDateTime createdAt;
Expand All @@ -78,6 +81,7 @@ public static ManagerWorkspaceResponseDto of(ManagerWorkspaceResponse entity) {
.fullAddress(entity.getFullAddress())
.latitude(entity.getLatitude())
.longitude(entity.getLongitude())
.nextMonthShiftGenDay(entity.getNextMonthShiftGenDay())
.createdAt(entity.getCreatedAt())
.reputationSummary(SelfReputationSummaryDto.from(entity.getReputationSummary()))
.build();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.dreamteam.alter.adapter.inbound.manager.workspace.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
@AllArgsConstructor
@Schema(description = "매니저 - 고정근무 생성일 변경 DTO")
public class UpdateFixedScheduleDateRequestDto {

@NotNull(message = "시작 요일은 필수입니다")
@Min(value = 1, message = "1 보다 커야합니다.")
@Max(value = 31, message = "31 보다 작아야합니다")
@Schema(description = "변경일", example = "15")
Integer nextMonthShiftGenDay;
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public ManagerWorkspaceResponse getByManagerUserAndId(ManagerUser managerUser, L
qWorkspace.fullAddress,
qWorkspace.latitude,
qWorkspace.longitude,
qWorkspace.nextMonthShiftGenDay,
qWorkspace.createdAt,
qReputationSummary
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public class ManagerWorkspaceResponse {

private BigDecimal longitude;

private int nextMonthShiftGenDay;

private LocalDateTime createdAt;

private ReputationSummary reputationSummary;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import lombok.RequiredArgsConstructor;

@Service
@Service("managerCreateFixedWorkerSchedule")
@RequiredArgsConstructor
@Transactional
public class ManagerCreateFixedWorkerSchedule implements ManagerCreateFixedWorkerScheduleUseCase {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
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.FixedWorkerScheduleResponseDto;
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.ManagerGetFixedWorkerScheduleListUseCase;
import com.dreamteam.alter.domain.workspace.port.outbound.WorkspaceQueryRepository;
import com.dreamteam.alter.domain.workspace.port.outbound.WorkspaceWorkerScheduleQueryRepository;

import lombok.RequiredArgsConstructor;

@Service("managerGetFixedWorkerScheduleList")
@RequiredArgsConstructor
@Transactional(readOnly = true)
public class ManagerGetFixedWorkerScheduleList implements ManagerGetFixedWorkerScheduleListUseCase {

private final WorkspaceQueryRepository workspaceQueryRepository;
private final WorkspaceWorkerScheduleQueryRepository workspaceWorkerScheduleQueryRepository;

@Override
public List<FixedWorkerScheduleResponseDto> execute(ManagerActor actor, Long workspaceId) {
if (!workspaceQueryRepository.existsByIdAndManagerUser(workspaceId, actor.getManagerUser()))
throw new CustomException(ErrorCode.WORKSPACE_NOT_FOUND);

return workspaceWorkerScheduleQueryRepository.findAllActivatedWithWorkspaceWorkerByWorkspaceIds(List.of(workspaceId)).stream()
.map(FixedWorkerScheduleResponseDto::of)
.toList();
}
}
Loading