⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 guestbookserviceimpl.java

📁 学习tapestry的好书啊,绝对经典实用.
💻 JAVA
字号:
package com.cucu.tapestry.service.impl;

import java.util.List;

import net.sf.hibernate.Hibernate;
import net.sf.hibernate.type.Type;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.dao.DataAccessException;

import com.cucu.tapestry.dao.GuestbookDAO;
import com.cucu.tapestry.dao.PageHandle;
import com.cucu.tapestry.entity.Guestbook;
import com.cucu.tapestry.service.GuestbookService;

/**
 * @author 绝情酷哥
 * @version 1.0
 */
public class GuestbookServiceImpl implements GuestbookService {
    private static final Log log =
            LogFactory.getLog(GuestbookServiceImpl.class);
    private GuestbookDAO guestbookDAO;
    private PageHandle pageHandle;

    /**
     * 将guestbookDAO注入到service中来
     *
     * @param guestbookDAO
     */
    public void setGuestbookDAO(GuestbookDAO guestbookDAO) {
        this.guestbookDAO = guestbookDAO;
    }

    /**
     * 将分页程序注入到service中来
     *
     * @param handle
     */
    public void setPageHandle(PageHandle handle) {
        pageHandle = handle;
    }


    /**
     * @param pos  记录起始位置
     * @param size 每页记录数
     * @return 返回留言列表
     * @throws DataAccessException
     */
    public List getList(int pos, int size) throws DataAccessException {
        String hql =
                "select pojo from Guestbook pojo where pojo.parentId=-1 order by pojo.isTop desc,pojo.bookDate desc";
        return this.pageHandle.getPageItems(hql, pos, size);
    }

    /**
     * @return
     */
    /**
     * @param parentId 如果等于-1,即为留言,不为-1即为回复
     * @param pos      记录起始位置
     * @param size     每页记录数
     * @return 返回回复或者留言列表
     * @throws DataAccessException
     */
    public List getReplyList(Integer parentId, int pos, int size)
            throws DataAccessException {
        String hql =
                "select pojo from Guestbook pojo where pojo.parentId=? order by pojo.bookId ";
        return this.pageHandle.getPageItems(
                hql,
                new Object[]{parentId},
                new Type[]{Hibernate.INTEGER},
                pos,
                size);
    }

    /**
     * 根据ID返回Guestbook
     *
     * @param id
     * @return Guestbook对象
     * @throws DataAccessException
     */
    public Guestbook getGuestbook(Integer id) throws DataAccessException {
        return this.guestbookDAO.getGuestbook(id);
    }

    /**
     * 回复总数
     *
     * @param parentId 留言ID
     * @return 回复总数
     * @throws DataAccessException
     */
    public Integer getReplyCount(Integer parentId) throws DataAccessException {
        return this.guestbookDAO.getReplyCount(parentId);
    }

    /**
     * /**
     * 根据ID记算回复主数
     *
     * @param parentId
     * @return 回复总数
     */
    public Integer getCommentCount(Integer parentId)
            throws DataAccessException {
        return this.guestbookDAO.getCommentCount(parentId);
    }

    /**
     * @return 计算总共花费时间
     */
    public Integer getSumTime() throws DataAccessException {
        return this.guestbookDAO.getSumTime();
    }

    /**
     * 根据ID删除一个对象
     *
     * @param id
     * @throws DataAccessException
     */
    public void doDeleteTopic(Integer id) throws DataAccessException {
        this.guestbookDAO.doDeleteTopic(id);
    }

    /**
     * @return 留言总数
     */
    public Integer getCount() throws DataAccessException {
        return this.guestbookDAO.getCount();
    }

    /**
     * 设置置顶操作
     *
     * @param id 留言ID
     * @throws DataAccessException
     */
    public void doSetTop(Integer id) throws DataAccessException {
        this.guestbookDAO.doSetTop(id);
    }

    /**
     * 新建或者修改一个guestbook
     *
     * @param gb Guestbook
     * @throws DataAccessException
     */
    public void doUpdateTopic(Guestbook gb) throws DataAccessException {
        this.guestbookDAO.doUpdateTopic(gb);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -