diff --git a/src/main/kotlin/com/albatros/springsecurity/data/model/dto/SearchFragmentXML.kt b/src/main/kotlin/com/albatros/springsecurity/data/model/dto/SearchFragmentXML.kt new file mode 100644 index 0000000..9f8b829 --- /dev/null +++ b/src/main/kotlin/com/albatros/springsecurity/data/model/dto/SearchFragmentXML.kt @@ -0,0 +1,5 @@ +package com.albatros.springsecurity.data.model.dto + +data class SearchFragmentXML( + val fragment: List +) \ No newline at end of file diff --git a/src/main/kotlin/com/albatros/springsecurity/data/model/dto/TenderDto.java b/src/main/kotlin/com/albatros/springsecurity/data/model/dto/TenderDto.java deleted file mode 100644 index 464525c..0000000 --- a/src/main/kotlin/com/albatros/springsecurity/data/model/dto/TenderDto.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.albatros.springsecurity.data.model.dto; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Data; - -@Data -public class TenderDto { - private int ID; - private String Date; - private String TenderName; - private String Customer; - private String Category; - private String Region; - private Long Price; - private String EndTime; - private String Etp; - private String TenderLink; - private String TenderLinkInner; - @JsonProperty("User_id") - private int UserId; - private String CustomerINN; -} diff --git a/src/main/kotlin/com/albatros/springsecurity/data/model/dto/TenderDto.kt b/src/main/kotlin/com/albatros/springsecurity/data/model/dto/TenderDto.kt new file mode 100644 index 0000000..e678f3d --- /dev/null +++ b/src/main/kotlin/com/albatros/springsecurity/data/model/dto/TenderDto.kt @@ -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 \ No newline at end of file diff --git a/src/main/kotlin/com/albatros/springsecurity/data/model/dto/TenderInfoDto.kt b/src/main/kotlin/com/albatros/springsecurity/data/model/dto/TenderInfoDto.kt new file mode 100644 index 0000000..d954f49 --- /dev/null +++ b/src/main/kotlin/com/albatros/springsecurity/data/model/dto/TenderInfoDto.kt @@ -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, + val productsXML: List, + val zakazLink: String, + val zakazTendersLink: String +) \ No newline at end of file diff --git a/src/main/kotlin/com/albatros/springsecurity/data/service/TenderService.kt b/src/main/kotlin/com/albatros/springsecurity/data/service/TenderService.kt index 5729ac4..5b82c42 100644 --- a/src/main/kotlin/com/albatros/springsecurity/data/service/TenderService.kt +++ b/src/main/kotlin/com/albatros/springsecurity/data/service/TenderService.kt @@ -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( @@ -20,6 +23,22 @@ class TenderService( .collectList() .block() + fun getTendersByProviders(providerId: Int): MutableList? = 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? = 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() } \ No newline at end of file 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 b841a31..e364234 100644 --- a/src/main/kotlin/com/albatros/springsecurity/presentation/controller/TenderController.kt +++ b/src/main/kotlin/com/albatros/springsecurity/presentation/controller/TenderController.kt @@ -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) + } \ No newline at end of file