/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.dm.device.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.validation.constraints.*;
import javax.persistence.Entity;
import javax.persistence.Table;

import me.zhengjie.base.BaseEntity;
import me.zhengjie.modules.dm.floor.domain.DmFloor;
import me.zhengjie.modules.dm.printingQueue.domain.DmPrintingQueue;
import org.hibernate.annotations.*;
import java.sql.Timestamp;
import java.io.Serializable;
import java.util.List;
import java.util.Set;

/**
* @website https://el-admin.vip
* @description /
* @author xwx
* @date 2021-03-12
**/
@Entity
@Data
@Table(name="dm_device")
public class DmDevice extends BaseEntity implements Serializable {

    @Id
    @Column(name = "id")
    @ApiModelProperty(value = "主键")
    private Long id;

    @Column(name = "code",nullable = false)
    @ApiModelProperty(value = "设备编号")
    private String code;

    @Column(name = "name",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "设备名称")
    private String name;

    @Column(name = "style",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "产品类型")
    private String style;

    @OneToOne
    @JoinColumn(name = "build_address")
    @ApiModelProperty(value = "设备安装")
    private DmFloor floor;

    @Column(name = "status",nullable = false)
    @ApiModelProperty(value = "设备状态")
    private String status;

    @Column(name = "build_date")
    @ApiModelProperty(value = "安装时间")
    private Timestamp buildDate;

    @Column(name = "warranty")
    @ApiModelProperty(value = "保修期")
    private String warranty;

    @Column(name = "last_guarantee")
    @ApiModelProperty(value = "最新维修日期")
    private Timestamp lastGuarantee;

    @Column(name = "operator",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "运维人员")
    private String operator;

    @Column(name = "link_type",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "联系方式")
    private String linkType;

    @Column(name = "remark")
    @ApiModelProperty(value = "备注")
    private String remark;

    @Column(name = "un_printing_count")
    @ApiModelProperty(value = "未打印数")
    private Integer unPrintingCount;

    @Column(name = "yi_printing_count")
    @ApiModelProperty(value = "已打印数")
    private Integer yiPrintingCount;

    @Column(name = "is_common_printer")
    @ApiModelProperty(value = "是否是公共打印机")
    private String isCommonPrinter;

    @Column(name = "printing_ip")
    @ApiModelProperty(value = "打印机ip")
    private String printingIp;

    @Column(name = "card_ip")
    @ApiModelProperty(value = "读卡器ip")
    private String cardIp;

    @Column(name = "printing_address")
    @ApiModelProperty(value = "打印机地址")
    private String printingAddress;

    @Transient
    @ApiModelProperty(value = "打印队列")
    private List<DmPrintingQueue> queueList;


    public void copy(DmDevice source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
