package com.sv.api.context;

import com.ydd.oms.dto.PlatformDTO;

import java.util.List;

public class PlatformContext {

    protected static final ThreadLocal<PlatformDTO> LOCAL_PLATFORM = new ThreadLocal<PlatformDTO>();

    public static String getKey(){
        if(LOCAL_PLATFORM.get() != null){
           return LOCAL_PLATFORM.get().getKey();
        }
        return null;
    }

    public static void changeKey(String key){
        if(LOCAL_PLATFORM.get() != null){
            LOCAL_PLATFORM.get().setKey(key);
        }
    }

    public static void remove(){
        LOCAL_PLATFORM.remove();
    }


    public static Integer getValue(){
        if(LOCAL_PLATFORM.get() != null){
            return LOCAL_PLATFORM.get().getValue();
        }
        return null;
    }

    public static void set(String key,Integer value){
        PlatformDTO platformDTO = new PlatformDTO();
        platformDTO.setKey(key);
        platformDTO.setValue(value);
        LOCAL_PLATFORM.set(platformDTO);
    }
}
