📜 借阅历史
+ +详情
+⚠️ 待缴罚款
+请尽快处理,避免影响借阅权限
+无待缴罚款
+保持良好的借阅习惯!
+-
+
- + 借阅 + 成功借出图书 + +
- + 归还 + 图书已归还 + +
- + 续借 + 延长借阅期限 + +
- + 逾期 + 超过应还日期 + +
- + 缴费 + 缴纳罚款 + +
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 @@
详情
+请尽快处理,避免影响借阅权限
+保持良好的借阅习惯!
+内容
+当图书被借出时,您可以预约等待
+