new updated

This commit is contained in:
xds
2025-02-11 13:46:50 +03:00
parent 510f527bec
commit c1d7e42a29
11 changed files with 3014 additions and 1220 deletions

View File

@@ -16,49 +16,49 @@ import space.luminic.budgerapp.models.Budget
import space.luminic.budgerapp.models.BudgetDTO
import space.luminic.budgerapp.models.Transaction
import space.luminic.budgerapp.models.Warn
import space.luminic.budgerapp.services.BudgetService
import space.luminic.budgerapp.services.FinancialService
import java.time.LocalDate
@RestController
@RequestMapping("/budgets")
class BudgetController(
val budgetService: BudgetService
val financialService: FinancialService
) {
private val logger = LoggerFactory.getLogger(BudgetController::class.java)
@GetMapping
fun getBudgets(): Mono<MutableList<Budget>> {
return budgetService.getBudgets()
return financialService.getBudgets()
}
@GetMapping("/{id}")
fun getBudget(@PathVariable id: String): Mono<BudgetDTO> {
logger.info("here }")
return budgetService.getBudget(id)
return financialService.getBudget(id)
}
@GetMapping("/by-dates")
fun getBudgetByDate(@RequestParam date: LocalDate): ResponseEntity<Any> {
return ResponseEntity.ok(budgetService.getBudgetByDate(date))
return ResponseEntity.ok(financialService.getBudgetByDate(date))
}
@GetMapping("/{id}/categories")
fun getBudgetCategories(@PathVariable id: String): ResponseEntity<Any> {
return ResponseEntity.ok(budgetService.getBudgetCategories(id))
return ResponseEntity.ok(financialService.getBudgetCategories(id))
}
@GetMapping("/{id}/transactions")
fun getBudgetTransactions(@PathVariable id: String):Mono<Map<String,List<Transaction>>> {
return budgetService.getBudgetTransactionsByType(id)
return financialService.getBudgetTransactionsByType(id)
}
@PostMapping("/")
fun createBudget(@RequestBody budgetCreationDTO: BudgetCreationDTO): Mono<Budget> {
return budgetService.createBudget(
return financialService.createBudget(
budgetCreationDTO.budget,
budgetCreationDTO.createRecurrent
)
@@ -66,7 +66,7 @@ class BudgetController(
@DeleteMapping("/{id}")
fun deleteBudget(@PathVariable id: String): Mono<Void> {
return budgetService.deleteBudget(id)
return financialService.deleteBudget(id)
}
@PostMapping("/{budgetId}/categories/{catId}/limit")
@@ -76,7 +76,7 @@ class BudgetController(
@RequestBody limit: LimitValue,
): ResponseEntity<Any> {
return try {
ResponseEntity.ok(budgetService.setCategoryLimit(budgetId, catId, limit.limit))
ResponseEntity.ok(financialService.setCategoryLimit(budgetId, catId, limit.limit))
} catch (e: Exception) {
ResponseEntity.badRequest().body(e.message)
}
@@ -86,14 +86,17 @@ class BudgetController(
@GetMapping("/{id}/warns")
fun budgetWarns(@PathVariable id: String, @RequestParam hidden: Boolean? = null): Mono<List<Warn>> {
return budgetService.getWarns(id, hidden)
return financialService.getWarns(id, hidden)
}
@PostMapping("/{id}/warns/{warnId}/hide")
fun setWarnHide(@PathVariable id: String, @PathVariable warnId: String): Mono<Warn> {
return budgetService.hideWarn( warnId)
return financialService.hideWarn( warnId)
}
@GetMapping("/regencats")
fun regenCats(): Mono<Void>{
return financialService.regenCats()
}
data class LimitValue(