package com.newvideo.service.imp.push; import java.util.List; import javax.annotation.Resource; import org.springframework.stereotype.Service; import com.newvideo.dao.push.VideoPushHistoryDao; import com.newvideo.domain.Comment2; import com.newvideo.domain.CommentReply; import com.newvideo.domain.LoginUser; import com.newvideo.domain.push.VideoPushHistory; import com.newvideo.service.imp.CommentService; import com.newvideo.util.StringUtil; import com.newvideo.util.XingePushUtil; @Service public class PushService { @Resource private VideoPushHistoryDao videoPushHistoryDao; @Resource private CommentService commentService; public VideoPushHistoryDao getVideoPushHistoryDao() { return videoPushHistoryDao; } public void setVideoPushHistoryDao(VideoPushHistoryDao videoPushHistoryDao) { this.videoPushHistoryDao = videoPushHistoryDao; } public void addVideoPushHistory(VideoPushHistory vh) { videoPushHistoryDao.create(vh); } public void updateVideoPushHistory(VideoPushHistory vh) { videoPushHistoryDao.update(vh); } public VideoPushHistory getVideoPushHistory(String id) { return videoPushHistoryDao.find(VideoPushHistory.class, id); } public List getUnPushVideoPushHistory() { return videoPushHistoryDao .list("from VideoPushHistory vh where vh.videoInfo.show=1 and (vh.pushtime is null or vh.pushtime='')"); } // 推送评论 public void pushCommentReplay(String commentid, String commentReplayId, String replyId) { LoginUser loginUser = null; if (!StringUtil.isNullOrEmpty(commentReplayId)) { CommentReply cr = commentService.getCommentReplay(commentReplayId); loginUser = cr.getUser(); } else { Comment2 c2 = commentService.getComment2ById(commentid); loginUser = c2.getUser(); } LoginUser owner = commentService.getCommentReplay(replyId).getUser(); if (loginUser != null && owner != null) {// 不为空 String messageStr = owner.getName() + " 回复了您的评论,赶快去看看吧"; XingePushUtil.pushCommentMessage(messageStr, loginUser.getId()); } } }