-
Notifications
You must be signed in to change notification settings - Fork 0
feat: [alt-216] 근무자 색상 코드 변경 기능 추가 #85
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 all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
573230f
feat: 근무자 색상 코드 엔티티 필드 및 UseCase 추가
ysw789 bd47f56
feat: 근무자 색상 코드 변경 DTO 및 응답 필드 추가
ysw789 bf9e97e
feat: 근무자 색상 코드 변경 API 엔드포인트 추가
ysw789 6093aaf
refactor: Command 패턴으로 UseCase 아키텍처 개선
ysw789 a0024da
docs: ControllerSpec ErrorCode 예시 정합성 수정
ysw789 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
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
20 changes: 20 additions & 0 deletions
20
...eam/alter/adapter/inbound/manager/workspace/dto/UpdateWorkspaceWorkerColorRequestDto.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,20 @@ | ||
| package com.dreamteam.alter.adapter.inbound.manager.workspace.dto; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import jakarta.validation.constraints.NotBlank; | ||
| import jakarta.validation.constraints.Pattern; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Getter | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| @Schema(description = "매니저 - 근무자 색상 변경 요청 DTO") | ||
| public class UpdateWorkspaceWorkerColorRequestDto { | ||
|
|
||
| @NotBlank | ||
| @Pattern(regexp = "^#[0-9A-Fa-f]{6}$", message = "색상은 #로 시작하는 6자리 16진수여야 합니다.") | ||
| @Schema(description = "변경할 색상 (hex)", example = "#93B0A4") | ||
| private String colorCode; | ||
| } |
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
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
52 changes: 52 additions & 0 deletions
52
.../dreamteam/alter/application/workspace/usecase/ManagerUpdateWorkspaceWorkerColorCode.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,52 @@ | ||
| package com.dreamteam.alter.application.workspace.usecase; | ||
|
|
||
| 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.command.UpdateWorkspaceWorkerColorCommand; | ||
| import com.dreamteam.alter.domain.workspace.entity.WorkspaceWorker; | ||
| import com.dreamteam.alter.domain.workspace.port.inbound.ManagerUpdateWorkspaceWorkerColorCodeUseCase; | ||
| import com.dreamteam.alter.domain.workspace.port.outbound.WorkspaceQueryRepository; | ||
| import com.dreamteam.alter.domain.workspace.port.outbound.WorkspaceWorkerQueryRepository; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| @Service("managerUpdateWorkspaceWorkerColorCode") | ||
| @RequiredArgsConstructor | ||
| @Transactional | ||
| public class ManagerUpdateWorkspaceWorkerColorCode implements ManagerUpdateWorkspaceWorkerColorCodeUseCase { | ||
|
|
||
| private final WorkspaceQueryRepository workspaceQueryRepository; | ||
| private final WorkspaceWorkerQueryRepository workspaceWorkerQueryRepository; | ||
|
|
||
| @Override | ||
| public void execute( | ||
| ManagerActor actor, | ||
| Long workspaceId, | ||
| Long workerId, | ||
| UpdateWorkspaceWorkerColorCommand command | ||
| ) { | ||
| if (!workspaceQueryRepository.existsByIdAndManagerUser(workspaceId, actor.getManagerUser())) { | ||
| throw new CustomException(ErrorCode.WORKSPACE_NOT_FOUND); | ||
| } | ||
|
|
||
| WorkspaceWorker worker = workspaceWorkerQueryRepository.findById(workerId) | ||
| .orElseThrow(() -> new CustomException(ErrorCode.NOT_FOUND, "근무자를 찾을 수 없습니다")); | ||
|
|
||
| if (!worker.getWorkspace().getId().equals(workspaceId)) { | ||
| throw new CustomException(ErrorCode.WORKSPACE_NOT_FOUND); | ||
| } | ||
|
|
||
| if (!WorkspaceWorker.DEFAULT_COLOR_CODE.equals(command.getColorCode()) | ||
| && workspaceWorkerQueryRepository.existsActivatedByWorkspaceAndColorCode( | ||
| workspaceId, | ||
| command.getColorCode(), | ||
| workerId | ||
| )) { | ||
| throw new CustomException(ErrorCode.CONFLICT, "이미 사용 중인 근무자 색상입니다."); | ||
| } | ||
|
|
||
| worker.updateColorCode(command.getColorCode()); | ||
| } | ||
| } |
20 changes: 20 additions & 0 deletions
20
.../java/com/dreamteam/alter/domain/workspace/command/UpdateWorkspaceWorkerColorCommand.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,20 @@ | ||
| package com.dreamteam.alter.domain.workspace.command; | ||
|
|
||
| import lombok.AccessLevel; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
|
|
||
| @Getter | ||
| @Builder(access = AccessLevel.PRIVATE) | ||
| @AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
| public class UpdateWorkspaceWorkerColorCommand { | ||
|
ysw789 marked this conversation as resolved.
|
||
|
|
||
| private String colorCode; | ||
|
|
||
| public static UpdateWorkspaceWorkerColorCommand of(String colorCode) { | ||
| return UpdateWorkspaceWorkerColorCommand.builder() | ||
| .colorCode(colorCode) | ||
| .build(); | ||
| } | ||
| } | ||
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
8 changes: 8 additions & 0 deletions
8
...eam/alter/domain/workspace/port/inbound/ManagerUpdateWorkspaceWorkerColorCodeUseCase.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,8 @@ | ||
| package com.dreamteam.alter.domain.workspace.port.inbound; | ||
|
|
||
| import com.dreamteam.alter.domain.user.context.ManagerActor; | ||
| import com.dreamteam.alter.domain.workspace.command.UpdateWorkspaceWorkerColorCommand; | ||
|
|
||
| public interface ManagerUpdateWorkspaceWorkerColorCodeUseCase { | ||
| void execute(ManagerActor actor, Long workspaceId, Long workerId, UpdateWorkspaceWorkerColorCommand command); | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
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
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.
Uh oh!
There was an error while loading. Please reload this page.