package com.storlead.centre.pojo.vo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.storlead.centre.pojo.entity.SysAppInfoEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.util.CollectionUtils;

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 SysAppVO {

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

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

    private List<SysAppPageVO> appPages;


    /**
     * 子公司转换
     * @param vals
     * @return
     */
    public static List<SysAppVO> appInfoListToAppTreeVoList(List<SysAppInfoEntity> vals) {
        if (CollectionUtils.isEmpty(vals)) {
            return null;
        }
        List<SysAppVO> departmentTrees = vals.stream().map(SysAppVO::appInfoListToAppTreeVo).filter(obj -> !Objects.isNull(obj)).collect(Collectors.toList());
        return departmentTrees;
    }

    public static SysAppVO  appInfoListToAppTreeVo(SysAppInfoEntity val) {
        if (null == val) {
            return null;
        }
        SysAppVO appTree = new SysAppVO();
        appTree.setAppId(val.getId());
        appTree.setAppName(val.getAppName());
        return appTree;
    }
}
