admin
2021-03-06 7804263c6061aef813f0db27cb3046f746572606
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
package com.yeshi.buwan.dao.video;
 
import com.yeshi.buwan.dao.base.MongodbBaseDao;
import com.yeshi.buwan.domain.video.AlbumVideoMap;
import com.yeshi.buwan.domain.video.VideoInfoExtra;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Repository;
 
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
@Repository
public class VideoInfoExtraDao extends MongodbBaseDao<VideoInfoExtra> {
 
    /**
     * 选择性更新
     *
     * @param extra
     */
    public void updateSelective(VideoInfoExtra extra) {
        Query query = new Query();
        query.addCriteria(Criteria.where("id").is(extra.getId()));
 
        Update update = new Update();
        if (extra.gethPosterPicture() != null) {
            update.set("hPosterPicture", extra.gethPosterPicture());
        }
 
        if (extra.getvPosterPicture() != null) {
            update.set("vPosterPicture", extra.getvPosterPicture());
        }
        update.set("updateTime", new Date());
        update(query, update);
    }
 
 
    /**
     * 根据ID查询
     *
     * @param ids
     * @return
     */
    public List<VideoInfoExtra> listByIds(List<String> ids) {
        List<Criteria> whereList = new ArrayList<>();
        for (String id : ids) {
            whereList.add(Criteria.where("id").is(id));
        }
        Criteria[] wheres = new Criteria[whereList.size()];
        whereList.toArray(wheres);
        Query query = new Query();
        query.addCriteria(new Criteria().orOperator(wheres));
        return findList(query);
    }
 
 
}