?? guestbookserviceimpl.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 + -