/*
*  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.dmAccessTraffic.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import me.zhengjie.modules.dmuser.domain.DmUser;
import me.zhengjie.ykt.domain.DmRoomDevice;

import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.io.Serializable;
import java.util.List;

/**
* @website https://el-admin.vip
* @description /
* @author zhirong
* @date 2021-11-22
**/
@Entity
@Data
@Table(name="dm_access_traffic")
public class DmAccessTraffic implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    @ApiModelProperty(value = "id")
    private Long id;

//    @Column(name = "user_number")
    @ApiModelProperty(value = "用户")
    @OneToOne
    @JoinColumn(name="user_number", referencedColumnName ="id")
    private DmUser user;

    @Column(name = "card_number")
    @ApiModelProperty(value = "卡号")
    private String cardNumber;

    @Column(name = "room_device")
    @ApiModelProperty(value = "门禁设备编号")
    private String roomDevice;

    @Column(name = "come_go_out")
    @ApiModelProperty(value = "出入")
    private String comeGoOut;

    @Column(name = "access_time")
    @ApiModelProperty(value = "通行时间")
    private Timestamp accessTime;

    @Column(name = "access_photo")
    @ApiModelProperty(value = "通行照片")
    private String accessPhoto;

    @Column(name = "passage_way")
    @ApiModelProperty(value = "通行方式")
    private String passageWay;

    @Column(name = "create_by")
    @ApiModelProperty(value = "创建者")
    private String createBy;

    @Column(name = "update_by")
    @ApiModelProperty(value = "更新者")
    private String updateBy;

    @Column(name = "create_time")
    @ApiModelProperty(value = "创建时间")
    private Timestamp createTime;

    @Column(name = "update_time")
    @ApiModelProperty(value = "更新时间")
    private Timestamp updateTime;

    @Column(name = "is_success")
    @ApiModelProperty(value = "是否通行成功")
    private Boolean isSuccess;

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