Skip to content

Commit

Permalink
First day
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbatovK committed Mar 23, 2024
1 parent 957ee57 commit e6584bd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import com.albatros.springsecurity.data.model.dto.TenderProviderDto
import org.springframework.http.MediaType
import org.springframework.stereotype.Service
import org.springframework.web.reactive.function.client.WebClient
import java.nio.charset.Charset

@Service
class TenderService(
class TenderApiService(
private val tenderApiConfig: TenderApiConfig,
private val webClient: WebClient
) {
Expand All @@ -23,20 +22,20 @@ class TenderService(
.collectList()
.block()

fun getTendersByProviders(providerId: Int): MutableList<TenderDto>? = webClient
fun getTendersByProviders(providerId: Int): List<TenderDto>? = webClient
.get()
.uri("/export?e$providerId=$providerId&api_code=${tenderApiConfig.apiKey}&dtype=json")
.accept(MediaType.APPLICATION_JSON)
.retrieve()
.bodyToFlux(TenderDto::class.java)
.collectList()
.block()
?.drop(1)

fun getTenderInfoById(tenderId: Int): MutableList<TenderInfoDto>? = webClient
.get()
.uri("/export?e$tenderId=$tenderId&dtype=json")
.uri("/export?id=$tenderId&dtype=json")
.accept(MediaType.APPLICATION_JSON)
.acceptCharset(Charset.forName("UTF-8"))
.retrieve()
.bodyToFlux(TenderInfoDto::class.java)
.collectList()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.albatros.springsecurity.presentation.controller

import com.albatros.springsecurity.data.service.TenderService
import com.albatros.springsecurity.data.service.TenderApiService
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestMapping
Expand All @@ -9,7 +9,7 @@ import org.springframework.web.bind.annotation.RestController
@RestController
@RequestMapping("/api")
class TenderController(
private val tenderService: TenderService
private val tenderService: TenderApiService
) {

@GetMapping("providers/")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.albatros.springsecurity.presentation.route

import com.albatros.springsecurity.data.model.dto.TenderProviderDto
import com.albatros.springsecurity.data.service.TenderService
import com.albatros.springsecurity.data.service.TenderApiService
import com.vaadin.flow.component.Text
import com.vaadin.flow.component.button.Button
import com.vaadin.flow.component.grid.Grid
Expand All @@ -11,7 +11,7 @@ import com.vaadin.flow.router.Route

@Route("")
class MainRoute(
tenderService: TenderService
tenderService: TenderApiService
) : VerticalLayout() {

init {
Expand Down

0 comments on commit e6584bd

Please sign in to comment.