package com.example.chemical.ui.plan.room;

import androidx.room.TypeConverter;

import com.blankj.utilcode.util.GsonUtils;
import com.example.chemical.ui.plan.room.bean.input_add.InventoryItemBean;
import com.example.chemical.ui.plan.room.bean.locker.CabinetLayerSelect;
import com.example.chemical.ui.plan.room.bean.locker.HxpCabinetAdminVo;
import com.example.chemical.ui.plan.room.bean.locker.HxpCabinetDoorVo;
import com.example.chemical.ui.plan.room.bean.locker.HxpCabinetLockVo;
import com.google.gson.reflect.TypeToken;
import com.rc.httpcore.bean.BelongingPersonBean;
import com.rc.httpcore.bean.HxpChemicalVo;
import com.rc.httpcore.bean.TopicDataBean;

import java.lang.reflect.Type;
import java.util.List;

public class RoomConverter {

    @TypeConverter
    public String topicToString(TopicDataBean topicDataBean) {
        return GsonUtils.toJson(topicDataBean);
    }

    @TypeConverter
    public TopicDataBean stringToTopic(String json) {
        return GsonUtils.fromJson(json, TopicDataBean.class);
    }

    @TypeConverter
    public String hxpToString(HxpChemicalVo hxpChemicalVo) {
        return GsonUtils.toJson(hxpChemicalVo);
    }

    @TypeConverter
    public HxpChemicalVo stringToHxp(String json) {
        return GsonUtils.fromJson(json, HxpChemicalVo.class);
    }

    @TypeConverter
    public String belongToString(BelongingPersonBean belongingPersonBean) {
        return GsonUtils.toJson(belongingPersonBean);
    }

    @TypeConverter
    public BelongingPersonBean stringToBelong(String json) {
        return GsonUtils.fromJson(json, BelongingPersonBean.class);
    }

    @TypeConverter
    public String doorListToString(List<HxpCabinetDoorVo> list) {
        return GsonUtils.toJson(list);
    }

    @TypeConverter
    public List<HxpCabinetDoorVo> stringToDoorList(String json) {
        Type listType = new TypeToken<List<HxpCabinetDoorVo>>() {
        }.getType();
        return GsonUtils.fromJson(json, listType);
    }

    @TypeConverter
    public String adminListToString(List<HxpCabinetAdminVo> list) {
        return GsonUtils.toJson(list);
    }

    @TypeConverter
    public List<HxpCabinetAdminVo> stringToAdminList(String json) {
        Type listType = new TypeToken<List<HxpCabinetAdminVo>>() {
        }.getType();
        return GsonUtils.fromJson(json, listType);
    }

    @TypeConverter
    public String lockListToString(List<HxpCabinetLockVo> list) {
        return GsonUtils.toJson(list);
    }

    @TypeConverter
    public List<HxpCabinetLockVo> stringToLockList(String json) {
        Type listType = new TypeToken<List<HxpCabinetLockVo>>() {
        }.getType();
        return GsonUtils.fromJson(json, listType);
    }

    @TypeConverter
    public String layerListToString(List<CabinetLayerSelect> list) {
        return GsonUtils.toJson(list);
    }

    @TypeConverter
    public List<CabinetLayerSelect> stringToLayerList(String json) {
        Type listType = new TypeToken<List<CabinetLayerSelect>>() {
        }.getType();
        return GsonUtils.fromJson(json, listType);
    }

    @TypeConverter
    public String inventoryListToString(List<InventoryItemBean> list) {
        return GsonUtils.toJson(list);
    }

    @TypeConverter
    public List<InventoryItemBean> stringToInventoryList(String json) {
        Type listType = new TypeToken<List<InventoryItemBean>>() {
        }.getType();
        return GsonUtils.fromJson(json, listType);
    }

    @TypeConverter
    public String layerSelectListToString(CabinetLayerSelect obj) {
        return GsonUtils.toJson(obj);
    }

    @TypeConverter
    public CabinetLayerSelect stringToLayerSelect(String json) {
        return GsonUtils.fromJson(json, CabinetLayerSelect.class);
    }


}
