package com.engine.htsc.cube.web;

import com.alibaba.fastjson.JSONObject;
import com.engine.common.util.ServiceUtil;
import com.engine.htsc.cube.service.FeedBackService;
import com.engine.htsc.cube.service.impl.FeedBackServiceImpl;
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/19.
 */

public class FeedBackAction {
    private FeedBackService getService(HttpServletRequest req, HttpServletResponse resp){
        User user = CommonUtil.getUserByRequest(req, resp);
        return (FeedBackService) ServiceUtil.getService(FeedBackServiceImpl.class,user);
    }

    /**
     * 任务反馈汇总
     * @param req
     * @param response
     * @return
     */
    @GET
    @Path("/feedbackList")
    @Produces({MediaType.TEXT_PLAIN})
    public String feedBackData(@Context HttpServletRequest req, @Context HttpServletResponse response){

        Integer pagesize = Util.getIntValue(req.getParameter("pagesize"));
        Integer current = Util.getIntValue(req.getParameter("current"));
        Integer billid = Util.getIntValue(req.getParameter("billid"));
        Integer modeid = Util.getIntValue(req.getParameter("modeid"));

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

    @GET
    @Path("/tasikDetailList")
    @Produces({MediaType.TEXT_PLAIN})
    public String taiskDetail(@Context HttpServletRequest req, @Context HttpServletResponse response){

        Integer billid = Util.getIntValue(req.getParameter("billid"));

        JSONObject dataList = this.getService(req, response).getTasikDetailList(billid);
        return dataList.toString();
    }

}
