package com.service.imp; import java.util.ArrayList; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import com.entity.Comment; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.mapper.CommentMapper; import com.service.ICommentService; @Service public class CommentServiceImp implements ICommentService{ @Autowired private CommentMapper commentMapper; @Transactional(propagation=Propagation.REQUIRED,readOnly=true) @Override public Comment findCommentById(long comment_id) { return this.commentMapper.findCommentById(comment_id); } @Transactional(propagation=Propagation.REQUIRED,rollbackFor=Exception.class) @Override public Integer addComemnt(Comment comment) { return this.commentMapper.addComemnt(comment); } @Transactional(propagation=Propagation.REQUIRED,rollbackFor=Exception.class) @Override public Integer updateComment(Comment comment) { return this.commentMapper.updateComment(comment); } @Transactional(propagation=Propagation.REQUIRED,rollbackFor=Exception.class) @Override public Integer deleteComment(long comment_id) { return this.commentMapper.deleteComment(comment_id); } @Transactional(propagation=Propagation.REQUIRED,readOnly=true) @Override public List findAllComments() { return this.commentMapper.findAllComments(); } @Transactional(propagation=Propagation.REQUIRED,readOnly=true) @Override public PageInfo findAllCommentsBySplitPage(Integer page, Integer limit, String keyword) { PageHelper.startPage(page, limit); List list = new ArrayList(); if(keyword != null && !keyword.trim().equals("")) { System.out.println("keyword:"+keyword); list = this.commentMapper.findCommentsByUserName(keyword); }else { //System.out.println("keyword:"+keyword); list = this.commentMapper.findAllComments(); } PageInfo info = new PageInfo(list); return info; } @Transactional(propagation=Propagation.REQUIRED,readOnly=true) @Override public PageInfo findCommentsByUserName(Integer page, Integer limit,String user_name) { PageHelper.startPage(page,limit); List list = new ArrayList(); list = this.commentMapper.findCommentsByUserName(user_name); PageInfo info = new PageInfo(list); return info; } @Transactional(propagation=Propagation.REQUIRED,readOnly=true) @Override public List findCommentsByMovieId(long movie_id) { return this.commentMapper.findCommentsByMoiveId(movie_id); } }