package com.engine.htsc.HKContract.web;

import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.htsc.HKContract.service.HKContractService;
import com.engine.htsc.HKContract.service.impl.HKContractServiceImpl;
import weaver.interfaces.htsc.GlobatTools.JAVATools;

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 javax.ws.rs.core.MediaType;

/**
 * 香港合同
 */
public class HKContractAction {


    private HKContractService HKContractService()
    {
        return ServiceUtil.getService(HKContractServiceImpl.class);
    }

    /**
     * 校验ceo是否审批rest
     * @param request
     * @param response
     * @return
     */

    @POST
    @Path("/verifyCEOApproval")
    @Produces({MediaType.APPLICATION_JSON})
    public String verifyCEOApproval(@Context HttpServletRequest request, @Context HttpServletResponse response){
        boolean flag=false;
        JAVATools.SetCmdwritelog("----HKContractAction-----verifyCEOApproval-----");
        try{
            flag = HKContractService().verifyCEOApproval(ParamUtil.request2Map(request));
        }catch (Exception e) {
            //   e.printStackTrace();
            return JAVATools.Apiretrun("400","请检查参数");
        }
        return JAVATools.Apiretrun("200",flag);
    }

    @POST
    @Path("/getApprovedLeaderIdStr")
    @Produces({MediaType.APPLICATION_JSON})
    public String getApprovedLeaderIdStr(@Context HttpServletRequest request, @Context HttpServletResponse response){

        String operator = null;
        JAVATools.SetCmdwritelog("----HKContractAction-----getApprovedLeaderIdStr-----");
        try{
            operator = HKContractService().getApprovedLeaderIdStr(ParamUtil.request2Map(request));
        }catch (Exception e) {
            // e.printStackTrace();
            return JAVATools.Apiretrun("400","请检查参数");
        }
        return JAVATools.Apiretrun("200",operator);

    }
}
