package com.engine.attendance.workflow.web;

import com.engine.attendance.workflow.service.MakeUpClockInService;
import com.engine.attendance.workflow.service.impl.MakeUpClockInServiceImpl;
import com.engine.common.util.ApiReturnTools;
import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import lombok.extern.slf4j.Slf4j;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import java.util.Map;

/**
 * 补打卡流程
 */
@Slf4j
public class MakeUpClockInAction {

    private MakeUpClockInService makeUpClockInService = ServiceUtil.getService(MakeUpClockInServiceImpl.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 = makeUpClockInService.processSubmitCheck(paramMap);
            return ApiReturnTools.success(dataMap);
        }catch (Exception e){
            log.error("execute fail,catch error: [{}]",e);
            return ApiReturnTools.error("500","processSubmitCheck error");
        }
    }
}
