From a041103a92edbcb0345dc182d6c8a360c303fc35 Mon Sep 17 00:00:00 2001 From: msksbr515 Date: Wed, 13 May 2026 17:22:51 +0800 Subject: [PATCH] feat(api): add controller layer and auth service stubs - Add AdminBookController, AdminBorrowController, BookController, BorrowController, and DashBoardController stubs - Implement AuthController with login endpoint - Add AuthService interface and AuthServiceImpl stub --- .../bookmgr/controller/AdminBookController.kt | 7 ++++++ .../controller/AdminBorrowController.kt | 7 ++++++ .../bookmgr/controller/AuthController.kt | 24 +++++++++++++++++++ .../bookmgr/controller/BookController.kt | 7 ++++++ .../bookmgr/controller/BorrowController.kt | 7 ++++++ .../bookmgr/controller/DashBoardController.kt | 7 ++++++ .../com/msksbr/bookmgr/service/AuthService.kt | 5 ++++ .../bookmgr/service/impl/AuthServiceImpl.kt | 11 +++++++++ 8 files changed, 75 insertions(+) create mode 100644 src/main/kotlin/com/msksbr/bookmgr/controller/AdminBookController.kt create mode 100644 src/main/kotlin/com/msksbr/bookmgr/controller/AdminBorrowController.kt create mode 100644 src/main/kotlin/com/msksbr/bookmgr/controller/AuthController.kt create mode 100644 src/main/kotlin/com/msksbr/bookmgr/controller/BookController.kt create mode 100644 src/main/kotlin/com/msksbr/bookmgr/controller/BorrowController.kt create mode 100644 src/main/kotlin/com/msksbr/bookmgr/controller/DashBoardController.kt create mode 100644 src/main/kotlin/com/msksbr/bookmgr/service/AuthService.kt create mode 100644 src/main/kotlin/com/msksbr/bookmgr/service/impl/AuthServiceImpl.kt diff --git a/src/main/kotlin/com/msksbr/bookmgr/controller/AdminBookController.kt b/src/main/kotlin/com/msksbr/bookmgr/controller/AdminBookController.kt new file mode 100644 index 0000000..5b3e480 --- /dev/null +++ b/src/main/kotlin/com/msksbr/bookmgr/controller/AdminBookController.kt @@ -0,0 +1,7 @@ +package com.msksbr.bookmgr.controller + +import org.springframework.web.bind.annotation.RestController + +@RestController +class AdminBookController { +} \ No newline at end of file diff --git a/src/main/kotlin/com/msksbr/bookmgr/controller/AdminBorrowController.kt b/src/main/kotlin/com/msksbr/bookmgr/controller/AdminBorrowController.kt new file mode 100644 index 0000000..aff4ef5 --- /dev/null +++ b/src/main/kotlin/com/msksbr/bookmgr/controller/AdminBorrowController.kt @@ -0,0 +1,7 @@ +package com.msksbr.bookmgr.controller + +import org.springframework.web.bind.annotation.RestController + +@RestController +class AdminBorrowController { +} \ No newline at end of file diff --git a/src/main/kotlin/com/msksbr/bookmgr/controller/AuthController.kt b/src/main/kotlin/com/msksbr/bookmgr/controller/AuthController.kt new file mode 100644 index 0000000..4b9d9a0 --- /dev/null +++ b/src/main/kotlin/com/msksbr/bookmgr/controller/AuthController.kt @@ -0,0 +1,24 @@ +package com.msksbr.bookmgr.controller + +import com.msksbr.bookmgr.service.AuthService +import jakarta.servlet.http.HttpSession +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.web.bind.annotation.PostMapping +import org.springframework.web.bind.annotation.RestController + +// 管理登录、登出 +@RestController +class AuthController( + val authService: AuthService +) { + @PostMapping("/api/auth/login") + fun login(username: String?, password: String?) :String? { + return TODO("提供返回值") + } + @PostMapping("/api/auth/logout") + fun logout(session: HttpSession): String? { + // 直接销毁session + session.invalidate() + return TODO("Need json template") + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/msksbr/bookmgr/controller/BookController.kt b/src/main/kotlin/com/msksbr/bookmgr/controller/BookController.kt new file mode 100644 index 0000000..2db09c3 --- /dev/null +++ b/src/main/kotlin/com/msksbr/bookmgr/controller/BookController.kt @@ -0,0 +1,7 @@ +package com.msksbr.bookmgr.controller + +import org.springframework.web.bind.annotation.RestController + +@RestController +class BookController { +} \ No newline at end of file diff --git a/src/main/kotlin/com/msksbr/bookmgr/controller/BorrowController.kt b/src/main/kotlin/com/msksbr/bookmgr/controller/BorrowController.kt new file mode 100644 index 0000000..e00638a --- /dev/null +++ b/src/main/kotlin/com/msksbr/bookmgr/controller/BorrowController.kt @@ -0,0 +1,7 @@ +package com.msksbr.bookmgr.controller + +import org.springframework.web.bind.annotation.RestController + +@RestController +class BorrowController { +} \ No newline at end of file diff --git a/src/main/kotlin/com/msksbr/bookmgr/controller/DashBoardController.kt b/src/main/kotlin/com/msksbr/bookmgr/controller/DashBoardController.kt new file mode 100644 index 0000000..1e2e882 --- /dev/null +++ b/src/main/kotlin/com/msksbr/bookmgr/controller/DashBoardController.kt @@ -0,0 +1,7 @@ +package com.msksbr.bookmgr.controller + +import org.springframework.web.bind.annotation.RestController + +@RestController +class DashBoardController { +} \ No newline at end of file diff --git a/src/main/kotlin/com/msksbr/bookmgr/service/AuthService.kt b/src/main/kotlin/com/msksbr/bookmgr/service/AuthService.kt new file mode 100644 index 0000000..0ab2058 --- /dev/null +++ b/src/main/kotlin/com/msksbr/bookmgr/service/AuthService.kt @@ -0,0 +1,5 @@ +package com.msksbr.bookmgr.service + +interface AuthService { + fun login(username: String?, password: String?): String? +} \ No newline at end of file diff --git a/src/main/kotlin/com/msksbr/bookmgr/service/impl/AuthServiceImpl.kt b/src/main/kotlin/com/msksbr/bookmgr/service/impl/AuthServiceImpl.kt new file mode 100644 index 0000000..fcacb49 --- /dev/null +++ b/src/main/kotlin/com/msksbr/bookmgr/service/impl/AuthServiceImpl.kt @@ -0,0 +1,11 @@ +package com.msksbr.bookmgr.service.impl + +import com.msksbr.bookmgr.service.AuthService +import org.springframework.stereotype.Service + +@Service +class AuthServiceImpl: AuthService { + override fun login(username: String?, password: String?): String? { + TODO("Not yet implemented") + } +} \ No newline at end of file