+ fixes
This commit is contained in:
@@ -21,5 +21,6 @@ class TelegramBotConfig {
|
|||||||
@ConfigurationProperties(prefix = "telegram.bot")
|
@ConfigurationProperties(prefix = "telegram.bot")
|
||||||
data class TelegramBotProperties(
|
data class TelegramBotProperties(
|
||||||
val username: String,
|
val username: String,
|
||||||
val token: String
|
val token: String,
|
||||||
|
val enable:Int
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,22 +1,35 @@
|
|||||||
package space.luminic.budgerapp.controllers
|
package space.luminic.budgerapp.controllers
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping
|
import org.springframework.web.bind.annotation.DeleteMapping
|
||||||
import org.springframework.web.bind.annotation.GetMapping
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable
|
import org.springframework.web.bind.annotation.PathVariable
|
||||||
import org.springframework.web.bind.annotation.PostMapping
|
|
||||||
import org.springframework.web.bind.annotation.PutMapping
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping
|
import org.springframework.web.bind.annotation.RequestMapping
|
||||||
import org.springframework.web.bind.annotation.RestController
|
import org.springframework.web.bind.annotation.RestController
|
||||||
import reactor.core.publisher.Mono
|
import space.luminic.budgerapp.configs.AuthException
|
||||||
import space.luminic.budgerapp.models.Recurrent
|
import space.luminic.budgerapp.services.AuthService
|
||||||
import space.luminic.budgerapp.services.RecurrentService
|
import space.luminic.budgerapp.services.RecurrentService
|
||||||
|
import space.luminic.budgerapp.services.SpaceService
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/recurrents")
|
@RequestMapping("/spaces/{spaceId}")
|
||||||
class RecurrentController(
|
class RecurrentController(
|
||||||
private val recurrentService: RecurrentService
|
private val recurrentService: RecurrentService,
|
||||||
|
private val authService: AuthService,
|
||||||
|
private val spaceService: SpaceService
|
||||||
){
|
){
|
||||||
|
|
||||||
|
// @DeleteMapping("/recurrents/{recurrentId}")
|
||||||
|
// suspend fun delete(
|
||||||
|
// @PathVariable spaceId: String,
|
||||||
|
// @PathVariable recurrentId: String): String {
|
||||||
|
// val user = authService.getSecurityUser()
|
||||||
|
// val space = spaceService.isValidRequest(spaceId, user)
|
||||||
|
// if (space.owner?.id == user.id) {
|
||||||
|
// recurrentService.deleteRecurrent(recurrentId)
|
||||||
|
// return "Cool"
|
||||||
|
// } else {
|
||||||
|
// throw AuthException("Only owners allowed")
|
||||||
|
// }
|
||||||
|
// }
|
||||||
//
|
//
|
||||||
// @GetMapping("/")
|
// @GetMapping("/")
|
||||||
// fun getRecurrents(): Mono<List<Recurrent>> {
|
// fun getRecurrents(): Mono<List<Recurrent>> {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import org.springframework.http.HttpStatus
|
|||||||
import org.springframework.http.MediaType
|
import org.springframework.http.MediaType
|
||||||
import org.springframework.http.ResponseEntity
|
import org.springframework.http.ResponseEntity
|
||||||
import org.springframework.web.bind.annotation.*
|
import org.springframework.web.bind.annotation.*
|
||||||
|
import space.luminic.budgerapp.configs.AuthException
|
||||||
import space.luminic.budgerapp.controllers.BudgetController.LimitValue
|
import space.luminic.budgerapp.controllers.BudgetController.LimitValue
|
||||||
import space.luminic.budgerapp.controllers.dtos.BudgetCreationDTO
|
import space.luminic.budgerapp.controllers.dtos.BudgetCreationDTO
|
||||||
import space.luminic.budgerapp.models.*
|
import space.luminic.budgerapp.models.*
|
||||||
@@ -357,14 +358,14 @@ class SpaceController(
|
|||||||
return recurrentService.getRecurrentById(space, id).awaitSingle()
|
return recurrentService.getRecurrentById(space, id).awaitSingle()
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/{spaceId}/recurrent")
|
@PostMapping("/{spaceId}/recurrents")
|
||||||
suspend fun createRecurrent(@PathVariable spaceId: String, @RequestBody recurrent: Recurrent): Recurrent {
|
suspend fun createRecurrent(@PathVariable spaceId: String, @RequestBody recurrent: Recurrent): Recurrent {
|
||||||
val user = authService.getSecurityUser()
|
val user = authService.getSecurityUser()
|
||||||
val space = spaceService.isValidRequest(spaceId, user)
|
val space = spaceService.isValidRequest(spaceId, user)
|
||||||
return recurrentService.createRecurrent(space, recurrent).awaitSingle()
|
return recurrentService.createRecurrent(space, recurrent).awaitSingle()
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/{spaceId}/recurrent/{id}")
|
@PutMapping("/{spaceId}/recurrents/{id}")
|
||||||
suspend fun editRecurrent(
|
suspend fun editRecurrent(
|
||||||
@PathVariable spaceId: String,
|
@PathVariable spaceId: String,
|
||||||
@PathVariable id: String,
|
@PathVariable id: String,
|
||||||
@@ -376,11 +377,16 @@ class SpaceController(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@DeleteMapping("/{spaceId}/recurrent/{id}")
|
@DeleteMapping("/{spaceId}/recurrents/{id}")
|
||||||
suspend fun deleteRecurrent(@PathVariable spaceId: String, @PathVariable id: String) {
|
suspend fun deleteRecurrent(@PathVariable spaceId: String, @PathVariable id: String) {
|
||||||
val user = authService.getSecurityUser()
|
val user = authService.getSecurityUser()
|
||||||
spaceService.isValidRequest(spaceId, user)
|
val space = spaceService.isValidRequest(spaceId, user)
|
||||||
recurrentService.deleteRecurrent(id).awaitSingle()
|
if (space.owner?.id == user.id) {
|
||||||
|
recurrentService.deleteRecurrent(id)
|
||||||
|
} else {
|
||||||
|
throw AuthException("Only owners allowed")
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @GetMapping("/regen")
|
// @GetMapping("/regen")
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ class CategoryService(
|
|||||||
}.awaitFirstOrNull() ?: throw NotFoundException("Category not found")
|
}.awaitFirstOrNull() ?: throw NotFoundException("Category not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cacheable(cacheNames = ["categories"])
|
|
||||||
suspend fun getCategories(
|
suspend fun getCategories(
|
||||||
spaceId: String,
|
spaceId: String,
|
||||||
type: String? = null,
|
type: String? = null,
|
||||||
@@ -133,7 +132,6 @@ class CategoryService(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@CacheEvict(cacheNames = ["getAllCategories"], allEntries = true)
|
|
||||||
suspend fun editCategory(space: Space, category: Category): Category {
|
suspend fun editCategory(space: Space, category: Category): Category {
|
||||||
val oldCategory = findCategory(space, id = category.id)
|
val oldCategory = findCategory(space, id = category.id)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package space.luminic.budgerapp.services
|
package space.luminic.budgerapp.services
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.coroutines.reactive.awaitFirstOrNull
|
||||||
import kotlinx.coroutines.reactive.awaitLast
|
import kotlinx.coroutines.reactive.awaitLast
|
||||||
import kotlinx.coroutines.reactive.awaitSingle
|
import kotlinx.coroutines.reactive.awaitSingle
|
||||||
import kotlinx.coroutines.reactor.awaitSingleOrNull
|
import kotlinx.coroutines.reactor.awaitSingleOrNull
|
||||||
@@ -124,8 +125,8 @@ class RecurrentService(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun deleteRecurrent(id: String): Mono<Void> {
|
suspend fun deleteRecurrent(id: String) {
|
||||||
return recurrentRepo.deleteById(id)
|
recurrentRepo.deleteById(id).awaitFirstOrNull()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user