package com.xypower.mpmaster.sms;


import com.xypower.common.MicroPhotoContext;

import org.json.JSONArray;

import java.util.HashMap;

public class ValueTypeUtil {

    /*
    *
    * 类型
        0：number
        1：string
        2：float
    *
    * */
    public static int checkType(Object item) {
        if (item instanceof String) {
            return 1;
        } else if (item instanceof Integer) {
            return 0;
        } else if (item instanceof Double) {
            return 2;
        } else if (item instanceof JSONArray) {
            return 3;
        } else {
            return -1;
        }

    }

    /*
     * 根据短信类型来判断是修改哪个配置文件
     *
     * */
    public static HashMap checkFilePathAndName( int fileType) {
        HashMap<String, String> hashMap = new HashMap<>();
        String filePath = null;
        String fileName = null;
        switch (fileType) {
            case 1:
                filePath =MicroPhotoContext.PACKAGE_NAME_MPAPP + "/data/";
                fileName = "App.json";
                break;
            case 2:
                filePath =MicroPhotoContext.PACKAGE_NAME_MPMASTER + "/data/";
                fileName = "Master.json";
                break;
            case 91:
            case 92:
            case 93:
            case 94:
            case 95:
            case 96:
            case 97:
            case 98:
            case 99:
                filePath =MicroPhotoContext.PACKAGE_NAME_MPAPP + "/data/channels/";
                fileName = Integer.toString(fileType - 90) + ".json";
                break;
            default:
                break;

        }

        hashMap.put(UpdateSysConfigUtil.FILEPATH, filePath);
        hashMap.put(UpdateSysConfigUtil.FILENAME, fileName);
        return hashMap;
    }


}
