fix spaces
This commit is contained in:
@@ -10,12 +10,7 @@ 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
|
||||
import org.springframework.data.mongodb.core.aggregation.Aggregation.limit
|
||||
import org.springframework.data.mongodb.core.aggregation.Aggregation.lookup
|
||||
import org.springframework.data.mongodb.core.aggregation.Aggregation.match
|
||||
import org.springframework.data.mongodb.core.aggregation.Aggregation.newAggregation
|
||||
import org.springframework.data.mongodb.core.aggregation.Aggregation.skip
|
||||
import org.springframework.data.mongodb.core.aggregation.Aggregation.sort
|
||||
import org.springframework.data.mongodb.core.aggregation.Aggregation.*
|
||||
import org.springframework.data.mongodb.core.query.Criteria
|
||||
import org.springframework.data.mongodb.core.query.isEqualTo
|
||||
import org.springframework.stereotype.Service
|
||||
@@ -47,7 +42,6 @@ class CategoryService(
|
||||
}
|
||||
|
||||
|
||||
|
||||
// @Cacheable("categories")
|
||||
fun getCategories(spaceId: String, type: String? = null, sortBy: String, direction: String): Mono<List<Category>> {
|
||||
val matchCriteria = mutableListOf<Criteria>()
|
||||
@@ -62,11 +56,13 @@ class CategoryService(
|
||||
val sort = sort(Sort.by(direction, sortBy))
|
||||
|
||||
val lookupSpaces = lookup("spaces", "space.\$id", "_id", "spaceDetails")
|
||||
val project = project("_id", "type", "name", "description", "icon")
|
||||
|
||||
val aggregationBuilder = mutableListOf(
|
||||
|
||||
lookupSpaces,
|
||||
match.takeIf { matchCriteria.isNotEmpty() },
|
||||
project,
|
||||
sort,
|
||||
).filterNotNull()
|
||||
|
||||
@@ -96,11 +92,7 @@ class CategoryService(
|
||||
return types
|
||||
}
|
||||
|
||||
@CacheEvict(cacheNames = ["getAllCategories"], allEntries = true)
|
||||
fun createCategory(space: Space, category: Category): Mono<Category> {
|
||||
category.space = space
|
||||
return categoryRepo.save(category)
|
||||
}
|
||||
|
||||
|
||||
@CacheEvict(cacheNames = ["getAllCategories"], allEntries = true)
|
||||
fun editCategory(category: Category): Mono<Category> {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user