package com.yeshi.buwan.dao.juhe.hanmi;
|
|
import com.yeshi.buwan.dao.base.MongodbBaseDao;
|
import com.yeshi.buwan.videos.hanmi.entity.HanmiShowEpisode;
|
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 HanmiShowEpisodeDao extends MongodbBaseDao<HanmiShowEpisode> {
|
|
|
public List<HanmiShowEpisode> listByShowId(String showId, int start, int count) {
|
Query query = new Query();
|
query.addCriteria(Criteria.where("showId").is(showId));
|
query.with(new Sort(new Sort.Order(Sort.Direction.ASC, "orderBy")));
|
return findList(query);
|
}
|
|
|
|
public HanmiShowEpisode getLatestEpisode(String showId) {
|
Query query = new Query();
|
query.addCriteria(Criteria.where("showId").is(showId));
|
query.with(new Sort(new Sort.Order(Sort.Direction.DESC, "orderBy")));
|
query.limit(1);
|
return findOne(query);
|
}
|
|
public long countByShowId(String showId) {
|
Query query = new Query();
|
query.addCriteria(Criteria.where("showId").is(showId));
|
return count(query);
|
}
|
|
|
}
|