package com.palmnest.dao.notice.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.palmnest.model.notice.WxUploadMaterialModel;
import com.palmnest.dao.hibernate.GenericDaoHibernate;
import com.palmnest.dao.notice.WxUploadMaterialDao;

@Repository("wxUploadMaterialDao")
public class WxUploadMaterialDaoImpl extends GenericDaoHibernate<WxUploadMaterialModel, Integer> implements WxUploadMaterialDao {

	public WxUploadMaterialDaoImpl() {
		super(WxUploadMaterialModel.class);

	}

	@Override
	public WxUploadMaterialModel findBySourceId(Integer sourceId, String type, Integer orgId) {
		String sql = "from WxUploadMaterialModel where sourceId=? and m_type=？ and orgId=?  limit 1";
		List<WxUploadMaterialModel> list = getSession().createQuery(sql).setInteger(0, sourceId).setString(1, type).setInteger(2, orgId).list();
		if (list != null && list.size() > 0) {
			return list.get(0);
		}
		return null;
	}
}
