admin
2022-04-16 04f09e52ffd4681bdfd85e51acd3da0d1280c3d3
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
package com.yeshi.buwan.dao.video;
 
import com.yeshi.buwan.dao.base.MongodbBaseDao;
import com.yeshi.buwan.domain.video.VideoWatchHistory;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;
 
import java.util.List;
 
@Repository
public class VideoWatchHistoryDao extends MongodbBaseDao<VideoWatchHistory> {
 
 
    public List<VideoWatchHistory> list(String device, int start, int count) {
        Query query = new Query();
        query.addCriteria(Criteria.where("device").is(device));
        query.skip(start);
        query.limit(count);
        query.with(new Sort(new Sort.Order(Sort.Direction.DESC, "createTime")));
        return findList(query);
    }
 
    public long count(String device) {
        Query query = new Query();
        query.addCriteria(Criteria.where("device").is(device));
        return count(query);
    }
 
}