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

import kr.co.accura.wtm.domain.wbs.entity.WbsNode;
import lombok.*;

import java.math.BigDecimal;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class WbsNodeDto {

    private Long id;
    private String wbsCode;
    private String name;
    private Integer level;
    private String parentCode;
    private String discipline;
    private BigDecimal plannedHours;
    private Boolean isLeaf;

    public static WbsNodeDto from(WbsNode node) {
        return WbsNodeDto.builder()
                .id(node.getId())
                .wbsCode(node.getWbsCode())
                .name(node.getName())
                .level(node.getLevel())
                .parentCode(node.getParent() != null ? node.getParent().getWbsCode() : null)
                .discipline(node.getDiscipline())
                .plannedHours(node.getPlannedHours())
                .isLeaf(node.getIsLeaf())
                .build();
    }
}
