📄 noteserviceimp.java
字号:
package com.opensource.blog.service.imp;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.laoer.comm.web.PageList;
import com.laoer.comm.web.Pages;
import com.opensource.blog.dao.ArticleDAO;
import com.opensource.blog.dao.NoteDAO;
import com.opensource.blog.exception.BlogException;
import com.opensource.blog.model.Article;
import com.opensource.blog.model.Note;
import com.opensource.blog.service.NoteService;
public class NoteServiceImp
implements NoteService {
private static final Log logger = LogFactory.getLog(NoteServiceImp.class);
private NoteDAO noteDAO;
private ArticleDAO articleDAO;
public NoteServiceImp() {
}
/**
*
* @param note Note
* @return Note
* @throws BlogException
* @todo Implement this com.opensource.blog.service.NoteService method
*/
public Note saveNote(Note note) throws BlogException {
try {
return this.getNoteDAO().saveNote(note);
}
catch (Exception ex) {
logger.error(ex);
throw new BlogException(ex);
}
}
/**
*
* @param id long
* @param blogID long
* @return Note
* @todo Implement this com.opensource.blog.service.NoteService method
*/
public Note findNoteByID_BlogID(long id, long blogID) {
return this.getNoteDAO().findNoteByID_BlogID(id, blogID);
}
/**
*
* @param artID long
* @return int
* @todo Implement this com.opensource.blog.service.NoteService method
*/
public int getNoteCountByArtID(long artID) {
return this.getNoteDAO().getNoteCountByArtID(artID);
}
/**
*
* @param artID long
* @return List
* @todo Implement this com.opensource.blog.service.NoteService method
*/
public List findNotesByArtID(long artID) {
return this.getNoteDAO().findNotesByArtID(artID);
}
/**
*
* @param blogID long
* @return int
* @todo Implement this com.opensource.blog.service.NoteService method
*/
public int getNoteCountByBlogID(long blogID) {
return this.getNoteDAO().getNoteCountByBlogID(blogID);
}
/**
*
* @param blogID long
* @param pages Pages
* @return PageList
* @todo Implement this com.opensource.blog.service.NoteService method
*/
public PageList findNotesByBlogID(long blogID, Pages pages) {
PageList pl = new PageList();
if (pages.getTotals() == -1) {
pages.setTotals(this.getNoteDAO().getNoteCountByBlogID(blogID));
}
pages.doPageBreak();
List l = this.getNoteDAO().getNotesByBlogID(blogID, pages.getSpage(), pages.getPerPageNum());
pl.setObjectList(l);
pl.setPageShowString(pages.getListPageBreak());
pl.setPages(pages);
return pl;
}
/**
*
* @param note Note
* @throws BlogException
* @todo Implement this com.opensource.blog.service.NoteService method
*/
public void removeNote(Note note) throws BlogException {
try {
long artID = note.getArtid();
Article art = this.getArticleDAO().findArticleByID_BlogID(note.getArtid(),note.getBlogid());
this.getNoteDAO().removeNote(note);
int num = this.getNoteCountByArtID(artID);
if (art != null) {
art.setCommentnum(num);
this.getArticleDAO().saveArticle(art);
}
}
catch (Exception ex) {
logger.error(ex);
throw new BlogException(ex);
}
}
public NoteDAO getNoteDAO() {
return noteDAO;
}
public ArticleDAO getArticleDAO() {
return articleDAO;
}
public void setNoteDAO(NoteDAO noteDAO) {
this.noteDAO = noteDAO;
}
public void setArticleDAO(ArticleDAO articleDAO) {
this.articleDAO = articleDAO;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -