33 lines
1.1 KiB
Kotlin
33 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.security.access.prepost.PreAuthorize
|
|
import org.springframework.stereotype.Controller
|
|
import org.springframework.web.bind.annotation.*
|
|
import java.util.*
|
|
|
|
@RestController
|
|
class UserController @Autowired constructor(private val userService: UserService){
|
|
|
|
@GetMapping("/api/user/name/{firstName}/{lastName}")
|
|
fun findByFirstNameAndLastName(@PathVariable firstName:String ?="",@PathVariable lastName:String?=""):UserDto{
|
|
return userService.findByFirstNameAndLastName(firstName,lastName)
|
|
}
|
|
|
|
|
|
@PreAuthorize("hasRole('ADMIN')")
|
|
@GetMapping("/api/user")
|
|
fun findAllRecord():List<UserDto>{
|
|
return userService.findAllRecord().orEmpty()
|
|
}
|
|
|
|
@RequestMapping("/api/user/{id}")
|
|
fun findByOneRecord(@PathVariable uid:String): List<UserDto> {
|
|
//error Path Varaible Missing URI
|
|
print(uid)
|
|
return userService.findByOneRecord(1)
|
|
}
|
|
} |