24 lines
923 B
Kotlin
24 lines
923 B
Kotlin
package com.chantha.mini.controller
|
|
|
|
import com.chantha.mini.dto.UserDto
|
|
import com.chantha.mini.service.UserService
|
|
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/{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()
|
|
}
|
|
} |