package com.engine.htsc.trip.web;

import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.htsc.trip.pojo.AllowanceRequest;
import com.engine.htsc.trip.service.AllowanceService;
import com.engine.htsc.trip.service.impl.AllowanceServiceImpl;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.Consumes;
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 org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;

public class AllowanceAction {
  private Log log = LogFactory.getLog(this.getClass());
  private AllowanceService getService(){
    return ServiceUtil.getService(AllowanceServiceImpl.class);
  }
  @POST
  @Path("/allowance")
  @Consumes({MediaType.APPLICATION_JSON})
  @Produces({MediaType.APPLICATION_JSON})
  public Map<String,Object> getAllowance( AllowanceRequest request){
    Map<String, Object> apidatas = new HashMap<>();
    try {
      apidatas = this.getService().allowance(request);
      apidatas.put("code", 200);
      apidatas.put("message","接口调用成功");
    }catch (Exception e){
      e.printStackTrace();
      apidatas.put("code",-1);
      apidatas.put("message","接口调用失败");
      apidatas.put("api_errormsg", "catch exception : " + e.getMessage());
      log.error("isPostion catch exception");
    }
    return apidatas;
  }
  
  @POST
  @Path("/v2/allowance")
  @Produces({MediaType.APPLICATION_JSON})
  public Map<String,Object> getAllowanceV2( AllowanceRequest request){
    Map<String, Object> apidatas = new HashMap<>();
    try {
      apidatas = this.getService().execute(request);
      apidatas.put("code", 200);
      apidatas.put("message","接口调用成功");
    }catch (Exception e){
      apidatas.put("code",-1);
      apidatas.put("message","接口调用失败");
      apidatas.put("api_errormsg", "catch exception : " + e.getMessage());
      log.error("v2 allowance catch exception",e);
    }
    return apidatas;
  }
}
