SortServiceImp.java
资源名称:Myblog.rar [点击查看]
上传用户:wlfwy2004
上传日期:2016-12-12
资源大小:33978k
文件大小:3k
源码类别:
Jsp/Servlet
开发平台:
Java
- package com.opensource.blog.service.imp;
- import java.util.*;
- import org.apache.commons.logging.*;
- import com.opensource.blog.dao.*;
- import com.opensource.blog.exception.*;
- import com.opensource.blog.model.*;
- import com.opensource.blog.service.*;
- public class SortServiceImp
- implements SortService {
- private static final Log logger = LogFactory.getLog(SortServiceImp.class);
- private SortDAO sortDAO;
- private ArticleDAO articleDAO;
- public SortServiceImp() {
- }
- /**
- *
- * @param sort Sort
- * @return Sort
- * @throws BlogException
- * @todo Implement this com.opensource.blog.service.SortService method
- */
- public Sort saveSort(Sort sort) throws BlogException {
- try {
- return this.getSortDAO().saveSort(sort);
- }
- catch (Exception ex) {
- logger.error(ex);
- throw new BlogException(ex);
- }
- }
- /**
- *
- * @param id long
- * @param blogID long
- * @return Sort
- * @todo Implement this com.opensource.blog.service.SortService method
- */
- public Sort findSortByID_BlogID(long id, long blogID) {
- return this.getSortDAO().findSortByID_BlogID(id, blogID);
- }
- /**
- *
- * @param blogID long
- * @return int
- * @todo Implement this com.opensource.blog.service.SortService method
- */
- public int getSortCountByBlogID(long blogID) {
- return this.getSortDAO().getSortCountByBlogID(blogID);
- }
- /**
- *
- * @param blogID long
- * @return List
- * @todo Implement this com.opensource.blog.service.SortService method
- */
- public List findSortsByBlogID(long blogID) {
- return this.getSortDAO().findSortsByBlogID(blogID);
- }
- /**
- *
- * @param sort Sort
- * @throws BlogException
- * @todo Implement this com.opensource.blog.service.SortService method
- */
- public void removeSort(Sort sort) throws BlogException {
- try {
- List l = this.getArticleDAO().findArticlesAllBySort(sort.getBlogid(), sort.getId().longValue());
- for (int i = 0; i < l.size(); i++) {
- Article art = (Article) l.get(i);
- art.setSortid(0);
- art.setSortname("");
- this.getArticleDAO().saveArticle(art);
- }
- this.getSortDAO().removeSort(sort);
- }
- catch (Exception ex) {
- logger.error(ex);
- throw new BlogException(ex);
- }
- }
- public SortDAO getSortDAO() {
- return sortDAO;
- }
- public ArticleDAO getArticleDAO() {
- return articleDAO;
- }
- public void setSortDAO(SortDAO sortDAO) {
- this.sortDAO = sortDAO;
- }
- public void setArticleDAO(ArticleDAO articleDAO) {
- this.articleDAO = articleDAO;
- }
- }