package com.engine.htsc.payment.web;

import com.engine.common.util.ServiceUtil;
import com.engine.htsc.payment.pojo.PreApproval;
import com.engine.htsc.payment.service.PreApprovalService;
import com.engine.htsc.payment.service.impl.PreApprovalServiceImpl;
import com.engine.htsc.trip.util.AjaxResult;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import java.util.List;

public class PreApprovalAction {
    private final Log log = LogFactory.getLog(this.getClass());

    private PreApprovalService getServices() {
        return ServiceUtil.getService(PreApprovalServiceImpl.class);
    }

    @GET
    @Path("/assertFp")
    @Produces(MediaType.APPLICATION_JSON)
    public AjaxResult<List<PreApproval>> checkRequestMark(@QueryParam("requestid") String requestid) {
        try {
            List<PreApproval> preAplInfos = getServices().getPreAplInfos(requestid);
            return AjaxResult.ok(preAplInfos);
        } catch (Exception e) {
            log.error(e.getMessage());
            e.printStackTrace();
            return AjaxResult.error(":" + e.getMessage());
        }
    }



}
