new updated
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -6,6 +6,7 @@ import org.bson.types.ObjectId
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.cache.annotation.CacheEvict
|
||||
import org.springframework.cache.annotation.Cacheable
|
||||
import org.springframework.context.ApplicationEventPublisher
|
||||
import org.springframework.data.domain.Sort
|
||||
import org.springframework.data.domain.Sort.Direction
|
||||
import org.springframework.data.mongodb.core.ReactiveMongoTemplate
|
||||
@@ -37,8 +38,9 @@ import java.util.Date
|
||||
@Service
|
||||
class CategoryService(
|
||||
private val categoryRepo: CategoryRepo,
|
||||
private val transactionService: TransactionService,
|
||||
private val mongoTemplate: ReactiveMongoTemplate
|
||||
private val financialService: FinancialService,
|
||||
private val mongoTemplate: ReactiveMongoTemplate,
|
||||
private val eventPublisher: ApplicationEventPublisher
|
||||
) {
|
||||
|
||||
private val logger = LoggerFactory.getLogger(javaClass)
|
||||
@@ -115,7 +117,7 @@ class CategoryService(
|
||||
return categoryRepo.findById(categoryId).switchIfEmpty(
|
||||
Mono.error(IllegalArgumentException("Category with id: $categoryId not found"))
|
||||
).flatMap {
|
||||
transactionService.getTransactions(categoryId = categoryId)
|
||||
financialService.getTransactions(categoryId = categoryId)
|
||||
.flatMapMany { transactions ->
|
||||
categoryRepo.findByName("Другое").switchIfEmpty(
|
||||
categoryRepo.save(
|
||||
@@ -126,10 +128,10 @@ class CategoryService(
|
||||
icon = "🚮"
|
||||
)
|
||||
)
|
||||
).flatMapMany { Category ->
|
||||
).flatMapMany { category ->
|
||||
Flux.fromIterable(transactions).flatMap { transaction ->
|
||||
transaction.category = Category // Присваиваем конкретный объект категории
|
||||
transactionService.editTransaction(transaction) // Сохраняем изменения
|
||||
transaction.category = category // Присваиваем конкретный объект категории
|
||||
financialService.editTransaction(transaction) // Сохраняем изменения
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -140,7 +142,6 @@ class CategoryService(
|
||||
|
||||
|
||||
fun getBudgetCategories(dateFrom: LocalDate, dateTo: LocalDate): Mono<Map<String, Map<String, Double>>> {
|
||||
logger.info("here cat starts")
|
||||
val pipeline = listOf(
|
||||
Document(
|
||||
"\$lookup",
|
||||
@@ -265,7 +266,6 @@ class CategoryService(
|
||||
)
|
||||
id to values
|
||||
}
|
||||
logger.info("here cat ends")
|
||||
|
||||
Mono.just(categories)
|
||||
}
|
||||
|
||||
1805
src/main/kotlin/space/luminic/budgerapp/services/FinancialService.kt
Normal file
1805
src/main/kotlin/space/luminic/budgerapp/services/FinancialService.kt
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user