NoteServiceImp.java
资源名称:Myblog.rar [点击查看]
上传用户:wlfwy2004
上传日期:2016-12-12
资源大小:33978k
文件大小:4k
源码类别:
Jsp/Servlet
开发平台:
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;
- }
- }