package net.tooan.ynpay.core.ejb.service.order.bus;
import net.tooan.ynpay.commons.YnpayJndiConstants;
import net.tooan.ynpay.core.ejb.helper.CoreServiceBean;
import net.tooan.ynpay.core.ejb.helper.SqlMapClientInterceptorBean;
import net.tooan.ynpay.order.agent.bus.bean.BusStation;
import javax.ejb.Stateless;
import javax.interceptor.Interceptors;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static net.tooan.ynpay.commons.BusinessException.parseException;
/**
* Created with IntelliJ IDEA.
* User: Jing
* Date: 13-10-14
* Time: 下午2:36
*/
@Stateless(name = YnpayJndiConstants.Order_Bus_Station_Service)
@Interceptors(SqlMapClientInterceptorBean.class)
public class BusStationServiceBean extends CoreServiceBean<BusStation, Long> implements BusStationServer {
@Override
public List<BusStation> getList() {
try {
return sqlMapClient.queryForList("BusStation.getList");
} catch (SQLException e) {
throw parseException(e);
}
}
@Override
public List<BusStation> getList(String origin) {
try {
Map<String, String> params = new HashMap<String, String>();
params.put("origin", origin);
return sqlMapClient.queryForList("BusStation.getList", params);
} catch (SQLException e) {
throw parseException(e);
}
}
@Override
public void save(BusStation origin) {
try {
sqlMapClient.insert("BusStation.getList", origin);
} catch (SQLException e) {
throw parseException(e);
}
}
}