package com.tofly.ghrq_route.module.planPointRepair.domain;

import com.google.gson.Gson;
import com.google.gson.annotations.Expose;
import com.google.gson.reflect.TypeToken;

import org.greenrobot.greendao.converter.PropertyConverter;

import java.io.Serializable;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class AdjustRepairContent implements Serializable {
    private String parentId;

    private String parentName;
    private List<String> menuIds;
    private String note = "";

    private boolean hasNone = false;

    @Expose(serialize = false, deserialize = false)
    private MaintainSelectParam noneParam = null;

    private int exist = 0;      //1存在，0不存在

    public static final Map<String, String> defaultMap = new HashMap<>();

    static {
        defaultMap.put("压力表", "运行正常");
        defaultMap.put("阀门", "运行正常");
        defaultMap.put("安全阀", "切断压力正常");
        defaultMap.put("调压器", "运行正常");
        defaultMap.put("燃气管道", "运行正常");
        defaultMap.put("安全水封", "无");
    }

    public AdjustRepairContent(String parentId, String parentName) {
        this.parentId = parentId;
        this.parentName = parentName;
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    public String getParentName() {
        return parentName;
    }

    public void setParentName(String parentName) {
        this.parentName = parentName;
    }

    public List<String> getMenuIds() {
        return menuIds;
    }

    public void setMenuIds(List<String> menuIds) {
        this.menuIds = menuIds;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    public int getExist() {
        return exist;
    }

    public void setExist(int exist) {
        this.exist = exist;
    }

    public boolean isHasNone() {
        return hasNone;
    }

    public void setHasNone(boolean hasNone) {
        this.hasNone = hasNone;
    }

    public MaintainSelectParam getNoneParam() {
        return noneParam;
    }

    public void setNoneParam(MaintainSelectParam noneParam) {
        this.noneParam = noneParam;
    }

    public static class List_RepairContent_Converter implements PropertyConverter<List<AdjustRepairContent>, String> {

        @Override
        public List<AdjustRepairContent> convertToEntityProperty(String databaseValue) {
            if (databaseValue == null)
                return null;

            Gson gson = new Gson();
            Type type = new TypeToken<List<AdjustRepairContent>>(){}.getType();
            List<AdjustRepairContent> contents  = gson.fromJson(databaseValue, type);
            return contents;
        }

        @Override
        public String convertToDatabaseValue(List<AdjustRepairContent> contents) {
            if (contents == null){
                return null;
            }else {
                Gson gson = new Gson();
                String strJson = gson.toJson(contents);
                return strJson;
            }
        }
    }
}
