package com.engine.htsc.errorremind.web;

import com.alibaba.fastjson.JSON;
import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.htsc.equipment.service.EquipmentPurchaseService;
import com.engine.htsc.errorremind.service.RequestSubmitErrorRemindService;
import com.engine.htsc.errorremind.service.impl.RequestSubmitErrorRemindServiceImpl;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.HrmUserVarify;
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;
import java.util.HashMap;
import java.util.Map;

public class RequestSubmitErrorRemindAction {


    public RequestSubmitErrorRemindService getService(HttpServletRequest request, HttpServletResponse response){
        User user = HrmUserVarify.getUser( request, response );
        return (RequestSubmitErrorRemindService)ServiceUtil.getService(RequestSubmitErrorRemindServiceImpl.class,user);
    }

    @GET
    @Path("/doSendErrorRemind")
    @Produces({MediaType.TEXT_PLAIN})
    public String doSendErrorRemind(@Context HttpServletRequest request, @Context HttpServletResponse response){
        BaseBean bs = new BaseBean();
        Map<String, Object> apidatas = new HashMap<String, Object>();
        bs.writeLog("----EquipmentPurchaseAction-----");
        try{
            Map<String,Object> param = ParamUtil.request2Map(request);
            User user = HrmUserVarify.getUser( request, response );
            apidatas.putAll(getService(request,response).doSendErrorRemind(param,user));
        }catch (Exception e) {
            e.printStackTrace();
            apidatas.put("api_status", false);
            apidatas.put("api_errormsg", "catch exception : " + e.getMessage());
        }
        return JSON.toJSONString(apidatas);
    }
}
