package com.imdroid.beidou.data.dto;

import com.google.gson.annotations.Expose;
import com.imdroid.beidou.utils.GsonUtils;
import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 小程序硬件设备消息body对象
 *
 * @author LiGang
 * @date 2023/11/12 10:19
 */
@Setter
@Getter
public class MiniHardwareDeviceMessageDTO {

    @Expose
    private List<String> to_openid_list;

    @Expose
    private String template_id;

    @Expose
    private String sn;

    @Expose
    private String modelId;

    @Expose
    private String page;

    @Expose
    private String miniprogram_state = "developer";

    @Expose
    private String lang = "zh_CN";

    @Expose
    private Map<String, Map<String, Object>> data;


    public void addDataItem(String key, Object value) {
        if (data == null) {
            data = new HashMap<>(8);
        }
        Map<String, Object> valueMap = new HashMap<>(1);
        valueMap.put("value", value);
        data.put(key, valueMap);
    }

    public void removeDataItem(String key) {
        data.remove(key);
    }

    @Override
    public String toString() {
        return GsonUtils.toJsonExpose(this);
    }

}
