-
Notifications
You must be signed in to change notification settings - Fork 4
CLAP-119 작업 승인 처리 #106
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
CLAP-119 작업 승인 처리 #106
Changes from all commits
35991ab
a459914
e86172c
d5b157b
303b1d2
f54e6f8
e9d2fce
58a5885
56cbd59
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,18 @@ | ||
| package clap.server.adapter.inbound.web.dto.task; | ||
|
|
||
| import jakarta.validation.constraints.NotNull; | ||
|
|
||
| import java.time.LocalDateTime; | ||
|
|
||
| public record ApprovalTaskRequest( | ||
| @NotNull | ||
| Long categoryId, | ||
|
Contributor
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. 카테고리 id(2차)만 받아도 충분할 거 같은데 어떻게 생각하시나요?
Collaborator
Author
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. 넵 그 방향이 나을 것 같습니다. |
||
| @NotNull | ||
| Long processorId, | ||
| @NotNull | ||
| LocalDateTime dueDate, | ||
| @NotNull | ||
| Long labelId | ||
|
|
||
| ) { | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package clap.server.adapter.inbound.web.dto.task; | ||
|
|
||
| import clap.server.adapter.outbound.persistense.entity.task.constant.TaskStatus; | ||
|
|
||
| import java.time.LocalDateTime; | ||
|
|
||
| public record ApprovalTaskResponse( | ||
| Long taskId, | ||
| String processorName, | ||
| String reviewerName, | ||
| LocalDateTime deadLine, | ||
| String labelName, | ||
| TaskStatus taskStatus | ||
| ) { | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package clap.server.adapter.outbound.persistense.repository; | ||
|
|
||
| import clap.server.adapter.outbound.persistense.entity.task.LabelEntity; | ||
| import clap.server.adapter.outbound.persistense.entity.task.TaskEntity; | ||
| import clap.server.adapter.outbound.persistense.mapper.LabelPersistenceMapper; | ||
| import clap.server.adapter.outbound.persistense.repository.task.LabelRepository; | ||
| import clap.server.application.port.outbound.task.LoadLabelPort; | ||
| import clap.server.common.annotation.architecture.PersistenceAdapter; | ||
| import clap.server.domain.model.task.Label; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| import java.util.Optional; | ||
|
|
||
| @PersistenceAdapter | ||
| @RequiredArgsConstructor | ||
| public class LabelPersistenceAdapter implements LoadLabelPort { | ||
|
|
||
| private final LabelRepository labelRepository; | ||
| private final LabelPersistenceMapper labelPersistenceMapper; | ||
|
|
||
| @Override | ||
| public Optional<Label> findById(Long id) { | ||
| Optional<LabelEntity> labelEntity = labelRepository.findById(id); | ||
| return labelEntity.map(labelPersistenceMapper::toDomain); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| package clap.server.application.Task; | ||
|
|
||
| import clap.server.adapter.inbound.web.dto.task.ApprovalTaskRequest; | ||
| import clap.server.adapter.inbound.web.dto.task.ApprovalTaskResponse; | ||
| import clap.server.application.mapper.TaskMapper; | ||
| import clap.server.application.port.inbound.domain.CategoryService; | ||
| import clap.server.application.port.inbound.domain.LabelService; | ||
| import clap.server.application.port.inbound.domain.MemberService; | ||
| import clap.server.application.port.inbound.domain.TaskService; | ||
| import clap.server.application.port.inbound.task.ApprovalTaskUsecase; | ||
| import clap.server.application.port.outbound.task.CommandTaskPort; | ||
| import clap.server.common.annotation.architecture.ApplicationService; | ||
| import clap.server.domain.model.member.Member; | ||
| import clap.server.domain.model.task.Category; | ||
| import clap.server.domain.model.task.Label; | ||
| import clap.server.domain.model.task.Task; | ||
| import clap.server.exception.ApplicationException; | ||
| import clap.server.exception.code.MemberErrorCode; | ||
| import clap.server.exception.code.TaskErrorCode; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| @ApplicationService | ||
| @RequiredArgsConstructor | ||
| public class ApprovalTaskService implements ApprovalTaskUsecase { | ||
|
|
||
| private final MemberService memberService; | ||
| private final TaskService taskService; | ||
| private final CategoryService categoryService; | ||
| private final LabelService labelService; | ||
| private final CommandTaskPort commandTaskPort; | ||
|
|
||
| @Override | ||
| @Transactional | ||
| public ApprovalTaskResponse approvalTaskByReviewer(Long reviewerId, Long taskId, ApprovalTaskRequest approvalTaskRequest) { | ||
| Member reviewer = memberService.findActiveMember(reviewerId); | ||
| if (!reviewer.isReviewer()) { | ||
| throw new ApplicationException(MemberErrorCode.NOT_A_REVIEWER); | ||
| } | ||
| Task task = taskService.findById(taskId); | ||
| Member processor = memberService.findById(approvalTaskRequest.processorId()); | ||
| Category category = categoryService.findById(approvalTaskRequest.categoryId()); | ||
| Label label = labelService.findById(approvalTaskRequest.labelId()); | ||
|
|
||
| task.approveTask(reviewer, processor, approvalTaskRequest.dueDate(), category, label); | ||
| return TaskMapper.toApprovalTaskResponse(commandTaskPort.save(task)); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| import clap.server.adapter.inbound.web.dto.task.UpdateTaskRequest; | ||
| import clap.server.adapter.inbound.web.dto.task.UpdateTaskResponse; | ||
| import clap.server.adapter.outbound.infrastructure.s3.S3UploadAdapter; | ||
| import clap.server.adapter.outbound.persistense.entity.task.constant.TaskStatus; | ||
| import clap.server.application.mapper.AttachmentMapper; | ||
| import clap.server.application.mapper.TaskMapper; | ||
| import clap.server.application.port.inbound.domain.CategoryService; | ||
|
|
@@ -13,10 +14,12 @@ | |
| import clap.server.application.port.outbound.task.CommandTaskPort; | ||
| import clap.server.application.port.outbound.task.LoadAttachmentPort; | ||
| import clap.server.common.annotation.architecture.ApplicationService; | ||
| import clap.server.domain.model.member.Member; | ||
| import clap.server.domain.model.task.Attachment; | ||
| import clap.server.domain.model.task.Category; | ||
| import clap.server.domain.model.task.FilePath; | ||
| import clap.server.domain.model.task.Task; | ||
|
|
||
| import clap.server.exception.ApplicationException; | ||
| import clap.server.exception.code.TaskErrorCode; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
@@ -47,7 +50,9 @@ public UpdateTaskResponse updateTask(Long requesterId, Long taskId, UpdateTaskRe | |
| memberService.findActiveMember(requesterId); | ||
| Category category = categoryService.findById(updateTaskRequest.categoryId()); | ||
|
Contributor
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. 승인 권한이 있는 담당자만 가능하도록 해야해서, SPEL을 사용하여 메서드 단위로 승인을 하거나 MEMBER의 리뷰어 권한을 조회해서 예외 처리 추가하시면 될거같아요!
Collaborator
Author
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. 제가 이해한게 맞다면 말씀하신 부분은 approvalTaskByReviewer()메서드에 추가되어있는데 확인한번 부탁드립니다.
Contributor
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. 아 승인과 수정이 분리되어야하네요! 네 확인입니다:)
Contributor
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. 수정시에도 요청자나 담당자와 일치하는지 검증하는거 필요할거같아요! |
||
| Task task = taskService.findById(taskId); | ||
| //TODO: 작업이 요청 상태인 경우만 업데이트 가능 | ||
| if(task.getTaskStatus() != TaskStatus.REQUESTED){ | ||
| throw new ApplicationException(TaskErrorCode.TASK_STATUS_MISMATCH); | ||
| } | ||
| task.updateTask(category, updateTaskRequest.title(), updateTaskRequest.description()); | ||
| Task updatedTask = commandTaskPort.save(task); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package clap.server.application.port.inbound.domain; | ||
|
|
||
| import clap.server.application.port.outbound.task.LoadLabelPort; | ||
| import clap.server.domain.model.task.Label; | ||
| import clap.server.exception.ApplicationException; | ||
| import clap.server.exception.code.TaskErrorCode; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class LabelService { | ||
|
|
||
| private final LoadLabelPort loadLabelPort; | ||
|
|
||
| public Label findById(Long labelId) { | ||
| return loadLabelPort.findById(labelId).orElseThrow( | ||
| ()-> new ApplicationException(TaskErrorCode.LABEL_NOT_FOUND)); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package clap.server.application.port.inbound.task; | ||
|
|
||
| import clap.server.adapter.inbound.web.dto.task.ApprovalTaskRequest; | ||
| import clap.server.adapter.inbound.web.dto.task.ApprovalTaskResponse; | ||
|
|
||
| public interface ApprovalTaskUsecase { | ||
| ApprovalTaskResponse approvalTaskByReviewer(Long userId, Long taskId, ApprovalTaskRequest approvalTaskRequest); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package clap.server.application.port.outbound.task; | ||
|
|
||
| import clap.server.domain.model.task.Label; | ||
|
|
||
| import java.util.Optional; | ||
|
|
||
| public interface LoadLabelPort { | ||
|
|
||
| Optional<Label> findById(Long id); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
taskid는 dto 선언이 아닌 path variable로 변경 부탁드립니다!