package com.ag.web.demo;

import com.ag.secp.platform.common.ParamUtil;
import com.alibaba.fastjson.JSON;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;



/**
 * Created by shaoqiang on 2017/7/13.
 */
public class WebbuilderPoDemo {


    /**
     * ???????
     * @param request
     * @param response
     */
    public static void getpojodemo(HttpServletRequest request, HttpServletResponse response){
        BeanpojoDemo step = new ParamUtil<BeanpojoDemo>().packPOJO(getRequestMap(request), BeanpojoDemo.class);

        System.out.println(step);

    }


    /**
     * ??????
     * @param request
     * @param response
     */
    public static void getGridstore(HttpServletRequest request, HttpServletResponse response){
        String destroy = request.getParameter("destroy");
        String update = request.getParameter("update");
        String create = request.getParameter("create");
        List<BeanpojoDemo> createLst = JSON.parseArray(create,BeanpojoDemo.class);
        List<BeanpojoDemo> updateLst = JSON.parseArray(update,BeanpojoDemo.class);
        List<BeanpojoDemo> destroyLst = JSON.parseArray(destroy,BeanpojoDemo.class);

    }


    public static Map<String,String> getRequestMap(HttpServletRequest request){
        Map<String,String> map = new HashMap<>();
        Enumeration em = request.getParameterNames();
        while (em.hasMoreElements()) {
            String name = (String) em.nextElement();
            String value = request.getParameter(name);
            map.put(name, value);
        }
        return map;
    }
}
