package com.ecep.contract.vm;

import java.time.LocalDateTime;

import com.ecep.contract.model.CloudRk;
import com.ecep.contract.model.Company;

import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = false)
public class CloudRkViewModel extends IdentityViewModel<CloudRk> {
    /**
     * 云端Id
     */
    private SimpleStringProperty cloudId = new SimpleStringProperty();
    /**
     * 更新间隔天数
     */
    private SimpleIntegerProperty updateDays = new SimpleIntegerProperty();
    /**
     * 自动更新
     */
    private SimpleBooleanProperty autoUpdate = new SimpleBooleanProperty();
    /**
     * 相关方资信评价等级
     */
    private SimpleStringProperty rank = new SimpleStringProperty();
    /**
     * 相关方资信评价等级描述
     */
    private SimpleStringProperty rankDescription = new SimpleStringProperty();
    /**
     * 客户资信评价等级
     */
    private SimpleStringProperty customerGrade = new SimpleStringProperty();
    /**
     * 客户资信评价等级描述
     */
    private SimpleStringProperty customerDescription = new SimpleStringProperty();
    /**
     * 客户资信评价等级描述
     */
    private SimpleIntegerProperty customerScore = new SimpleIntegerProperty();
    /**
     * 供应商资信评价等级
     */
    private SimpleStringProperty vendorGrade = new SimpleStringProperty();
    /**
     * 供应商资信评价等级描述
     */
    private SimpleStringProperty vendorDescription = new SimpleStringProperty();
    /**
     * 供应商资信评价等级描述
     */
    private SimpleIntegerProperty vendorScore = new SimpleIntegerProperty();
    /**
     * 描述
     */
    private SimpleStringProperty description = new SimpleStringProperty();
    /**
     * 公司
     */
    private SimpleObjectProperty<Company> company = new SimpleObjectProperty<>();
    /**
     * 最后更新日期
     */
    private SimpleObjectProperty<LocalDateTime> latestUpdate = new SimpleObjectProperty<>();
    /**
     * 企业更新日期
     */
    private SimpleObjectProperty<LocalDateTime> cloudEntUpdate = new SimpleObjectProperty<>();
    /**
     * 黑名单更新日期
     */
    private SimpleObjectProperty<LocalDateTime> cloudBlackListUpdated = new SimpleObjectProperty<>();
    /**
     * 云端最新更新时间
     */
    private SimpleObjectProperty<LocalDateTime> cloudLatest = new SimpleObjectProperty<>();
    /**
     * Version
     */
    private SimpleIntegerProperty version = new SimpleIntegerProperty();

    @Override
    protected void updateFrom(CloudRk v) {
        super.updateFrom(v);
        cloudId.set(v.getCloudId());
        updateDays.set(v.getUpdateDays());
        autoUpdate.set(v.isAutoUpdate());
        description.set(v.getDescription());
        rank.set(v.getRank());
        rankDescription.set(v.getRankDescription());
        customerGrade.set(v.getCustomerGrade());
        customerDescription.set(v.getCustomerDescription());
        customerScore.set(v.getCustomerScore());
        vendorGrade.set(v.getVendorGrade());
        vendorDescription.set(v.getVendorDescription());
        vendorScore.set(v.getVendorScore());
        company.set(v.getCompany());
        latestUpdate.set(v.getLatestUpdate());
        cloudEntUpdate.set(v.getCloudEntUpdate());
        cloudBlackListUpdated.set(v.getCloudBlackListUpdated());
        cloudLatest.set(v.getCloudLatest());
        cloudLatest.set(v.getCloudLatest());
        version.set(v.getVersion());
    }

    @Override
    public boolean copyTo(CloudRk v) {
        boolean result = super.copyTo(v);
        v.setCloudId(cloudId.get());
        v.setUpdateDays(updateDays.get());
        v.setAutoUpdate(autoUpdate.get());
        v.setDescription(description.get());
        v.setRank(rank.get());
        v.setRankDescription(rankDescription.get());
        v.setCustomerGrade(customerGrade.get());
        v.setCustomerDescription(customerDescription.get());
        v.setCustomerScore(customerScore.get());
        v.setVendorGrade(vendorGrade.get());
        v.setVendorDescription(vendorDescription.get());
        v.setVendorScore(vendorScore.get());
        v.setCompany(company.get());
        v.setLatestUpdate(latestUpdate.get());
        v.setCloudEntUpdate(cloudEntUpdate.get());
        v.setCloudBlackListUpdated(cloudBlackListUpdated.get());
        v.setCloudLatest(cloudLatest.get());
        v.setVersion(version.get());
        return result;
    }
}
