Skip to content
Draft
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
Expand Up @@ -433,7 +433,11 @@ public Task replaceReviewAfterCriticalChange(
);

Map<String, Object> hrSnapshot = new LinkedHashMap<>();
hrSnapshot.put("worker_id", savedTask.workerId().toString());
hrSnapshot.put(
"worker_id",
savedTask.workerId() == null ? null : savedTask.workerId().toString()
);
hrSnapshot.put("target_type", savedTask.targetType().name());
hrSnapshot.put("task_type", savedTask.taskType().name());
hrSnapshot.put("workflow_id", savedTask.workflowId());
hrSnapshot.put("title", savedTask.title());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ private static ActorType actorType(TaskSource source) {
return switch (source) {
case AI_CANDIDATE -> ActorType.AI_AGENT;
case SYSTEM_DDAY -> ActorType.SYSTEM_RULE;
case MANUAL -> ActorType.HR_USER;
case MANUAL, FILE_IMPORT -> ActorType.HR_USER;
case WORKER_RESPONSE -> ActorType.WORKER_LINK;
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,15 @@ public DocumentReadinessResult calculate(UUID taskId, ActorContext actor) {
Set<DocumentType> requiredTypes = requiredDocumentTypes(taskId, companyId);

LocalDate today = LocalDate.now(clock);
WorkerDocumentSearchQuery allDocumentsQuery = new WorkerDocumentSearchQuery(
task.workerId(), null, null, null, null, 0, 100
);
List<WorkerDocument> workerDocuments = workerDocumentRepository.findPage(companyId, allDocumentsQuery);
List<WorkerDocument> workerDocuments;
if (task.workerId() == null) {
workerDocuments = List.of();
} else {
WorkerDocumentSearchQuery allDocumentsQuery = new WorkerDocumentSearchQuery(
task.workerId(), null, null, null, null, 0, 100
);
workerDocuments = workerDocumentRepository.findPage(companyId, allDocumentsQuery);
}

Set<DocumentType> available = EnumSet.noneOf(DocumentType.class);
Set<DocumentType> expired = EnumSet.noneOf(DocumentType.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import com.fowoco.server.task.application.CreateTaskCommand;
import com.fowoco.server.task.domain.TaskTargetType;
import com.fowoco.server.task.domain.TaskType;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
Expand All @@ -13,7 +14,8 @@

@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public record CreateTaskRequest(
@NotNull UUID workerId,
TaskTargetType targetType,
UUID workerId,
UUID caseId,
@NotNull TaskType taskType,
@NotBlank @Size(max = 100) String workflowId,
Expand All @@ -24,6 +26,9 @@ public record CreateTaskRequest(
) {
CreateTaskCommand toCommand() {
return new CreateTaskCommand(
targetType == null
? (workerId == null ? TaskTargetType.COMPANY : TaskTargetType.WORKER)
: targetType,
workerId,
caseId,
taskType,
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/fowoco/server/task/api/TaskController.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import com.fowoco.server.common.web.RequestMetadata;
import com.fowoco.server.task.application.TaskResult;
import com.fowoco.server.task.application.TaskWorkflowService;
import com.fowoco.server.task.domain.TaskSource;
import com.fowoco.server.task.domain.TaskStatus;
import com.fowoco.server.task.domain.TaskTargetType;
import com.fowoco.server.task.domain.TaskType;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
Expand Down Expand Up @@ -62,6 +64,8 @@ public TaskController(
public TaskPageResponse findAll(
@RequestParam(required = false) TaskStatus status,
@RequestParam(required = false) TaskType taskType,
@RequestParam(name = "target_type", required = false) TaskTargetType targetType,
@RequestParam(required = false) TaskSource source,
@RequestParam(required = false) UUID workerId,
@Parameter(description = "Case ID 필터")
@RequestParam(name = "case_id", required = false) UUID caseId,
Expand All @@ -74,6 +78,8 @@ public TaskPageResponse findAll(
return TaskPageResponse.from(taskService.findAll(
status,
taskType,
targetType,
source,
workerId,
caseId,
dueFrom,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.fowoco.server.task.domain.Task;
import com.fowoco.server.task.domain.TaskSource;
import com.fowoco.server.task.domain.TaskStatus;
import com.fowoco.server.task.domain.TaskTargetType;
import com.fowoco.server.task.domain.TaskType;
import java.time.Instant;
import java.time.LocalDate;
Expand All @@ -16,6 +17,7 @@
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public record TaskDetailResponse(
UUID taskId,
TaskTargetType targetType,
UUID workerId,
UUID caseId,
TaskType taskType,
Expand All @@ -40,6 +42,7 @@ static TaskDetailResponse from(TaskResult result) {
Task task = result.task();
return new TaskDetailResponse(
task.taskId(),
task.targetType(),
task.workerId(),
task.caseId(),
task.taskType(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.fowoco.server.task.domain.Task;
import com.fowoco.server.task.domain.TaskSource;
import com.fowoco.server.task.domain.TaskStatus;
import com.fowoco.server.task.domain.TaskTargetType;
import com.fowoco.server.task.domain.TaskType;
import java.time.Instant;
import java.time.LocalDate;
Expand All @@ -13,6 +14,7 @@
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public record TaskSummaryResponse(
UUID taskId,
TaskTargetType targetType,
UUID workerId,
UUID caseId,
TaskType taskType,
Expand All @@ -30,6 +32,7 @@ public record TaskSummaryResponse(
static TaskSummaryResponse from(Task task) {
return new TaskSummaryResponse(
task.taskId(),
task.targetType(),
task.workerId(),
task.caseId(),
task.taskType(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ private int order(TaskType taskType) {
case RECONTRACT -> 1;
case STAY_PERIOD_EXTENSION -> 2;
case EMPLOYMENT_PERIOD_EXTENSION -> 3;
default -> throw new ApiException(TaskErrorCode.INVALID_AI_CANDIDATE_TASK_DATA);
};
}

Expand All @@ -319,6 +320,7 @@ private String title(TaskType taskType) {
case RECONTRACT -> "재계약 조건 확인";
case STAY_PERIOD_EXTENSION -> "체류기간 연장 준비";
case EMPLOYMENT_PERIOD_EXTENSION -> "취업활동기간 연장 준비";
default -> throw new ApiException(TaskErrorCode.INVALID_AI_CANDIDATE_TASK_DATA);
};
}

Expand All @@ -327,6 +329,7 @@ private String description(TaskType taskType) {
case RECONTRACT -> "재계약 조건과 계속 고용 의사를 검토합니다.";
case STAY_PERIOD_EXTENSION -> "체류기간 연장에 필요한 정보와 서류를 확인합니다.";
case EMPLOYMENT_PERIOD_EXTENSION -> "재계약 결과를 바탕으로 취업활동기간 연장을 준비합니다.";
default -> throw new ApiException(TaskErrorCode.INVALID_AI_CANDIDATE_TASK_DATA);
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.fowoco.server.task.application;

import com.fowoco.server.task.domain.TaskTargetType;
import com.fowoco.server.task.domain.TaskType;
import java.time.LocalDate;
import java.util.Map;
import java.util.UUID;

public record CreateTaskCommand(
TaskTargetType targetType,
UUID workerId,
UUID caseId,
TaskType taskType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fowoco.server.common.error.ApiException;
import com.fowoco.server.task.application.error.TaskErrorCode;
import com.fowoco.server.task.domain.TaskTargetType;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
Expand Down Expand Up @@ -63,6 +64,7 @@ public TaskContentCodec(ObjectMapper objectMapper) {
}

public EncodedTaskContent encode(
TaskTargetType targetType,
UUID workerId,
String workflowId,
String taskType,
Expand All @@ -77,8 +79,9 @@ public EncodedTaskContent encode(
approvalTarget.put("description", normalizeNullableText(description, 2000));
approvalTarget.put("due_date", dueDate == null ? null : dueDate.toString());
approvalTarget.put("task_type", normalizeText(taskType, 40));
approvalTarget.put("target_type", targetType.name());
approvalTarget.put("title", normalizeText(title, 160));
approvalTarget.put("worker_id", workerId.toString());
approvalTarget.put("worker_id", workerId == null ? null : workerId.toString());
approvalTarget.put("workflow_id", normalizeText(workflowId, 100));
try {
String businessDataJson = objectMapper.writeValueAsString(normalizedBusinessData);
Expand All @@ -89,6 +92,27 @@ public EncodedTaskContent encode(
}
}

public EncodedTaskContent encode(
UUID workerId,
String workflowId,
String taskType,
String title,
String description,
LocalDate dueDate,
Map<String, Object> businessData
) {
return encode(
TaskTargetType.WORKER,
workerId,
workflowId,
taskType,
title,
description,
dueDate,
businessData
);
}

@SuppressWarnings("unchecked")
public Map<String, Object> decodeBusinessData(String businessDataJson) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ final class TaskDomainEvents {
private static final String AGGREGATE_TYPE = "Task";
private static final Set<String> TASK_CREATED_FIELDS = Set.of(
"task_type",
"target_type",
"status",
"workflow_id",
"workflow_catalog_version",
Expand Down Expand Up @@ -49,6 +50,7 @@ static DomainEventEnvelope taskCreated(
TASK_CREATED_FIELDS,
Map.of(
"task_type", task.taskType(),
"target_type", task.targetType(),
"status", task.status(),
"workflow_id", task.workflowId(),
"workflow_catalog_version", task.workflowCatalogVersion(),
Expand Down
Loading
Loading