package com.system.utils;

import org.springframework.util.CollectionUtils;

import java.util.*;

/**
 * @author Inori
 */
public class PushResultUtil {

    public static Object purchaseTo(String code, String message, List<Map<String, Object>> list) {
        Map<String, Object> result = new LinkedHashMap<>();
        result.put("resultCode", code);
        result.put("resultMsg", message);
        if (!CollectionUtils.isEmpty(list)) {
            List<Map<String, Object>> tempList = new ArrayList<>();
            for (Map<String, Object> temp : list) {
                Map<String, Object> map = new HashMap<>();
                map.put("po_code", temp.get("code"));
                map.put("Msg", temp.get("msg"));
                tempList.add(map);
            }
            result.put("resultData", tempList);
        } else {
            result.put("resultData", list);
        }
        return result;
    }


}
