Draft
Conversation
…ug prints, needsFollowUp, fragile count SQL; remove debug JSP files; add email UNIQUE constraint Agent-Logs-Url: https://github.com/xiaoyuanhost/PetHospitalManagementSystem/sessions/e5ff2be9-dd00-4adf-b08c-03288c672a43 Co-authored-by: xiaoyuanhost <46616128+xiaoyuanhost@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor project features and fix identified bugs
修复多处 Bug 并清理调试遗留代码
Apr 12, 2026
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.
梳理项目发现多个功能缺陷和安全隐患,集中修复如下。
Bug 修复
AppointmentServlet — 假宠物注入(严重):用户无宠物时,
forwardToAddPage()会注入pet_id=999的虚假宠物,提交预约时触发外键约束错误。改为直接传真实(可能为空)列表。UserServlet.handleRegister() — NPE(高):
password.equals(confirmPassword)在password为null时抛NullPointerException。加前置null检查。UserServiceImpl.updateUser() — 邮箱唯一性校验失效(中):
HealthRecord.needsFollowUp() — 当天复诊漏判(中):
after(now)严格大于,当天到期不显示"需复诊"。改为!before(now)。HealthRecordDaoImpl.findByCondition() — 脆弱的 COUNT SQL(中):用
.replace("SELECT hr.*, p.pet_name, p.pet_type, p.breed", "SELECT COUNT(*)")拼 COUNT 查询,SELECT 子句变更即静默失效。改为单独构建 WHERE 子句,分别组合两条独立查询。信息泄露清理
移除
PetDaoImpl、PetServiceImpl、AppointmentServlet、PetServlet、UserServlet中所有System.out.println("DEBUG: ...")语句,这些语句将用户 ID、宠物信息、SQL 语句等敏感数据打印至服务器日志。数据层修复与清理
init.sql:users.email列补加UNIQUE约束,将唯一性约束下沉到数据库层。debug-pets.jsp、direct-test.jsp、fix-pet-data.jsp、test-basic.jsp、appointment-add-simple.jsp。