add kafka producer, move configs to separate package

This commit is contained in:
Denis Savosin
2024-10-02 10:32:55 +07:00
parent 1fa8b7051e
commit cbf7e0a5f6
15 changed files with 186 additions and 15 deletions

View File

@@ -0,0 +1,39 @@
package com.example.demo.config
import com.example.demo.provider.CityRepository
import com.example.demo.provider.MockedShopProvider
import com.example.demo.provider.ProductRepository
import com.example.demo.provider.ShopProvider
import com.example.demo.services.CityService
import com.example.demo.services.CityServiceImpl
import com.example.demo.services.ProductService
import com.example.demo.services.ProductServiceImpl
import com.example.demo.services.kafka.Producer
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Value
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
@Configuration
class AppConfig(
@Value("\${kafka.producer.product.default-sync-topic}")
private val defaultProductSyncTopic: String
) {
@Bean
fun shopProvider(): ShopProvider{
return MockedShopProvider()
}
@Bean
fun productService(
@Autowired productRepository: ProductRepository,
@Autowired producer: Producer,
): ProductService = ProductServiceImpl(
defaultProductSyncTopic,
productRepository,
producer,
)
@Bean
fun cityService(@Autowired cityRepository: CityRepository): CityService = CityServiceImpl(cityRepository)
}