31 lines
1.1 KiB
Kotlin
31 lines
1.1 KiB
Kotlin
package com.chantha.mini.controller
|
|
|
|
import com.chantha.mini.dto.UserDto
|
|
import com.chantha.mini.service.UserService
|
|
import com.fasterxml.jackson.annotation.JsonRootName
|
|
import org.springframework.beans.factory.annotation.Autowired
|
|
import org.springframework.stereotype.Controller
|
|
import org.springframework.web.bind.annotation.GetMapping
|
|
import org.springframework.web.bind.annotation.PathVariable
|
|
import org.springframework.web.bind.annotation.RestController
|
|
|
|
@RestController
|
|
class UserController @Autowired constructor(private val userService: UserService){
|
|
|
|
@GetMapping("/api/user/name/{firstName}/{lastName}")
|
|
fun findByFirstNameAndLastName(@PathVariable firstName:String ?="",@PathVariable lastName:String?=""):UserDto{
|
|
println(lastName+" "+firstName)
|
|
return userService.findByFirstNameAndLastName(firstName,lastName)
|
|
}
|
|
|
|
|
|
@GetMapping("/api/user")
|
|
fun findAllRecord():List<UserDto>{
|
|
return userService.findAllRecord().orEmpty()
|
|
}
|
|
|
|
@GetMapping("/api/user/id/{id}")
|
|
fun findById(@PathVariable Id:Long ):UserDto{
|
|
return userService.findById(Id)
|
|
}
|
|
} |