package com.engine.htsc.ityssq.web;


import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.htsc.ityssq.service.ItAcceptanceApplyService;
import com.engine.htsc.ityssq.service.impl.ItAcceptanceApplyServiceImpl;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;

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 ItAcceptanceApplyAction {

    private ItAcceptanceApplyService getService(User user){
        return ServiceUtil.getService(ItAcceptanceApplyServiceImpl.class,user);
    }

    /**
     * It验收流程明细表4汇总
     * @param request
     * @param response
     * @return
     */
    @POST
    @Path("/summary")
    @Produces({MediaType.APPLICATION_JSON})
    public Map<String,Object> detailSummary(@Context HttpServletRequest request,
                                            @Context HttpServletResponse response){
        Map<String, Object> apidatas = new HashMap<>();
        try {
            User user = HrmUserVarify.getUser(request, response);
            apidatas = this.getService(user).detailSummary(ParamUtil.request2Map(request));
            apidatas.put("api_status", 1);
        }catch (Exception e){
            e.printStackTrace();
            apidatas.put("api_status",-1);
            apidatas.put("api_errormsg", "catch exception : " + e.getMessage());
        }
        return apidatas;
    }
}
