Full-stack Kotlin application with Android frontend and Spring Boot backend
@RestController
@RequestMapping("/api/users")
class UserController(private val userService: UserService) {
@GetMapping
suspend fun getAll(): List<UserDto> =
userService.findAll()
@PostMapping
suspend fun create(@RequestBody request: CreateUserRequest): UserDto =
userService.create(request)
@GetMapping("/{id}")
suspend fun getById(@PathVariable id: Long): UserDto =
userService.findById(id)
@PutMapping("/{id}")
suspend fun update(
@PathVariable id: Long,
@RequestBody request: UpdateUserRequest
): UserDto = userService.update(id, request)
}