diff --git a/build.gradle.kts b/build.gradle.kts index 2885cb4..faa6d95 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,5 @@ import com.google.cloud.tools.jib.gradle.JibExtension +import com.vaadin.gradle.vaadin import io.gitlab.arturbosch.detekt.Detekt import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.jlleitschuh.gradle.ktlint.reporter.ReporterType @@ -36,6 +37,13 @@ noArg { group = "com.albatros" version = "0.0.1-SNAPSHOT" +vaadin { + pnpmEnable = true + productionMode = true + generateBundle = true + optimizeBundle = trueg +} + java { sourceCompatibility = JavaVersion.VERSION_17 } diff --git a/src/main/kotlin/com/albatros/springsecurity/data/repository/TenderSearchRepository.kt b/src/main/kotlin/com/albatros/springsecurity/data/repository/TenderSearchRepository.kt index 3532378..fe301c1 100644 --- a/src/main/kotlin/com/albatros/springsecurity/data/repository/TenderSearchRepository.kt +++ b/src/main/kotlin/com/albatros/springsecurity/data/repository/TenderSearchRepository.kt @@ -6,6 +6,7 @@ import org.springframework.data.domain.Pageable import org.springframework.data.elasticsearch.annotations.Query import org.springframework.data.elasticsearch.repository.ElasticsearchRepository import org.springframework.stereotype.Repository +import java.util.stream.Stream @Repository interface TenderSearchRepository : ElasticsearchRepository { @@ -20,7 +21,7 @@ interface TenderSearchRepository : ElasticsearchRepository { "query": "?0", "fields": ["tender_name^5", "tender_id^15", "region^5", "etp^10", "fz", "meta_data", "user_id", "category^10", "customer^15", "date"], "operator": "AND", - "fuzziness": "2", + "fuzziness": "AUTO", "minimum_should_match": "2", "type": "best_fields" } @@ -32,7 +33,7 @@ interface TenderSearchRepository : ElasticsearchRepository { "query": "?1", "fields": ["tender_name^5", "tender_id^15", "region^5", "etp^10", "fz", "meta_data", "user_id", "category^10", "customer^15", "date"], "operator": "AND", - "fuzziness": "2", + "fuzziness": "AUTO", "type": "best_fields" } } @@ -41,7 +42,7 @@ interface TenderSearchRepository : ElasticsearchRepository { } """ ) - fun fullTextSearchAnd(keywords: String): List + fun fullTextSearchAnd(keywords: String, exclude: String, pageable: Pageable): Stream @Query( """ @@ -53,7 +54,7 @@ interface TenderSearchRepository : ElasticsearchRepository { "query": "?0", "fields": ["tender_name^5", "tender_id^15", "region^5", "etp^10", "fz", "meta_data", "user_id", "category^10", "customer^15", "date"], "operator": "OR", - "fuzziness": "2", + "fuzziness": "AUTO", "type": "best_fields" } } @@ -64,7 +65,7 @@ interface TenderSearchRepository : ElasticsearchRepository { "query": "?1", "fields": ["tender_name^5", "tender_id^15", "region^5", "etp^10", "fz", "meta_data", "user_id", "category^10", "customer^15", "date"], "operator": "AND", - "fuzziness": "2", + "fuzziness": "AUTO", "type": "best_fields" } } @@ -73,7 +74,7 @@ interface TenderSearchRepository : ElasticsearchRepository { } """ ) - fun fullTextSearchOr(keywords: String, exclude: String): List + fun fullTextSearchOr(keywords: String, exclude: String): Stream fun findAllByTenderId(tenderId: String, pageable: Pageable): Page fun findAllByCustomerContainsIgnoreCase(customer: String, pageable: Pageable): Page diff --git a/src/main/kotlin/com/albatros/springsecurity/presentation/controller/TenderController.kt b/src/main/kotlin/com/albatros/springsecurity/presentation/controller/TenderController.kt index e77f598..8c1a740 100644 --- a/src/main/kotlin/com/albatros/springsecurity/presentation/controller/TenderController.kt +++ b/src/main/kotlin/com/albatros/springsecurity/presentation/controller/TenderController.kt @@ -22,10 +22,10 @@ class TenderController( ) { @PostMapping("/full-text-search") - fun getAll(@RequestBody fullTextSearchRequest: FullTextSearchRequest): List { + fun getAll(@RequestBody fullTextSearchRequest: FullTextSearchRequest, pageable: Pageable): List { return tenderRepository.fullTextSearchOr( fullTextSearchRequest.include, fullTextSearchRequest.exclude - ) + ).toList() } @GetMapping("/provider/") diff --git a/src/main/kotlin/com/albatros/springsecurity/presentation/route/TestRoute.kt b/src/main/kotlin/com/albatros/springsecurity/presentation/route/TestRoute.kt index 645c260..89d8990 100644 --- a/src/main/kotlin/com/albatros/springsecurity/presentation/route/TestRoute.kt +++ b/src/main/kotlin/com/albatros/springsecurity/presentation/route/TestRoute.kt @@ -1,22 +1,15 @@ package com.albatros.springsecurity.presentation.route import com.albatros.springsecurity.data.model.database.Tender -import com.albatros.springsecurity.data.model.database.TenderProvider -import com.albatros.springsecurity.data.repository.TenderProviderRepository import com.albatros.springsecurity.data.repository.TenderSearchRepository -import com.vaadin.flow.component.Text import com.vaadin.flow.component.button.Button import com.vaadin.flow.component.button.ButtonVariant import com.vaadin.flow.component.grid.Grid -import com.vaadin.flow.component.html.Paragraph import com.vaadin.flow.component.icon.VaadinIcon -import com.vaadin.flow.component.notification.Notification import com.vaadin.flow.component.orderedlayout.HorizontalLayout import com.vaadin.flow.component.orderedlayout.VerticalLayout import com.vaadin.flow.component.textfield.TextField import com.vaadin.flow.router.Route -import com.vaadin.flow.spring.data.VaadinSpringDataHelpers - @Route("test") class TestRoute(repository: TenderSearchRepository) : VerticalLayout() { @@ -59,7 +52,7 @@ class TestRoute(repository: TenderSearchRepository) : VerticalLayout() { height = "600px" } - val button = Button("Найти", VaadinIcon.SEARCH.create()){ + val button = Button("Найти", VaadinIcon.SEARCH.create()) { val includeText = includeTextField.value val excludeText = excludeTextField.value @@ -67,7 +60,7 @@ class TestRoute(repository: TenderSearchRepository) : VerticalLayout() { repository.fullTextSearchOr( includeText, excludeText, - ) + ).toList() ) }