package com.storlead.centre.pojo.vo;

import com.storlead.centre.entity.SysAppPageInfoEntity;
import com.storlead.centre.pojo.entity.SysAppInfoEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.util.CollectionUtils;

import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @program: storlead-centre-platform
 * @description:
 * @author: chenkq
 * @create: 2025-12-08 15:03
 */
@Data
public class SysAppPageVO {

    @ApiModelProperty(value = "主键ID")
    private Long pageId;

    @ApiModelProperty(value = "应用名称")
    private String appName;

    @ApiModelProperty(value = "图标")
    private String pageIcon;


    public static List<SysAppPageVO> appPageInfoListToAppPageTreeVoList(List<SysAppPageInfoEntity> vals) {
        if (CollectionUtils.isEmpty(vals)) {
            return null;
        }
        List<SysAppPageVO> departmentTrees = vals.stream().map(SysAppPageVO::appPageInfoListToAppPageTreeVo).filter(obj -> !Objects.isNull(obj)).collect(Collectors.toList());
        return departmentTrees;
    }

    public static SysAppPageVO  appPageInfoListToAppPageTreeVo(SysAppPageInfoEntity val) {
        if (null == val) {
            return null;
        }
        SysAppPageVO appPageTree = new SysAppPageVO();
        appPageTree.setPageId(val.getId());
        appPageTree.setAppName(val.getPageName());
        appPageTree.setPageIcon(val.getPageIcon());
        return appPageTree;
    }
}
