package com.engine.kq.web;

import com.alibaba.fastjson.JSONObject;
import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.kq.service.KQRemindOnPCService;
import com.engine.kq.service.impl.KQRemindOnPCServiceImpl;
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;

/**
 * 考勤提醒
 * 登录PC端后的弹窗提醒
 */
public class KQRemindOnPCAction {

    private KQRemindOnPCService getService(User user) {
        return (KQRemindOnPCServiceImpl) ServiceUtil.getService(KQRemindOnPCServiceImpl.class, user);
    }

    /**
     * 获取右键菜单
     *
     * @param request
     * @param response
     * @return
     */
    @GET
    @Path("/getRemindInfo")
    @Produces(MediaType.TEXT_PLAIN)
    public String getRemindInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) {
        Map<String, Object> apiDatas = new HashMap<String, Object>();
        try {
            User user = HrmUserVarify.getUser(request, response);
            apiDatas = getService(user).getRemindInfo(ParamUtil.request2Map(request), user);
            apiDatas.put("api_status", true);
        } catch (Exception e) {
            e.printStackTrace();
            apiDatas.put("api_status", false);
            apiDatas.put("api_errormsg", e.getMessage());
        }
        return JSONObject.toJSONString(apiDatas);
    }
}
