Czesc,
zastanawiam się jak powinna dobrze wygladac 'obsluga' endpointa
mam takie cos:
@PutMapping("/{id}")
fun updateUser(
@PathVariable id: Long,
@RequestParam("email", defaultValue = "") email: String,
@RequestParam("city", defaultValue = "") city: String
): User {
return userRepository.findUserById(id)?.apply {
if (email.isNotBlank()) this.email = email
if (city.isNotBlank()) this.city = city
userRepository.save(this)
} ?: throw NotFoundException("brak takiego usera")
}
//
@ResponseStatus(HttpStatus.NOT_FOUND)
class NotFoundException(message: String) : RuntimeException(message)
Macie jakies sugestie, jak mozna to zrobic lepiej?