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

📄 newsserviceimp.java

📁 Java项目 新闻管理系统 jsp+struts+hibernate 开发:eclipse+oracle9i+tomcat 高质量代码 导入数据即可用
💻 JAVA
字号:
package com.xdf.news.bo.service;

import java.util.List;

import com.xdf.news.bean.Admin;
import com.xdf.news.bean.News;
import com.xdf.news.bean.Ntype;
import com.xdf.news.bean.Reply;
import com.xdf.news.bo.INewsService;
import com.xdf.news.dao.IAdminDAO;
import com.xdf.news.dao.INewsDAO;
import com.xdf.news.dao.INtypeDAO;
import com.xdf.news.dao.IReplyDAO;

public class NewsServiceImp extends BaseService implements INewsService{
	private INewsDAO newsdao;
	private INtypeDAO ntypedao;
	private IReplyDAO replydao;
	private IAdminDAO admindao;
	public IAdminDAO getAdmindao() {
		return admindao;
	}

	public void setAdmindao(IAdminDAO admindao) {
		this.admindao = admindao;
	}

	public INewsDAO getNewsdao() {
		return newsdao;
	}

	public void setNewsdao(INewsDAO newsdao) {
		this.newsdao = newsdao;
	}

	public INtypeDAO getNtypedao() {
		return ntypedao;
	}

	public void setNtypedao(INtypeDAO ntypedao) {
		this.ntypedao = ntypedao;
	}

	public IReplyDAO getReplydao() {
		return replydao;
	}

	public void setReplydao(IReplyDAO replydao) {
		this.replydao = replydao;
	}

	public void addNews(News news) {
		beginTransaction();
		newsdao.add(news);
		commitTransaction();
	}

	public void addreply(Reply reply) {
		beginTransaction();
		replydao.add(reply);
		commitTransaction();
	}

	public void deleteNews(News news) {
		try {
			beginTransaction();
			replydao.deletebynewsid(news.getNewsid());
			newsdao.delete(news);
			commitTransaction();
		} catch (RuntimeException e) {
			rollbackTransaction();
			e.printStackTrace();
			throw e;
		}
	}

	public Admin findadmin(String username, String password) {
		return admindao.findAdmin(username,password);
	}

	public List findAllNews() {
		return newsdao.findAll();
	}

	public List findAllType() {
		return ntypedao.findAll();
	}

	public List findNews(String title, String keyword, Long typeid) {
		return newsdao.findNews(title,keyword,typeid);
	}

	public News findNewsById(Long id) {
		return (News)newsdao.load(News.class,id);
	}

	public int findNewsCount() {
		return newsdao.findcount();
	}

	public News readNews(Long id) {
		beginTransaction();
		News news = (News)newsdao.load(News.class,id);
		news.setTimes(news.getTimes()+1);
		//newsdao.update(news);		
		commitTransaction();
		return news;
	}

	public void updateNews(News news) {
		beginTransaction();
		newsdao.update(news);
		commitTransaction();
	}
	public Ntype findType(Long typeid) {
		return (Ntype)ntypedao.load(Ntype.class,typeid); 
	}
}

⌨️ 快捷键说明

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