package com.gscopetech.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.*;
import javax.persistence.criteria.CriteriaBuilder;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonManagedReference;

import org.springframework.stereotype.Component;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;

/**
 * Created with airsim.
 * Author  秋杰
 * Email   yaoqiujie@gscopetech.com
 * Date    2017/3/23
 */
@Table(name="wifidevice")
@Entity
@Component
@Data
@EqualsAndHashCode(callSuper = false)
public class WiFiDevice implements Serializable {
    @GeneratedValue
    @Id
    private Long id;

    // 设备IMEI号 International Mobile Equipment Identity
    @Column(length = 32)
    private String imei;

    // 设备密码
    @Column(length = 32)
    private String password;

    // 设备类型
    @Column(length = 32)
    private String type;

    // 设备版本
    @Column(length = 64)
    private String swVersion;

    // 导入时间
    private Date importDate;

    // 是否激活
    private Boolean isAlive;

    // 是否已经绑定用户
    private Boolean isBound;

    // 绑定的套餐
    @ManyToOne
    @JoinColumn(name = "uPkg_id")
    @JsonBackReference
    private UCloudPackage uPkg;

    // 已经绑定的用户
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "wifiDevice")
    @JsonManagedReference(value = "user-device")
    private WiFiUser wifiUser;
}
