package com.palmnest.dao.washcar.impl;

import com.palmnest.dao.hibernate.GenericDaoHibernate;
import com.palmnest.dao.washcar.OrderExtraServiceDao;
import com.palmnest.model.washcar.OrderExtraService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

import java.util.List;

@Slf4j
@Repository("orderExtraServiceDao")
public class OrderExtraServiceDaoImpl extends GenericDaoHibernate<OrderExtraService, Long> implements OrderExtraServiceDao {


	public OrderExtraServiceDaoImpl() {
		super(OrderExtraService.class);
	}

	@Override
	public List<OrderExtraService> getOrderExtraListByOrderId(Long orderId)
			throws Exception {
		String                  sql       = "from OrderExtraService where orderId=? ";
		List<OrderExtraService> orderList = getSession().createQuery(sql).setLong(0, orderId).list();
		return orderList;
	}

	@Override
	public Integer deleteOrderExtByOrderId(Long orderId) throws Exception {
		String sql = "delete from OrderExtraService where orderId=? ";
		return this.getSession().createQuery(sql).setLong(0, orderId).executeUpdate();
	}

}
