package com.engine.attendance.workflow.web;

import com.engine.attendance.workflow.service.ProcessSubmitCheckService;
import com.engine.attendance.workflow.service.impl.ProcessSubmitCheckServiceImpl;
import com.engine.common.util.ApiReturnTools;
import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import lombok.extern.slf4j.Slf4j;
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.POST;
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.Map;

@Slf4j
public class ProcessSubmitCheckApi {

    private ProcessSubmitCheckService basicsetService = ServiceUtil.getService(ProcessSubmitCheckServiceImpl.class);
    /**
     * 提交流程检查
     * @return
     */
    @POST
    @Path("/processSubmitCheck")
    @Produces({"text/plain"})
    public String processSubmitCheck(@Context HttpServletRequest request, @Context HttpServletResponse response) {
        try {
            Map<String,Object> paramMap = ParamUtil.request2Map(request);
            Map<String,Object> dataMap = basicsetService.processSubmitCheck(paramMap);
            return ApiReturnTools.success(dataMap);
        }catch (Exception e){
            log.error("execute fail,catch error: [{}]",e);
            return ApiReturnTools.error("500","processSubmitCheck error");
        }
    }

    /**
     * 获得请假
     * @param request
     * @param response
     * @return
     */
    @GET
    @Path("/getEliminationsEvctionList")
    @Produces(MediaType.APPLICATION_JSON)
    public String getBusinessTripsApplyList(@Context HttpServletRequest request, @Context HttpServletResponse response) {
        try {
            Map<String,Object> paramMap = ParamUtil.request2Map(request);
            Map<String,Object> dataMap = basicsetService.getEliminationsEvctionList(paramMap);
            return ApiReturnTools.success(dataMap);
        }catch (Exception e){
            log.error("execute fail,catch error: [{}]",e);
            return ApiReturnTools.error("500","getBusinessTripsApplyList error");
        }
    }



}
