package com.fuyuanshen.equipment.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fuyuanshen.common.tenant.core.TenantEntity;
import lombok.Data;

import java.util.Date;

/**
 * 设备分配权限表 (解决跨客户共享)
 *
 * @TableName device_type_grants
 */
@TableName(value = "device_type_grants")
@Data
public class DeviceTypeGrants extends TenantEntity {

    /**
     * id
     */
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 设备类型
     */
    private Long deviceTypeId;

    /**
     * 被授权的客户
     */
    private Long customerId;

    /**
     * 授权方客户
     */
    private Long grantorCustomerId;

    /**
     * 生成日期
     */
    private Date grantedAt;

    /**
     * 关联分配记录
     */
    private Long assignmentId;


    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        DeviceTypeGrants other = (DeviceTypeGrants) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) && (this.getDeviceTypeId() == null ? other.getDeviceTypeId() == null : this.getDeviceTypeId().equals(other.getDeviceTypeId())) && (this.getCustomerId() == null ? other.getCustomerId() == null : this.getCustomerId().equals(other.getCustomerId())) && (this.getGrantorCustomerId() == null ? other.getGrantorCustomerId() == null : this.getGrantorCustomerId().equals(other.getGrantorCustomerId())) && (this.getGrantedAt() == null ? other.getGrantedAt() == null : this.getGrantedAt().equals(other.getGrantedAt())) && (this.getAssignmentId() == null ? other.getAssignmentId() == null : this.getAssignmentId().equals(other.getAssignmentId()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getDeviceTypeId() == null) ? 0 : getDeviceTypeId().hashCode());
        result = prime * result + ((getCustomerId() == null) ? 0 : getCustomerId().hashCode());
        result = prime * result + ((getGrantorCustomerId() == null) ? 0 : getGrantorCustomerId().hashCode());
        result = prime * result + ((getGrantedAt() == null) ? 0 : getGrantedAt().hashCode());
        result = prime * result + ((getAssignmentId() == null) ? 0 : getAssignmentId().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", deviceTypeId=").append(deviceTypeId);
        sb.append(", customerId=").append(customerId);
        sb.append(", grantorCustomerId=").append(grantorCustomerId);
        sb.append(", grantedAt=").append(grantedAt);
        sb.append(", assignmentId=").append(assignmentId);
        sb.append("]");
        return sb.toString();
    }
}