package com.engine.attendance.workflow.web;

import com.engine.attendance.workflow.service.BusinessTripsApplyService;
import com.engine.attendance.workflow.service.impl.BusinessTripsApplyServiceImpl;
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.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.Map;

/**
 * @Author: sy
 * @Description: 出差申请
 * @Date: 2024/3/15
 **/
@Slf4j
public class BusinessTripsApplyApi {
    private BusinessTripsApplyService getBusinessTripsApplyService(User user) {
        return ServiceUtil.getService(BusinessTripsApplyServiceImpl.class,user);
    }
    /**
     * 出差申请列表
     * @param request
     * @param response
     * @return
     */
    @GET
    @Path("/getBusinessTripsApplyList")
    @Produces(MediaType.APPLICATION_JSON)
    public String getBusinessTripsApplyList(@Context HttpServletRequest request, @Context HttpServletResponse response) {
        try {
            User user = HrmUserVarify.getUser(request, response);
            Map<String,Object> param = ParamUtil.request2Map(request);
            return ApiReturnTools.success(getBusinessTripsApplyService(user).getBusinessTripsApplyList(param));
        }catch (Exception e){
            log.error("execute fail,catch error: [{}]",e);
            return ApiReturnTools.error("500","getBusinessTripsApplyList error");
        }
    }



}
