package com.fastbee.iot.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.Setter;

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


/**
 * 项目数据关联对象 iot_goview_project_data
 *
 * @author zhuangpeng.li
 * @date 2024-11-13
 */

@ApiModel(value = "GoviewProjectData", description = "项目数据关联 iot_goview_project_data")
@Data
@TableName("iot_goview_project_data" )
public class GoviewProjectData implements Serializable{
    private static final long serialVersionUID=1L;

    /** 主键 */
    @TableId(value = "id")
    @ApiModelProperty("主键")
    private String id;

    /** 项目id */
    @ApiModelProperty("项目id")
    private String projectId;

    /** 存储数据 */
    @ApiModelProperty("存储数据")
    private byte[] content;

    /** 创建时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty("创建时间")
    private Date createTime;

    /** 创建人id */
    @ApiModelProperty("创建人id")
    private String createBy;

    /** 更新时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty("更新时间")
    private Date updateTime;

    @Setter
    @TableField(exist = false)
    @ApiModelProperty("请求参数")
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private Map<String, Object> params;

    public Map<String, Object> getParams(){
        if (params == null){
            params = new HashMap<>();
        }
        return params;
    }

    public String getDataToStr() {
        byte[] bs = getContent();
        String str = "二进制转换错误";
        str = new String(bs);
        return str;
    }

}
