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:
@@ -19,6 +19,8 @@ import org.springframework.web.bind.annotation.RestController
|
|||||||
* - 全量获取借阅记录
|
* - 全量获取借阅记录
|
||||||
* - 全量搜索借阅记录
|
* - 全量搜索借阅记录
|
||||||
* - 单条借阅详情
|
* - 单条借阅详情
|
||||||
|
* - 手动借阅
|
||||||
|
* - 手动归还
|
||||||
*
|
*
|
||||||
* 全部接口需 admin 角色,由 @RequireRole 切面校验
|
* 全部接口需 admin 角色,由 @RequireRole 切面校验
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -26,4 +26,20 @@ interface AdminBorrowService {
|
|||||||
* @return 所有借阅记录,含关联的图书和用户信息
|
* @return 所有借阅记录,含关联的图书和用户信息
|
||||||
*/
|
*/
|
||||||
fun getAllBorrows(): Result<Any?>
|
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 query 搜索关键词,按书名模糊匹配
|
||||||
|
* @param userId 当前用户的 ID
|
||||||
* @return 匹配的借阅记录列表
|
* @return 匹配的借阅记录列表
|
||||||
*/
|
*/
|
||||||
fun searchMyBorrows(query: String): Result<Any?>
|
fun searchMyBorrows(query: String, userId: Long): Result<Any?>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 查询单条借阅记录
|
* 查询单条借阅记录
|
||||||
* @param borrowId 借阅记录 ID
|
* @param borrowId 借阅记录 ID
|
||||||
|
* @param userId 当前用户的 ID
|
||||||
* @return 借阅记录详情
|
* @return 借阅记录详情
|
||||||
*/
|
*/
|
||||||
fun getOneMyBorrow(borrowId: Long): Result<Any?>
|
fun getOneMyBorrow(borrowId: Long, userId: Long): Result<Any?>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 借书
|
* 借书
|
||||||
* @param bookId 要借的图书 ID
|
* @param bookId 要借的图书 ID
|
||||||
|
* @param userId 当前用户的 ID
|
||||||
* @return 借阅结果
|
* @return 借阅结果
|
||||||
*/
|
*/
|
||||||
fun borrowBook(bookId: Long): Result<Any?>
|
fun borrowBookForMe(bookId: Long, userId: Long): Result<Any?>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 还书
|
* 还书
|
||||||
* @param borrowId 借阅记录 ID
|
* @param borrowId 借阅记录 ID
|
||||||
|
* @param userId 当前用户的 ID
|
||||||
* @return 归还结果
|
* @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)
|
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 列表
|
// 并发查询用户和图书信息,组装为 BorrowInfoVo 列表
|
||||||
private suspend fun buildBorrowVos(
|
private suspend fun buildBorrowVos(
|
||||||
borrows: List<BorrowRecord>,
|
borrows: List<BorrowRecord>,
|
||||||
|
|||||||
@@ -4,25 +4,55 @@ import com.msksbr.bookmgr.service.BorrowService
|
|||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
import com.msksbr.bookmgr.template.Result
|
import com.msksbr.bookmgr.template.Result
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 借阅服务实现(面向普通用户)
|
||||||
|
*/
|
||||||
@Service
|
@Service
|
||||||
class BorrowServiceImpl: BorrowService {
|
class BorrowServiceImpl: BorrowService {
|
||||||
|
/*
|
||||||
|
* 查询当前用户的所有借阅记录
|
||||||
|
*/
|
||||||
override fun getAllMyBorrows(userId: Long): Result<Any?> {
|
override fun getAllMyBorrows(userId: Long): Result<Any?> {
|
||||||
TODO("Not yet implemented")
|
TODO("Not yet implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun searchMyBorrows(query: String): Result<Any?> {
|
/*
|
||||||
|
* 搜索当前用户的借阅记录,按书名模糊匹配
|
||||||
|
*/
|
||||||
|
override fun searchMyBorrows(
|
||||||
|
query: String,
|
||||||
|
userId: Long
|
||||||
|
): Result<Any?> {
|
||||||
TODO("Not yet implemented")
|
TODO("Not yet implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getOneMyBorrow(borrowId: Long): Result<Any?> {
|
/*
|
||||||
|
* 查询单条借阅记录详情
|
||||||
|
*/
|
||||||
|
override fun getOneMyBorrow(
|
||||||
|
borrowId: Long,
|
||||||
|
userId: Long
|
||||||
|
): Result<Any?> {
|
||||||
TODO("Not yet implemented")
|
TODO("Not yet implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun borrowBook(bookId: Long): Result<Any?> {
|
/*
|
||||||
|
* 借书
|
||||||
|
*/
|
||||||
|
override fun borrowBookForMe(
|
||||||
|
bookId: Long,
|
||||||
|
userId: Long
|
||||||
|
): Result<Any?> {
|
||||||
TODO("Not yet implemented")
|
TODO("Not yet implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun returnBook(borrowId: Long): Result<Any?> {
|
/*
|
||||||
|
* 还书
|
||||||
|
*/
|
||||||
|
override fun returnBookForMe(
|
||||||
|
borrowId: Long,
|
||||||
|
userId: Long
|
||||||
|
): Result<Any?> {
|
||||||
TODO("Not yet implemented")
|
TODO("Not yet implemented")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user