fix recurrents

This commit is contained in:
xds
2025-02-21 01:44:03 +03:00
parent bf2dfca1cc
commit 363d926443
17 changed files with 618 additions and 1034 deletions

View File

@@ -87,7 +87,9 @@ class SpaceController(
//
@GetMapping("/{spaceId}/budgets")
fun getBudgets(@PathVariable spaceId: String): Mono<List<Budget>> {
return financialService.getBudgets(spaceId)
return spaceService.isValidRequest(spaceId).flatMap {
financialService.getBudgets(spaceId)
}
}
@GetMapping("/{spaceId}/budgets/{id}")
@@ -104,7 +106,7 @@ class SpaceController(
@RequestBody budgetCreationDTO: BudgetCreationDTO,
): Mono<Budget> {
return spaceService.isValidRequest(spaceId).flatMap {
financialService.createBudget(spaceId, budgetCreationDTO.budget, budgetCreationDTO.createRecurrent)
financialService.createBudget(it, budgetCreationDTO.budget, budgetCreationDTO.createRecurrent)
}
}
@@ -124,7 +126,7 @@ class SpaceController(
@RequestBody limit: LimitValue,
): Mono<BudgetCategory> {
return spaceService.isValidRequest(spaceId).flatMap {
financialService.setCategoryLimit(it.id!!,budgetId, catId, limit.limit)
financialService.setCategoryLimit(it.id!!, budgetId, catId, limit.limit)
}
}
@@ -177,7 +179,7 @@ class SpaceController(
@PostMapping("/{spaceId}/transactions")
fun createTransaction(@PathVariable spaceId: String, @RequestBody transaction: Transaction): Mono<Transaction> {
return spaceService.isValidRequest(spaceId).flatMap {
financialService.createTransaction(spaceId, transaction)
financialService.createTransaction(it, transaction)
}
}
@@ -219,7 +221,7 @@ class SpaceController(
}
@GetMapping("/{spaceId}/categories/types")
fun getCategoriesTypes(): ResponseEntity<Any> {
fun getCategoriesTypes(@PathVariable spaceId: String): ResponseEntity<Any> {
return try {
ResponseEntity.ok(categoryService.getCategoryTypes())
} catch (e: Exception) {
@@ -238,15 +240,43 @@ class SpaceController(
}
@PutMapping("/{spaceId}/{categoryId}")
fun editCategory(@PathVariable categoryId: String, @RequestBody category: Category): Mono<Category> {
return categoryService.editCategory(category)
@PutMapping("/{spaceId}/categories/{categoryId}")
fun editCategory(
@PathVariable categoryId: String,
@RequestBody category: Category,
@PathVariable spaceId: String
): Mono<Category> {
return spaceService.isValidRequest(spaceId).flatMap {
categoryService.editCategory(it, category)
}
}
@DeleteMapping("/{spaceId}/categories/{categoryId}")
fun deleteCategory(@PathVariable categoryId: String, @PathVariable spaceId: String): Mono<String> {
return spaceService.isValidRequest(spaceId).flatMap {
categoryService.deleteCategory(it, categoryId)
}
}
@GetMapping("/by-month")
fun getCategoriesSumsByMonths(): Mono<List<Document>> {
return financialService.getCategorySumsPipeline(LocalDate.of(2024, 8, 1), LocalDate.of(2025, 1, 12))
@GetMapping("/{spaceId}/categories/tags")
fun getTags(@PathVariable spaceId: String): Mono<List<Tag>> {
return spaceService.isValidRequest(spaceId).flatMap {
spaceService.getTags(it)
}
}
@PostMapping("/{spaceId}/categories/tags")
fun createTags(@PathVariable spaceId: String, @RequestBody tag: Tag): Mono<Tag> {
return spaceService.isValidRequest(spaceId).flatMap {
spaceService.createTag(it, tag)
}
}
@DeleteMapping("/{spaceId}/categories/tags/{tagId}")
fun deleteTags(@PathVariable spaceId: String, @PathVariable tagId: String): Mono<Void> {
return spaceService.isValidRequest(spaceId).flatMap {
spaceService.deleteTag(it, tagId)
}
}
@GetMapping("/{spaceId}/analytics/by-month")
@@ -262,7 +292,7 @@ class SpaceController(
@GetMapping("/{spaceId}/recurrents")
fun getRecurrents(@PathVariable spaceId: String): Mono<List<Recurrent>> {
return spaceService.isValidRequest(spaceId).flatMap {
recurrentService.getRecurrents(it)
recurrentService.getRecurrents(it.id!!)
}
}
@@ -302,8 +332,8 @@ class SpaceController(
}
}
// @GetMapping("/regen")
// fun regenSpaces(): Mono<List<Space>> {
// return spaceService.regenSpaces()
// }
@GetMapping("/regen")
fun regenSpaces(): Mono<Category> {
return spaceService.regenSpaceCategory()
}
}