package com.engine.htsc.portal.web;

import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.htsc.portal.service.PortalTransactionService;
import com.engine.htsc.portal.service.impl.PortalTransactionServiceImpl;
import com.engine.htsc.response.utils.ResultVoUtil;
import com.engine.htsc.response.vo.ResultVo;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;

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


/**
 * 协同中心接口
 */
public class PortalTransactionAction {


    private PortalTransactionService getService(User user){
        return ServiceUtil.getService(PortalTransactionServiceImpl.class,user);
    }


    @GET
    @Path("/center")
    @Produces({MediaType.APPLICATION_JSON})
    public ResultVo coordinationCenter(@Context HttpServletRequest request, @Context HttpServletResponse response){
        Map<String, Object> apidatas = new HashMap<>();
        try {
            User user = HrmUserVarify.getUser(request, response);
            apidatas = getService(user).getStatisticalCount(ParamUtil.request2Map(request));
        }catch (Exception e){
            e.printStackTrace();
        }
        return ResultVoUtil.success("操作成功",apidatas);
    }


    @GET
    @Path("/getparticipatelist")
    @Produces({MediaType.APPLICATION_JSON})
    public ResultVo getParticipateList(@Context HttpServletRequest request, @Context HttpServletResponse response){
        Map<String, Object> apidatas = new HashMap<>();
        try {
            User user = HrmUserVarify.getUser(request, response);
            apidatas = getService(user).getParticipateList(ParamUtil.request2Map(request));
        }catch (Exception e){
            e.printStackTrace();
        }
        return ResultVoUtil.success("操作成功",apidatas);
    }

}
