From e238ee257a5b0cfd11ff76f5eae473a0219b9583 Mon Sep 17 00:00:00 2001 From: Chantha Date: Fri, 8 May 2020 17:01:07 +0700 Subject: [PATCH] start api with kotlin --- mini/src/main/kotlin/com/chantha/mini/repo/UserRepo.kt | 2 ++ mini/src/main/kotlin/com/chantha/mini/service/UserService.kt | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/mini/src/main/kotlin/com/chantha/mini/repo/UserRepo.kt b/mini/src/main/kotlin/com/chantha/mini/repo/UserRepo.kt index 38e3475..4300db9 100644 --- a/mini/src/main/kotlin/com/chantha/mini/repo/UserRepo.kt +++ b/mini/src/main/kotlin/com/chantha/mini/repo/UserRepo.kt @@ -10,4 +10,6 @@ interface UserRepo : JpaRepository { @Query("SELECT * FROM user_dto WHERE firstName=?1 AND lastName=?2",nativeQuery = true) fun findByFirstnameAndLastname(firstName:String?="",lastName:String?=""):UserDto + @Query("SELECT * FROM user_dto",nativeQuery = true) + fun findAllRecord():List } \ No newline at end of file diff --git a/mini/src/main/kotlin/com/chantha/mini/service/UserService.kt b/mini/src/main/kotlin/com/chantha/mini/service/UserService.kt index b92ccc4..ed0a8ca 100644 --- a/mini/src/main/kotlin/com/chantha/mini/service/UserService.kt +++ b/mini/src/main/kotlin/com/chantha/mini/service/UserService.kt @@ -12,6 +12,6 @@ class UserService @Autowired constructor(private val userRepo: UserRepo) { return userRepo.findByFirstnameAndLastname(firstName,lastName) } fun findAllRecord():List{ - return userRepo.findAll() + return userRepo.findAllRecord() } } \ No newline at end of file