package com.purui.prims.headless.api.pojo.response;

import com.purui.prims.headless.api.pojo.SchemaItem;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;

import java.util.Objects;

@Data
@ToString
@ApiModel(value = "主题域")
public class DomainResp extends SchemaItem {

    @ApiModelProperty(value = "父ID")
    private Long parentId;

    @ApiModelProperty(value = "全路径")
    private String fullPath;

    @ApiModelProperty(value = "是否公开")
    private Integer isOpen = 0;

    @ApiModelProperty(value = "是否可以编辑")
    private boolean hasEditPermission = false;

    @ApiModelProperty(value = "是否有模型")
    private boolean hasModel;

    public boolean openToAll() {
        return isOpen != null && isOpen == 1;
    }

    @Override
    public boolean equals(Object o) {
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        DomainResp that = (DomainResp) o;
        if (getId() == null || that.getId() == null) {
            return false;
        }
        return Objects.equals(getId().intValue(), that.getId().intValue());
    }

    @Override
    public int hashCode() {
        if (getId() == null) {
            return 0;
        }
        return getId().hashCode();
    }
}
