fix date to localdate

This commit is contained in:
xds
2025-02-17 22:16:27 +03:00
parent cb9a98dec5
commit 2610eb0404
4 changed files with 25 additions and 2 deletions

View File

@@ -10,6 +10,7 @@ import org.springframework.data.domain.Sort
import org.springframework.data.domain.Sort.Direction
import org.springframework.data.mongodb.core.MongoTemplate
import org.springframework.data.mongodb.core.ReactiveMongoTemplate
import org.springframework.data.mongodb.core.aggregation.Aggregation
import org.springframework.data.mongodb.core.aggregation.Aggregation.*
import org.springframework.data.mongodb.core.aggregation.DateOperators.DateToString
import org.springframework.data.mongodb.core.query.Criteria
@@ -222,7 +223,7 @@ class FinancialService(
println("Space ID type: ${spaceObjectId::class.java}, value: $spaceObjectId")
// Применяем сортировку к запросу
budgetRepo.findBySpaceId(spaceObjectId, sort).collectList()
findProjectedBudgets(spaceObjectId).collectList()
}
@@ -230,6 +231,17 @@ class FinancialService(
}
}
}
fun findProjectedBudgets(spaceId: ObjectId): Flux<Budget> {
val lookupSpaces = lookup("spaces", "space.\$id", "_id", "spaceDetails")
val matchStage = Aggregation.match(Criteria.where("spaceDetails._id").`is`(spaceId))
// matchCriteria.add(Criteria.where("spaceDetails._id").`is`(ObjectId(spaceId)))
val projectStage = Aggregation.project("_id", "name", "dateFrom", "dateTo") // Оставляем только нужные поля
val sort = sort(Sort.by(Sort.Order.desc("_id")))
val aggregation = Aggregation.newAggregation(lookupSpaces, matchStage, projectStage, sort)
return reactiveMongoTemplate.aggregate(aggregation, "budgets", Budget::class.java)
}
// @Cacheable("budgets", key = "#id")
fun getBudget(id: String): Mono<BudgetDTO> {