package com.yeshi.buwan.dao.video;
|
|
import com.yeshi.buwan.dao.base.MongodbBaseDao;
|
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));
|
}
|
if (whereList.size() == 0)
|
return new ArrayList<>();
|
Criteria[] wheres = new Criteria[whereList.size()];
|
whereList.toArray(wheres);
|
Query query = new Query();
|
query.addCriteria(new Criteria().orOperator(wheres));
|
return findList(query);
|
}
|
|
|
}
|