Работа над добавлением поиска паттернов
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
package ru.serega6531.packmate.service;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.serega6531.packmate.model.Pattern;
|
||||
import ru.serega6531.packmate.repository.PatternRepository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@@ -23,6 +26,14 @@ public class PatternService {
|
||||
return repository.findAll();
|
||||
}
|
||||
|
||||
public List<Pattern> findMatching(byte[] bytes) {
|
||||
String content = new String(bytes);
|
||||
|
||||
return findAll().stream()
|
||||
.filter(pattern -> StringUtils.containsIgnoreCase(content, pattern.getValue()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public void deleteById(int id) {
|
||||
repository.deleteById(id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user