admin
2021-03-01 d73687bc6115007145b4aab050e4e29ff87fd8ae
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package com.yeshi.buwan.service.imp.push;
 
import java.util.List;
 
import javax.annotation.Resource;
 
import org.springframework.stereotype.Service;
 
import com.yeshi.buwan.dao.push.VideoPushHistoryDao;
import com.yeshi.buwan.domain.Comment2;
import com.yeshi.buwan.domain.CommentReply;
import com.yeshi.buwan.domain.user.LoginUser;
import com.yeshi.buwan.domain.push.VideoPushHistory;
import com.yeshi.buwan.service.imp.CommentService;
import com.yeshi.buwan.util.StringUtil;
import com.yeshi.buwan.util.XingePushUtil;
 
@Service
public class PushService {
    @Resource
    private VideoPushHistoryDao videoPushHistoryDao;
    @Resource
    private CommentService commentService;
 
 
    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<VideoPushHistory> 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());
        }
    }
 
}