|
|
@ -1,6 +1,7 @@
|
|
|
|
package com.luoo.music.service;
|
|
|
|
package com.luoo.music.service;
|
|
|
|
|
|
|
|
|
|
|
|
import com.luoo.music.dao.JournalSongDao;
|
|
|
|
import com.luoo.music.dao.JournalSongDao;
|
|
|
|
|
|
|
|
import com.luoo.music.pojo.Journal;
|
|
|
|
import com.luoo.music.pojo.JournalSong;
|
|
|
|
import com.luoo.music.pojo.JournalSong;
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@ -155,7 +156,22 @@ public class JournalSongService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<JournalSong> fuzzySearch(String keyword) {
|
|
|
|
public List<JournalSong> fuzzySearch(String keyword) {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
Specification<JournalSong> specification = fuzzySpecification(keyword);
|
|
|
|
return Collections.emptyList();
|
|
|
|
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()]));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|