-
Notifications
You must be signed in to change notification settings - Fork 0
/
ReportRepository.kt
36 lines (32 loc) · 1.22 KB
/
ReportRepository.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package com.aamdigital.aambackendservice.reporting.storage
import com.aamdigital.aambackendservice.couchdb.core.CouchDbStorage
import com.aamdigital.aambackendservice.couchdb.core.getQueryParamsAllDocs
import com.aamdigital.aambackendservice.reporting.report.dto.FetchReportsResponse
import com.aamdigital.aambackendservice.reporting.report.dto.ReportDoc
import org.springframework.stereotype.Service
import org.springframework.util.LinkedMultiValueMap
import reactor.core.publisher.Mono
@Service
class ReportRepository(
private val couchDbStorage: CouchDbStorage,
) {
companion object {
private const val REPORT_DATABASE = "app"
}
fun fetchReports(): Mono<FetchReportsResponse> {
return couchDbStorage.getDatabaseDocument(
database = REPORT_DATABASE,
documentId = "_all_docs",
getQueryParamsAllDocs("ReportConfig"),
FetchReportsResponse::class
)
}
fun fetchReport(documentId: String, queryParams: LinkedMultiValueMap<String, String>): Mono<ReportDoc> {
return couchDbStorage.getDatabaseDocument(
database = REPORT_DATABASE,
documentId = documentId,
queryParams,
ReportDoc::class
)
}
}