Draft
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题与影响
当前项目里已经存在馆员侧的借还书能力,但管理员端缺少“接收还书”入口,管理员无法在自己的控制台里处理归还流程。对使用者的直接影响是,管理员即使有权限查看和管理系统,也不能在后台完成接收还书并同步恢复副本可借状态,导致这部分流程只能绕到别的角色入口处理。
根因
这个仓库的借阅实现存在新旧两套模型并存的问题。旧代码里还有按
Book.availableCopies和bookId操作的逻辑,但当前 Prisma 的真实模型已经是Loan.copyId + Copy.status。如果继续在管理员端复用旧链路,只会把错误模型继续扩散,功能表面上加上去了,底层状态却会继续错。修复
这次改动没有去重写整套借阅系统,而是只为管理员端新增一条独立、可落在当前模型上的还书链路:
loans.js。GET /api/admin/loans/active只返回未归还借阅,并带上管理员页面需要的读者、副本、图书信息。POST /api/admin/loans/:loanId/receive-return只允许管理员访问,按Loan.copyId查找借阅,在事务里同时更新归还时间、罚款、Copy.status = AVAILABLE,并记录管理员审计日志。结果
管理员现在可以直接在自己的控制台里完成接收还书,归还后副本状态会同步恢复为可借,逾期罚款也会沿用现有配置计算并落库,同时保留管理员操作日志。
验证
我完成了后端新增路由和入口文件的语法级检查,以及补丁格式检查。
由于当前仓库依赖安装环境不稳定,这次没有完成完整的前端构建和端到端联调,所以这部分没有伪造通过结果。