package com.engine.htsc.workflow.web;

import com.alibaba.fastjson.JSONObject;
import com.engine.common.util.ServiceUtil;
import com.engine.htsc.workflow.service.WorkFlowFeedBackService;
import com.engine.htsc.workflow.service.impl.WorkFlowFeedBackServiceImpl;
import com.engine.workflow.util.CommonUtil;
import weaver.general.Util;
import weaver.hrm.User;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;

/**
 * Created by K1810001 on 2020/10/21.
 */
public class WorkFlowFeedBackAction {

    private WorkFlowFeedBackService getService(HttpServletRequest req, HttpServletResponse resp){
        User user = CommonUtil.getUserByRequest(req, resp);
        return (WorkFlowFeedBackService) ServiceUtil.getService(WorkFlowFeedBackServiceImpl.class,user);
    }

    /**
     * 流程反馈汇总组件
     * @param req
     * @param response
     * @return
     */
    @GET
    @Path("/dataList")
    @Produces({MediaType.TEXT_PLAIN})
    public String workFlowFeedBackData(@Context HttpServletRequest req, @Context HttpServletResponse response){

        Integer pagesize = Util.getIntValue(req.getParameter("pagesize"));
        Integer current = Util.getIntValue(req.getParameter("current"));
        Integer rwid = Util.getIntValue(req.getParameter("rw"));

        JSONObject dataList = this.getService(req, response).getDataList(pagesize,current,rwid);
        return dataList.toString();
    }
}
