package com.app.admin.framework.system.organization.convert;

import com.app.admin.framework.system.organization.model.SysOrganization;
import com.app.framework.core.support.convert.ConvertTreeNodeUtils;
import com.app.framework.core.support.enums.common.StateEnum;
import com.app.framework.core.support.view.tree.ExTreeNode;

public class SysOrganizationConvert extends ConvertTreeNodeUtils<SysOrganization, ExTreeNode> {

    @Override
    public void convert(SysOrganization entity, ExTreeNode node) {
        node.setId(entity.getId().toString());
        String text = entity.getName();
        if (StateEnum.DISABLE.equalValue(entity.getState())) {
            text = text + "[已禁用]";
        } else if (StateEnum.DELETE.equalValue(entity.getState())) {
            text = text + "[已删除]";
        }
        node.setName(text);
        if (!entity.getParentId().equals(0L)) {
            node.setParentId(entity.getParentId().toString());
        }
    }

}