package com.engine.htsc.zbzysx.web;

import com.alibaba.fastjson.JSON;
import com.engine.common.util.ServiceUtil;
import com.engine.htsc.zbzysx.service.SubImpSearchService;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.HashMap;
import java.util.Map;

public class SubImpSearchAction {

    SubImpSearchService getService(){
        return ServiceUtil.getService(SubImpSearchService.class);
    }

    @POST
    @Path("/getWorkflowInfo")
    @Produces({MediaType.TEXT_PLAIN})
    public String getWorkflowInfo(@Context HttpServletRequest request, @Context HttpServletResponse response){
        Map<String, Object> apidatas = new HashMap<String, Object>();
        try{
            String beginDate = request.getParameter("beginDate");
            String endDate = request.getParameter("endDate");
            String searchType = request.getParameter("searchType");

            SubImpSearchService service = getService();
            apidatas = service.getWorkflowInfo(beginDate,endDate,searchType);
        }catch (Exception e) {
            e.printStackTrace();
            apidatas.put("api_status", false);
            apidatas.put("api_errormsg", "catch exception : " + e.getMessage());
        }

        return JSON.toJSONString(apidatas);
    }
}
