-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from kirillsinyuk/feature/26 #minor
#26 add mongosearch
- Loading branch information
Showing
3 changed files
with
21 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 9 additions & 6 deletions
15
src/main/kotlin/com/kvsinyuk/elasticsearch/application/impl/SearchDealsUseCaseImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
package com.kvsinyuk.elasticsearch.application.impl | ||
|
||
import com.kvsinyuk.elasticsearch.adapter.out.elasticsearch.ElasticDealRepository | ||
import com.kvsinyuk.elasticsearch.adapter.out.mongo.MongoDealRepository | ||
import com.kvsinyuk.elasticsearch.application.port.SearchDealsUseCase | ||
import org.springframework.data.domain.Pageable | ||
import com.kvsinyuk.elasticsearch.application.port.SearchDealsUseCase.SearchCommand | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class SearchDealsUseCaseImpl( | ||
private val dealRepository: ElasticDealRepository, | ||
private val elasticDealRepository: ElasticDealRepository, | ||
private val mongoDealRepository: MongoDealRepository, | ||
) : SearchDealsUseCase { | ||
override fun searchDeals( | ||
search: String, | ||
page: Pageable, | ||
) = dealRepository.searchAll(search, page) | ||
override fun searchDeals(command: SearchCommand) = | ||
when (command.databaseType) { | ||
"elasticsearch" -> elasticDealRepository.searchAll(command.search, command.page) | ||
else -> mongoDealRepository.findAll(command.page) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters