package com.yimeng.okr.dto;

import com.yimeng.okr.entity.SysDepartment;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
public class DepartmentTreeNode {
    private Long id;
    private String name;
    private Long parentId;
    private Long leaderId;
    private String leaderName;
    private Integer sortOrder;
    private List<DepartmentTreeNode> children = new ArrayList<>();

    public static DepartmentTreeNode from(SysDepartment dept) {
        DepartmentTreeNode node = new DepartmentTreeNode();
        node.setId(dept.getId());
        node.setName(dept.getName());
        node.setParentId(dept.getParentId());
        node.setLeaderId(dept.getLeaderId());
        node.setSortOrder(dept.getSortOrder());
        return node;
    }
}
