feat(service): add service implementations for borrow and book queries

- Add AdminBorrowServiceImpl with search and getAllBorrows stubs
- Add BorrowServiceImpl with borrow record query stubs
- Add getAllBooks and getAllBorrows to service interfaces
- Mark dashboard components for future service decomposition
This commit is contained in:
2026-05-23 00:51:59 +08:00
parent a489d4e91e
commit 547caaa23b
8 changed files with 54 additions and 0 deletions
@@ -7,6 +7,7 @@ import org.springframework.web.bind.annotation.RestController
* 路径前缀(待定):/api/admin/borrows
*
* 计划接口:
* - 全量获取借阅记录
* - 全量搜索借阅记录
*/
@RestController
@@ -19,6 +19,8 @@ import org.springframework.web.bind.annotation.RestController
* getAllBooks — 无注解,游客 / 用户 / admin 均可
* getAllBorrowRecords — @RequireRole("admin"),仅管理员
*/
// @TODO:拆分到各自的服务中
@RestController
@RequestMapping("/api/dashboard")
class DashBoardController(
@@ -2,4 +2,5 @@ package com.msksbr.bookmgr.service
interface AdminBorrowService {
fun searchBorrows(query: String): Result<Any?>
fun getAllBorrows(): Result<Any?>
}
@@ -13,10 +13,12 @@ interface BookService {
* @return 搜索结果列表,无匹配时返回 404
*/
fun searchBook(query: String): Result<Any?>
/*
* 根据 ID 查询单本图书
* @param id 图书 ID,必须为正整数
* @return 图书实体,不存在时返回 404
*/
fun getOneBook(id: Long): Result<Any?>
fun getAllBooks(): Result<Any?>
}
@@ -0,0 +1,15 @@
package com.msksbr.bookmgr.service.impl
import com.msksbr.bookmgr.service.AdminBorrowService
import org.springframework.stereotype.Service
@Service
class AdminBorrowServiceImpl : AdminBorrowService {
override fun searchBorrows(query: String): Result<Any?> {
TODO("Not yet implemented")
}
override fun getAllBorrows(): Result<Any?> {
TODO("Not yet implemented")
}
}
@@ -49,4 +49,8 @@ class BookServiceImpl(private val bookMapper: BookMapper) : BookService {
log.info("[Book] getOne: found {}, author={}", result.name, result.author)
return Result.success(result)
}
override fun getAllBooks(): Result<Any?> {
TODO("Not yet implemented")
}
}
@@ -0,0 +1,27 @@
package com.msksbr.bookmgr.service.impl
import com.msksbr.bookmgr.service.BorrowService
import org.springframework.stereotype.Service
@Service
class BorrowServiceImpl: BorrowService {
override fun getAllMyBorrows(userId: Long): Result<Any?> {
TODO("Not yet implemented")
}
override fun searchMyBorrows(query: String): Result<Any?> {
TODO("Not yet implemented")
}
override fun getOneBorrow(borrowId: Long): Result<Any?> {
TODO("Not yet implemented")
}
override fun borrowBook(bookId: Long): Result<Any?> {
TODO("Not yet implemented")
}
override fun returnBook(borrowId: Long): Result<Any?> {
TODO("Not yet implemented")
}
}
@@ -11,6 +11,8 @@ import org.springframework.stereotype.Service
* 仪表盘服务实现
* 聚合 BookMapper 和 BorrowRecordMapper 提供全量数据查询
*/
// @TODO: 拆分到book和admin borrow服务中
@Service
class DashBoardServiceImpl(
private val bookMapper: BookMapper,