package cn.jack.service;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import cn.jack.hibernate.Bookcontent;

public class BookcontentDaoImp extends HibernateDaoSupport implements BookcontentDao {

	/*
	 * (non-Javadoc)
	 * @see cn.jack.service.BookcontentDao#newmessage(cn.jack.hibernate.Bookcontent)
	 * 保存发表的留言数据到数据库
	 */
	public void newmessage(Bookcontent bt) {
	 this.getHibernateTemplate().save(bt);	
	}
	/*
	 * (non-Javadoc)
	 * @see cn.jack.service.BookcontentDao#allmessage()
	 * 显示所有的留言数据
	 */

	public List allmessage() {
	 List allmessage = this.getHibernateTemplate().find("from Bookcontent order by gbtime desc");
		return allmessage;
	}
	/*
	 * (non-Javadoc)
	 * @see cn.jack.service.BookcontentDao#delete(java.lang.String)
	 * 删除一条留言
	 */

	public void delete(String id) {
	 Bookcontent bt=(Bookcontent)this.getHibernateTemplate().get(Bookcontent.class, id);
	 this.getHibernateTemplate().delete(bt);
		
	}

	/*
	 * (non-Javadoc)
	 * @see cn.jack.service.BookcontentDao#replay(java.lang.String, java.lang.String, java.lang.String)
	 * 回复留言
	 */

	public void replay(String id, String re, String retime) {
		Bookcontent bat = new Bookcontent();
		Bookcontent bt=(Bookcontent)this.getHibernateTemplate().get(Bookcontent.class, id);
		bat.setGbcontent(bt.getGbcontent());
		bat.setGbface(bt.getGbface());
		bat.setGbip(bt.getGbip());
		bat.setGbmail(bt.getGbmail());
		bat.setGbtime(bt.getGbtime());
		bat.setGbtitle(bt.getGbtitle());
		bat.setGbuser(bt.getGbuser());
		bat.setGbre(re);
		bat.setGbretime(retime);
		bat.setId(bt.getId());
		this.getHibernateTemplate().update(bat);
		
	}

}
