package com.palmnest.dao.airconditioner.impl;

import com.palmnest.dao.airconditioner.AirConditionerAddTimeOrderHistoryDao;
import com.palmnest.dao.hibernate.GenericDaoHibernate;
import com.palmnest.model.airconditioner.AirConditionerAddTimeOrderHistory;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author xc
 * @since 2023/8/9 20:08
 */
@Repository("airConditionerAddTimeOrderHistoryDao")
public class AirConditionerAddTimeOrderHistoryDaoImpl extends GenericDaoHibernate<AirConditionerAddTimeOrderHistory, Long> implements AirConditionerAddTimeOrderHistoryDao {

    private static final Logger logger = Logger.getLogger(AirConditionerAddTimeOrderHistoryDaoImpl.class);
    public AirConditionerAddTimeOrderHistoryDaoImpl() {
        super(AirConditionerAddTimeOrderHistory.class);
    }

    @Override
    public List<AirConditionerAddTimeOrderHistory> getByOrderNo(String orderNo) {
        String sql = "select * from tb_airconditioner_addtime_order_history where order_no = ? order by id desc";
        logger.info("根据空调加时订单获取历史记录 sql: " + sql);
        return getSession().createSQLQuery(sql).addEntity(AirConditionerAddTimeOrderHistory.class).setString(0, orderNo).list();
    }
}
