package com.palmnest.dao.washcar.impl;

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

import java.util.List;


/**
 * 用户评价dao实现类
 *
 * @author longmeizhen
 */
@Slf4j
@Repository("userEvaluateDao")
public class UserEvaluateDaoImpl extends GenericDaoHibernate<UserEvaluate, Long> implements UserEvaluateDao {


	public UserEvaluateDaoImpl() {
		super(UserEvaluate.class);
	}

	@Override
	public UserEvaluate findByOrderId(Long orderId, String type) throws Exception {

		String sql = "from UserEvaluate where orderId=? and type=? ";

		List<UserEvaluate> custList = getSession().createQuery(sql).setLong(0, orderId).setString(1, type).list();

		if (custList != null && custList.size() > 0) {
			return custList.get(0);
		}
		return null;

	}
}
