feat(admin-borrows): add manual borrow and return stubs with service refactor

- Add borrowBook and returnBook method stubs to AdminBorrowService
- Pass userId parameter to BorrowService methods for context enrichment
- Add KDoc comments to service interfaces and implementations
This commit is contained in:
2026-05-23 13:18:35 +08:00
parent f73e0e3cba
commit 5b3e92209d
5 changed files with 74 additions and 8 deletions
@@ -19,6 +19,8 @@ import org.springframework.web.bind.annotation.RestController
* - 全量获取借阅记录
* - 全量搜索借阅记录
* - 单条借阅详情
* - 手动借阅
* - 手动归还
*
* 全部接口需 admin 角色,由 @RequireRole 切面校验
*/
@@ -26,4 +26,20 @@ interface AdminBorrowService {
* @return 所有借阅记录,含关联的图书和用户信息
*/
fun getAllBorrows(): Result<Any?>
/*
* 管理员手动借书
* @param bookId 要借的图书 ID
* @param userId 借书的用户 ID
* @return 借阅结果
*/
fun borrowBook(bookId: Long, userId: Long): Result<Any?>
/*
* 管理员手动还书
* @param bookId 要还的图书 ID
* @param userId 还书的用户 ID
* @return 归还结果
*/
fun returnBook(bookId: Long, userId: Long): Result<Any?>
}
@@ -17,28 +17,32 @@ interface BorrowService {
/*
* 搜索当前用户的借阅记录
* @param query 搜索关键词,按书名模糊匹配
* @param userId 当前用户的 ID
* @return 匹配的借阅记录列表
*/
fun searchMyBorrows(query: String): Result<Any?>
fun searchMyBorrows(query: String, userId: Long): Result<Any?>
/*
* 查询单条借阅记录
* @param borrowId 借阅记录 ID
* @param userId 当前用户的 ID
* @return 借阅记录详情
*/
fun getOneMyBorrow(borrowId: Long): Result<Any?>
fun getOneMyBorrow(borrowId: Long, userId: Long): Result<Any?>
/*
* 借书
* @param bookId 要借的图书 ID
* @param userId 当前用户的 ID
* @return 借阅结果
*/
fun borrowBook(bookId: Long): Result<Any?>
fun borrowBookForMe(bookId: Long, userId: Long): Result<Any?>
/*
* 还书
* @param borrowId 借阅记录 ID
* @param userId 当前用户的 ID
* @return 归还结果
*/
fun returnBook(borrowId: Long): Result<Any?>
fun returnBookForMe(borrowId: Long, userId: Long): Result<Any?>
}
@@ -127,6 +127,20 @@ class AdminBorrowServiceImpl(
return Result.success(result)
}
/*
* 管理员手动借书
*/
override fun borrowBook(bookId: Long, userId: Long): Result<Any?> {
TODO("Not yet implemented")
}
/*
* 管理员手动还书
*/
override fun returnBook(bookId: Long, userId: Long): Result<Any?> {
TODO("Not yet implemented")
}
// 并发查询用户和图书信息,组装为 BorrowInfoVo 列表
private suspend fun buildBorrowVos(
borrows: List<BorrowRecord>,
@@ -4,25 +4,55 @@ import com.msksbr.bookmgr.service.BorrowService
import org.springframework.stereotype.Service
import com.msksbr.bookmgr.template.Result
/*
* 借阅服务实现(面向普通用户)
*/
@Service
class BorrowServiceImpl: BorrowService {
/*
* 查询当前用户的所有借阅记录
*/
override fun getAllMyBorrows(userId: Long): Result<Any?> {
TODO("Not yet implemented")
}
override fun searchMyBorrows(query: String): Result<Any?> {
/*
* 搜索当前用户的借阅记录,按书名模糊匹配
*/
override fun searchMyBorrows(
query: String,
userId: Long
): Result<Any?> {
TODO("Not yet implemented")
}
override fun getOneMyBorrow(borrowId: Long): Result<Any?> {
/*
* 查询单条借阅记录详情
*/
override fun getOneMyBorrow(
borrowId: Long,
userId: Long
): Result<Any?> {
TODO("Not yet implemented")
}
override fun borrowBook(bookId: Long): Result<Any?> {
/*
* 借书
*/
override fun borrowBookForMe(
bookId: Long,
userId: Long
): Result<Any?> {
TODO("Not yet implemented")
}
override fun returnBook(borrowId: Long): Result<Any?> {
/*
* 还书
*/
override fun returnBookForMe(
borrowId: Long,
userId: Long
): Result<Any?> {
TODO("Not yet implemented")
}
}