package com.kiisoo.ic.utils;

import com.alibaba.fastjson.JSON;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;

/**
 * 数据导入相关工具
 */
public class DataImportUtil {
/*1000	操作成功
2100	token无效
2200	缺失参数
2300	请求方式有误
4000	操作失败*/

    /**
     * 成功map
     */
    public static  Map<String, Object> succMap = new HashMap<>();

    /**
     * 失败map
     */
    public static  Map<String, Object> failMap = new HashMap<>();

    static {
        succMap.put("code","1000");
        succMap.put("msg","操作成功");
        failMap.put("code","4000");
        failMap.put("msg","操作失败");
    }

    /**
     * 数据导入失败
     */
    public static String fail(Exception e){
        Map<String, Object> returnMap = new HashMap<>(failMap);
        returnMap.put("err",e);
        return JSON.toJSONString(returnMap);
    }

    /**
     * 数据导入成功
     * succNum 入库成功数目
     */
    public static String succ(int succNum){
        Map<String, Object> returnMap = new HashMap<>(succMap);
        returnMap.put("succ",succNum);
        return JSON.toJSONString(returnMap);
    }
}
