| | |
| | | package com.yeshi.buwan.service.manager; |
| | | |
| | | import com.yeshi.buwan.dao.video.AlbumVideoMapDao; |
| | | import com.yeshi.buwan.domain.SolrVideo; |
| | | import com.yeshi.buwan.domain.VideoInfo; |
| | | import com.yeshi.buwan.domain.video.AlbumVideoMap; |
| | | import com.yeshi.buwan.dto.search.SolrResultDTO; |
| | | import com.yeshi.buwan.service.imp.VideoInfoService; |
| | | import com.yeshi.buwan.service.inter.juhe.AlbumVideoMapService; |
| | | import com.yeshi.buwan.util.factory.SolrVideoFactory; |
| | | import org.apache.solr.client.solrj.response.UpdateResponse; |
| | | import org.springframework.data.domain.Sort; |
| | | import org.springframework.data.solr.core.SolrTemplate; |
| | | import org.springframework.data.solr.core.query.Criteria; |
| | | import org.springframework.data.solr.core.query.Query; |
| | |
| | | return solrVideo; |
| | | } |
| | | |
| | | public List<SolrVideo> findByKey(String key, Integer contentType, Integer videoType, int page) { |
| | | int pageSize = 20; |
| | | public SolrResultDTO findByKey(String key, Integer contentType, Integer videoType, int page, int pageSize) { |
| | | Query query = new SimpleQuery("name:\"" + key + "\""); |
| | | |
| | | Criteria criteria = new Criteria("contenttype").is(contentType); |
| | |
| | | query.addCriteria(criteria); |
| | | |
| | | /** 设置分页开始记录数(第一页) 默认0 */ |
| | | query.setOffset((page - 1) * page); |
| | | query.setOffset((page - 1) * pageSize); |
| | | /** 设置每页显示记录数,默认10 */ |
| | | query.setRows(pageSize); |
| | | query.addSort(new Sort(Sort.Direction.DESC, "year")); |
| | | ScoredPage<SolrVideo> result = solrTemplate.queryForPage(query, SolrVideo.class); |
| | | System.out.println("总记录数:" + result.getTotalElements()); |
| | | List<SolrVideo> list = result.getContent(); |
| | | return list; |
| | | return new SolrResultDTO(list, (int) result.getTotalElements()); |
| | | } |
| | | |
| | | public List<String> getSuggestKeyList(String key) { |