package com.yuchen.saas.manage.system.api.vo;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.yuchen.saas.manage.system.api.entity.Menu;
import com.yuchen.saas.manage.system.api.entity.Role;
import com.yuchen.saas.manage.system.api.entity.RoleUser;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.nest.springwrap.core.tool.node.INode;

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


@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "RoleVO对象", description = "RoleVO对象")
public class RoleVO extends Role implements INode<RoleVO> {
    private static final long serialVersionUID = 1L;


    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;


    @JsonSerialize(using = ToStringSerializer.class)
    private Long parentId;


    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<RoleVO> children;

    @Override
    public List<RoleVO> getChildren() {
        if (this.children == null) {
            this.children = new ArrayList<>();
        }
        return this.children;
    }


    private String parentName;


    @ApiModelProperty(value = "菜单ID集合")
    private List<RoleMenuVO> menus;

    @ApiModelProperty(value = "园区ID集合")
    private List<RoleParkVO> parks;

    @ApiModelProperty(value = "用户ID集合")
    private List<RoleUserVO> users;

    @ApiModelProperty(value = "用户ID集合")
    private List<Long> devices;
}
