package com.ruoyi.demo.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.ruoyi.demo.entity.bo.StatisticsAddBo;
import lombok.Data;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;

@Data
@TableName("dl_user")
public class DlUser {
    @TableField("user_id")
    private String userId;
    @TableField("user_name")
    private String userName;
    @TableField("user_telephone")
    private String userTelephone;
    @TableField("start_equipment_id")
    private String startEquipmentId;
    @TableField("start_equipment_name")
    private String startEquipmentName;
    @TableField("start_equipment_code")
    private String startEquipmentCode;
    @TableField("start_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime startTime;
    @TableField("end_equipment_id")
    private String endEquipmentId;
    @TableField("end_equipment_name")
    private String endEquipmentName;

    @TableField("end_equipment_code")
    private String endEquipmentCode;
    @TableField("end_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime endTime;
    @TableField("total_price")
    private Float totalPrice;

    @TableField("deleted")
    private int deleted;

    public DlUser(){}
    public DlUser(StatisticsAddBo s,Equipment equipment){
        this.userId = s.getUserId();
        this.userName = s.getUserName();
        this.userTelephone = s.getUserTelephone();
        this.startEquipmentId = equipment.getEquipmentId();
        this.startEquipmentName = equipment.getEquipmentName();
        this.startEquipmentCode = equipment.getEquipmentCode();
        this.startTime = s.getTime();
        this.endEquipmentId = equipment.getEquipmentId();
        this.endEquipmentName = equipment.getEquipmentName();
        this.endEquipmentCode = equipment.getEquipmentCode();
        this.endTime = s.getTime();
        this.totalPrice = Float.valueOf(0);
    }
}
