|
|
@ -2,6 +2,7 @@ package com.luoo.music.service;
|
|
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
import java.util.stream.IntStream;
|
|
|
|
import java.util.stream.IntStream;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.persistence.criteria.CriteriaBuilder;
|
|
|
|
import javax.persistence.criteria.CriteriaBuilder;
|
|
|
@ -38,7 +39,7 @@ import com.luoo.music.pojo.Journal;
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Service
|
|
|
|
@Service
|
|
|
|
public class JournalService {
|
|
|
|
public class JournalService {
|
|
|
|
|
|
|
|
private static final Pattern NUMBER_PATTERN = Pattern.compile("[0-9]*");
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private JournalDao journalDao;
|
|
|
|
private JournalDao journalDao;
|
|
|
|
|
|
|
|
|
|
|
@ -285,11 +286,22 @@ public class JournalService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<Journal> fuzzySearch(String keyword, PageRequest pageRequest) {
|
|
|
|
public List<Journal> fuzzySearch(String keyword, PageRequest pageRequest) {
|
|
|
|
|
|
|
|
if(isNumeric(keyword)) {
|
|
|
|
|
|
|
|
Journal journal=journalDao.findValidJournalByJournalNo(keyword);
|
|
|
|
|
|
|
|
if(null!=journal) {
|
|
|
|
|
|
|
|
return Arrays.asList(journal);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
if(keyword.length()==1) {
|
|
|
|
if(keyword.length()==1) {
|
|
|
|
return searchByLike(keyword,pageRequest);
|
|
|
|
return searchByLike(keyword,pageRequest);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return journalDao.fuzzySearch(keyword, pageRequest.getPageNumber()*pageRequest.getPageSize(), pageRequest.getPageSize());
|
|
|
|
return journalDao.fuzzySearch("+\""+keyword+"\"", pageRequest.getPageNumber()*pageRequest.getPageSize(), pageRequest.getPageSize());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static boolean isNumeric(String str){
|
|
|
|
|
|
|
|
return NUMBER_PATTERN.matcher(str).matches();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private List<Journal> searchByLike(String keyword, PageRequest pageRequest) {
|
|
|
|
private List<Journal> searchByLike(String keyword, PageRequest pageRequest) {
|
|
|
|
Specification<Journal> specification = fuzzySpecification(keyword);
|
|
|
|
Specification<Journal> specification = fuzzySpecification(keyword);
|
|
|
|
return journalDao.findAll(specification,pageRequest).getContent();
|
|
|
|
return journalDao.findAll(specification,pageRequest).getContent();
|
|
|
|