package com.engine.htsc.trip.web;

import com.alibaba.fastjson.JSONObject;
import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.htsc.trip.service.GetCustService;
import com.engine.htsc.trip.service.impl.GetCustServiceImpl;
import java.util.HashMap;
import java.util.Map;
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;


public class GetCustAction {
  
  GetCustService getService() {
    return ServiceUtil.getService(GetCustServiceImpl.class);
  }
  
  @GET
  @Path("/doGetCust")
  @Produces(MediaType.TEXT_PLAIN)
  public String getCust(@Context HttpServletRequest request,
      @Context HttpServletResponse response) {
    Map<String, Object> apidatas = new HashMap<String, Object>();
    try {
      //实例化Service 并调用业务类处理
      apidatas = getService().getCust(ParamUtil.request2Map(request));
    } catch (Exception e) {
      //异常处理
      e.printStackTrace();
      apidatas.put("api_status", false);
      apidatas.put("api_errormsg", "catch exception : " + e.getMessage());
    }
    //数据转换
    return JSONObject.toJSONString(apidatas);
  }
}
