package cn.pluss.platform.entity;

import cn.pluss.platform.enums.DeviceOperateType;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.Date;

/**
 * <p>
 * 设备信息流转表
 * </p>
 *
 * @author crystal
 * @since 2022-04-02
 */
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("tb_pluss_device_operate_info")
public class DeviceOperateInfo implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;


    /**
     * 设备号
     */
    @TableField("deviceNo")
    private String deviceNo;


    /**
     * 操作类型 00 ：入库 01：划拨 02：接收 03：绑定 04：解绑 05：购买
     */
    @TableField("type")
    private String type;


    /**
     * 操作用户ID
     */
    @TableField("userId")
    private Long userId;


    /**
     * 创建时间
     */
    @TableField(value = "createTime", fill = FieldFill.INSERT)
    private Date createTime;

    /**
     * 创建时间 开始时间
     */
    @TableField(exist = false, condition = "createTime &gt; #{%s}")
    private Date createTimeStart;

    /**
     * 创建时间 截止时间
     */
    @TableField(exist = false, condition = "createTime &lt; #{%s}")
    private Date createTimeEnd;

    /**
     * 备注
     */
    @TableField("remark")
    protected String remark;


    public DeviceOperateInfo(UserApp userApp, String type,String deviceNo,String remark) {
        this.deviceNo = deviceNo;
        this.remark = remark;
        this.type = type;
        if(userApp != null){
            this.userId = userApp.getUserId();
        }
    }
}