From b777225bd2e211dee3dd09fa53f9bad60ea4b036 Mon Sep 17 00:00:00 2001 From: SLMS Development Team Date: Tue, 2 Dec 2025 12:12:24 +0800 Subject: [PATCH] =?UTF-8?q?feat(v1.5.0):=20=E9=80=9A=E7=9F=A5=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E4=B8=8EAI=E5=A2=9E=E5=BC=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增服务: - NotificationService 多渠道通知服务 - 支持短信/邮件/微信/站内信/电话 - 借阅成功/归还提醒/逾期通知/罚款通知 - 预约到书/续借成功/AI推荐等通知类型 - ReservationService 预约管理服务 - 图书预约/取消预约 - 预约队列管理 - 到期自动处理 - LoanHistoryService 借阅历史服务 - 借阅操作历史记录 - 续借功能(最多1次,延期14天) - 罚款计算(每日0.5元) AI增强 (SmartAIService): - 用户借阅行为分析 - 逾期风险预测 - 智能通知内容生成 - 最佳通知时机建议 Web页面: - /notifications - 通知中心 - /history - 借阅历史 - /reservations - 预约管理 - 续借功能集成 导航栏更新: - 添加预约/历史/通知入口 --- .../backend/controller/WebController.java | 71 ++++ .../resources/templates/fragments/layout.html | 5 +- .../src/main/resources/templates/history.html | 149 +++++++ .../resources/templates/notifications.html | 121 ++++++ .../resources/templates/reservations.html | 147 +++++++ .../com/smartlibrary/ai/SmartAIService.java | 173 ++++++++ .../service/LoanHistoryService.java | 363 ++++++++++++++++ .../service/NotificationService.java | 396 ++++++++++++++++++ .../service/ReservationService.java | 358 ++++++++++++++++ 9 files changed, 1782 insertions(+), 1 deletion(-) create mode 100644 backend/src/main/resources/templates/history.html create mode 100644 backend/src/main/resources/templates/notifications.html create mode 100644 backend/src/main/resources/templates/reservations.html create mode 100644 core/src/main/java/com/smartlibrary/service/LoanHistoryService.java create mode 100644 core/src/main/java/com/smartlibrary/service/NotificationService.java create mode 100644 core/src/main/java/com/smartlibrary/service/ReservationService.java diff --git a/backend/src/main/java/com/smartlibrary/backend/controller/WebController.java b/backend/src/main/java/com/smartlibrary/backend/controller/WebController.java index 9962207..7c972ef 100644 --- a/backend/src/main/java/com/smartlibrary/backend/controller/WebController.java +++ b/backend/src/main/java/com/smartlibrary/backend/controller/WebController.java @@ -4,6 +4,9 @@ import com.smartlibrary.model.Book; import com.smartlibrary.model.Loan; import com.smartlibrary.service.BookService; import com.smartlibrary.service.StatisticsService; +import com.smartlibrary.service.NotificationService; +import com.smartlibrary.service.LoanHistoryService; +import com.smartlibrary.service.ReservationService; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.*; @@ -296,6 +299,74 @@ public class WebController { return statisticsService.getMonthlyBorrowTrend(12); } + // ========== v1.5.0 通知与历史 ========== + + /** + * 用户通知中心页面 + */ + @GetMapping("/notifications") + public String notifications(@RequestParam(defaultValue = "GUEST") String userId, Model model) { + NotificationService notificationService = new NotificationService(); + model.addAttribute("notifications", notificationService.getUserNotifications(userId)); + model.addAttribute("unreadCount", notificationService.getUnreadCount(userId)); + model.addAttribute("userId", userId); + return "notifications"; + } + + /** + * 借阅历史页面 + */ + @GetMapping("/history") + public String loanHistory(@RequestParam(defaultValue = "GUEST") String userId, Model model) { + LoanHistoryService historyService = new LoanHistoryService(); + model.addAttribute("history", historyService.getUserHistory(userId)); + model.addAttribute("totalFine", historyService.getTotalFine(userId)); + model.addAttribute("userId", userId); + return "history"; + } + + /** + * 预约管理页面 + */ + @GetMapping("/reservations") + public String reservations(@RequestParam(defaultValue = "GUEST") String userId, Model model) { + ReservationService reservationService = new ReservationService(); + model.addAttribute("reservations", reservationService.getUserReservations(userId)); + model.addAttribute("userId", userId); + model.addAttribute("books", bookService.findAllBooks()); + return "reservations"; + } + + /** + * 预约图书 + */ + @PostMapping("/reservations/add") + public String addReservation(@RequestParam String bookId, @RequestParam String userId) { + ReservationService reservationService = new ReservationService(); + reservationService.reserveBook(bookId, userId); + return "redirect:/reservations?userId=" + userId + "&success=true"; + } + + /** + * 取消预约 + */ + @PostMapping("/reservations/cancel/{id}") + public String cancelReservation(@PathVariable String id, @RequestParam String userId) { + ReservationService reservationService = new ReservationService(); + reservationService.cancelReservation(id); + return "redirect:/reservations?userId=" + userId + "&cancelled=true"; + } + + /** + * 续借图书 + */ + @PostMapping("/loans/renew/{loanId}") + public String renewLoan(@PathVariable String loanId) { + LoanHistoryService historyService = new LoanHistoryService(); + historyService.renewLoan(loanId); + return "redirect:/loans?renewed=true"; + } + /** * 切换端说明页面 */ diff --git a/backend/src/main/resources/templates/fragments/layout.html b/backend/src/main/resources/templates/fragments/layout.html index c804dc8..f4da0d1 100644 --- a/backend/src/main/resources/templates/fragments/layout.html +++ b/backend/src/main/resources/templates/fragments/layout.html @@ -12,7 +12,10 @@ - + + + + diff --git a/backend/src/main/resources/templates/history.html b/backend/src/main/resources/templates/history.html new file mode 100644 index 0000000..e24f50a --- /dev/null +++ b/backend/src/main/resources/templates/history.html @@ -0,0 +1,149 @@ + + + + + + 借阅历史 - MCSLMS v1.5.0 + + + + +