-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add userService and its unit tests
- Loading branch information
Showing
7 changed files
with
663 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
app/src/main/kotlin/io/sakurasou/exception/service/user/UserDeleteFailedException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package io.sakurasou.exception.service.user | ||
|
||
import io.sakurasou.exception.ServiceThrowable | ||
|
||
/** | ||
* @author Shiina Kin | ||
* 2024/9/25 12:44 | ||
*/ | ||
class UserDeleteFailedException( | ||
cause: ServiceThrowable? = null | ||
) : ServiceThrowable() { | ||
override val code: Int | ||
get() = 4000 | ||
override var message: String = "User Delete Failed" | ||
|
||
init { | ||
message = (message + (cause?.let { ", " + it.message } ?: "")) | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
app/src/main/kotlin/io/sakurasou/exception/service/user/UserInsertFailedException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package io.sakurasou.exception.service.user | ||
|
||
import io.sakurasou.exception.ServiceThrowable | ||
|
||
/** | ||
* @author Shiina Kin | ||
* 2024/9/25 12:44 | ||
*/ | ||
class UserInsertFailedException( | ||
cause: ServiceThrowable? = null, | ||
reason: String? = null | ||
) : ServiceThrowable() { | ||
override val code: Int | ||
get() = 4000 | ||
override var message: String = "User Insert Failed" | ||
|
||
init { | ||
message += if (cause != null) ", ${cause.message}" else if (reason != null) ", $reason" else "" | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
app/src/main/kotlin/io/sakurasou/exception/service/user/UserUpdateFailedException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package io.sakurasou.exception.service.user | ||
|
||
import io.sakurasou.exception.ServiceThrowable | ||
|
||
/** | ||
* @author Shiina Kin | ||
* 2024/9/25 12:44 | ||
*/ | ||
class UserUpdateFailedException( | ||
cause: ServiceThrowable? = null | ||
) : ServiceThrowable() { | ||
override val code: Int | ||
get() = 4000 | ||
override var message: String = "User Update Failed" | ||
|
||
init { | ||
message = (message + (cause?.let { ", " + it.message } ?: "")) | ||
} | ||
} |
13 changes: 12 additions & 1 deletion
13
app/src/main/kotlin/io/sakurasou/service/user/UserService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,22 @@ | ||
package io.sakurasou.service.user | ||
|
||
import io.sakurasou.controller.request.UserInsertRequest | ||
import io.sakurasou.controller.request.* | ||
import io.sakurasou.controller.vo.PageResult | ||
import io.sakurasou.controller.vo.UserPageVO | ||
import io.sakurasou.controller.vo.UserVO | ||
|
||
/** | ||
* @author ShiinaKin | ||
* 2024/9/5 15:30 | ||
*/ | ||
interface UserService { | ||
suspend fun saveUser(userInsertRequest: UserInsertRequest) | ||
suspend fun saveUserManually(userManageInsertRequest: UserManageInsertRequest) | ||
suspend fun deleteUser(id: Long) | ||
suspend fun patchSelf(id: Long, patchRequest: UserSelfPatchRequest) | ||
suspend fun patchUser(id: Long, patchRequest: UserManagePatchRequest) | ||
suspend fun banUser(id: Long) | ||
suspend fun unbanUser(id: Long) | ||
suspend fun fetchUser(id: Long): UserVO | ||
suspend fun pageUsers(pageRequest: PageRequest): PageResult<UserPageVO> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.