|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package com.luoo.music.service;
|
|
|
|
|
|
|
|
|
|
import com.luoo.music.dao.JournalSongDao;
|
|
|
|
|
import com.luoo.music.pojo.Journal;
|
|
|
|
|
import com.luoo.music.pojo.JournalSong;
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
@ -155,7 +156,22 @@ public class JournalSongService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<JournalSong> fuzzySearch(String keyword) {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
Specification<JournalSong> specification = fuzzySpecification(keyword);
|
|
|
|
|
return journalSongDao.findAll(specification);
|
|
|
|
|
}
|
|
|
|
|
private Specification<JournalSong> fuzzySpecification(String keyword) {
|
|
|
|
|
return new Specification<JournalSong>() {
|
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
|
@Override
|
|
|
|
|
public Predicate toPredicate(Root<JournalSong> root, CriteriaQuery<?> query, CriteriaBuilder criteriaBuilder) {
|
|
|
|
|
List<Predicate> predicateList = new ArrayList<Predicate>();
|
|
|
|
|
predicateList.add(criteriaBuilder.like(root.get("name").as(String.class),"%"+keyword+"%"));
|
|
|
|
|
predicateList.add(criteriaBuilder.like(root.get("artist").as(String.class),"%"+keyword+"%"));
|
|
|
|
|
predicateList.add(criteriaBuilder.like(root.get("album").as(String.class),"%"+keyword+"%"));
|
|
|
|
|
predicateList.add(criteriaBuilder.like(root.get("journalNo").as(String.class),"%"+keyword+"%"));
|
|
|
|
|
query.orderBy(criteriaBuilder.asc(root.get("name")));
|
|
|
|
|
return criteriaBuilder.or(predicateList.toArray(new Predicate[predicateList.size()]));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|