package kr.co.accura.wtm.domain.project.dto;

import kr.co.accura.wtm.domain.project.entity.Project;

import java.time.LocalDate;

public record ProjectDto(
        Long id,
        String projectCode,
        String name,
        String description,
        String projectType,
        String status,
        LocalDate startDate,
        LocalDate endDate,
        Long pmUserId,
        String pmUserName
) {
    public static ProjectDto from(Project project) {
        return new ProjectDto(
                project.getId(),
                project.getProjectCode(),
                project.getName(),
                project.getDescription(),
                project.getProjectType() != null ? project.getProjectType().name() : null,
                project.getStatus() != null ? project.getStatus().name() : null,
                project.getStartDate(),
                project.getEndDate(),
                project.getPmUser() != null ? project.getPmUser().getId() : null,
                project.getPmUser() != null ? project.getPmUser().getFullName() : null
        );
    }
}
