Skip to content

Commit

Permalink
Merge pull request #1 from AkkaRin11/master
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbatovK authored Mar 23, 2024
2 parents dccc42d + 7e6be0d commit 957ee57
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.albatros.springsecurity.data.model.dto

data class SearchFragmentXML(
val fragment: List<String>
)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.albatros.springsecurity.data.model.dto

import java.io.Serializable

class TenderDto(
var ApiTenderInfo: String?,
var Category: String?,
var Customer: String?,
var Date: String?,
var EndTime: String?,
var Etp: String?,
var Fz: String?,
var ID: String?,
var Price: String?,
var Region: String?,
var TenderLink: String?,
var TenderLinkInner: String?,
var TenderName: String?,
var TenderNumOuter: String?,
var Total: String?,
var User_id: String?,
var searchFragmentXML: SearchFragmentXML?
): Serializable
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.albatros.springsecurity.data.model.dto

data class TenderInfoDto(
val ApiContractInfo: String,
val ApiIzmInfo: String,
val ApiPredInfo: String,
val ApiProtokolInfo: String,
val Category: String,
val Customer: String,
val CustomerINN: String,
val Date: String,
val EisLink: String,
val EisLinkPrint: String,
val EndTime: String,
val Etp: String,
val EtpLink: String,
val Fz: String,
val ID: String,
val Info: String,
val ObPrice: String,
val ObPriceZ: String,
val PlanZakupApiInfo: String,
val PlanZakupNumber: String,
val Price: String,
val Region: String,
val TenderLink: String,
val TenderLinkEtp: String,
val TenderLinkInner: String,
val TenderName: String,
val TenderNumOuter: String,
val TenderType: String,
val User_id: String,
val biddingDate: String,
val contactEmail: String,
val contactName: String,
val contactPhone: String,
val deliveryPlace: String,
val docsXML: List<Any>,
val productsXML: List<Any>,
val zakazLink: String,
val zakazTendersLink: String
)
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package com.albatros.springsecurity.data.service

import com.albatros.springsecurity.config.webclient.TenderApiConfig
import com.albatros.springsecurity.data.model.dto.TenderDto
import com.albatros.springsecurity.data.model.dto.TenderInfoDto
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(
Expand All @@ -20,6 +23,22 @@ class TenderService(
.collectList()
.block()

fun getTendersByProviders(providerId: Int): MutableList<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()


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

import com.albatros.springsecurity.data.service.TenderService
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping("/api/tender")
@RequestMapping("/api")
class TenderController(
private val tenderService: TenderService
) {

@GetMapping("/")
@GetMapping("providers/")
fun getAll() = tenderService.getAllTenderProviders()

@GetMapping("tenders/{id}")
fun getTendersByProviderId(@PathVariable id: Int) = tenderService.getTendersByProviders(id)

@GetMapping("tender_info/{id}")
fun getTenderInfoById(@PathVariable id: Int) = tenderService.getTenderInfoById(id)

}

0 comments on commit 957ee57

Please sign in to comment.