- Visual C++源码
- Visual Basic源码
- C++ Builder源码
- Java源码
- Delphi源码
- C/C++源码
- PHP源码
- Perl源码
- Python源码
- Asm源码
- Pascal源码
- Borland C++源码
- Others源码
- SQL源码
- VBScript源码
- JavaScript源码
- ASP/ASPX源码
- C#源码
- Flash/ActionScript源码
- matlab源码
- PowerBuilder源码
- LabView源码
- Flex源码
- MathCAD源码
- VBA源码
- IDL源码
- Lisp/Scheme源码
- VHDL源码
- Objective-C源码
- Fortran源码
- tcl/tk源码
- QT源码
- package com.mycompany.news.service;
- import java.sql.Connection;
- import java.util.ArrayList;
- import java.util.List;
- import com.mycompany.database.Database;
- import com.mycompany.news.dao.NewsCommentDAO;
- import com.mycompany.news.dao.impl.NewsCommentDAOImpl;
- import com.mycompany.news.dto.News;
- import com.mycompany.news.dto.NewsComment;
- public class NewsCommentService extends BaseService {
- private NewsCommentDAO dao = new NewsCommentDAOImpl();
- /**
- * 添加评论
- * @param comment
- * @return
- */
- public boolean addComment(NewsComment comment){
- Connection conn=null;
- try {
- conn =Database.getConnection();
- dao.setConnection(conn);
- dao.addNewsComment(comment);
- Database.commit();
- setMessage("评论成功,等待审核");
- return true;
- } catch (Exception e) {
- setMessage(e.getMessage());
- return false;
- }finally{
- Database.releaseConnection(conn);
- }
- }
- /**
- * 删除评论
- * @param comment
- * @return
- */
- public boolean deleteComment(NewsComment comment){
- Connection conn=null;
- try {
- conn =Database.getConnection();
- dao.setConnection(conn);
- dao.deleteNewsComment(comment);
- Database.commit();
- return true;
- } catch (Exception e) {
- // TODO: handle exception
- return false;
- }finally{
- Database.releaseConnection(conn);
- }
- }
- /**
- * 列出分页评论(包括未审核)
- * @param news
- * @param pageNo
- * @param pageSize
- * @return
- */
- public List listComment(News news,int pageNo,int pageSize){
- Connection conn=null;
- try {
- conn =Database.getConnection();
- dao.setConnection(conn);
- List ret =dao.getNewsComment(news,pageNo,pageSize);
- return ret;
- } catch (Exception e) {
- // TODO: handle exception
- return new ArrayList();
- }finally{
- Database.releaseConnection(conn);
- }
- }
- /**
- * 分页列出已审核的评论
- * @param news
- * @param pageNo
- * @param pageSize
- * @return
- */
- public List listPublicComment(News news,int pageNo,int pageSize){
- Connection conn=null;
- try {
- conn =Database.getConnection();
- dao.setConnection(conn);
- List ret =dao.listPublicComment(news,pageNo,pageSize);
- return ret;
- } catch (Exception e) {
- // TODO: handle exception
- return new ArrayList();
- }finally{
- Database.releaseConnection(conn);
- }
- }
- public boolean auditComment(NewsComment comment) {
- Connection conn=null;
- try {
- conn =Database.getConnection();
- dao.setConnection(conn);
- boolean ret =dao.auditComment(comment);
- Database.commit();
- return ret;
- } catch (Exception e) {
- setMessage(e.getMessage());
- return false;
- }finally{
- Database.releaseConnection(conn);
- }
- }
- }