摘要
本研究旨在設計并實作一個基于Java, Spring Boot和HTML的實驗室預約管理系統,以解決實驗室資源配置設定不均、管理混亂和預約流程繁瑣等問題。系統采用B/S架構設計,後端使用Spring Boot架構進行開發,前端使用HTML進行頁面設計,實作了使用者登入、實驗室預約、檢視預約狀态以及管理者對實驗室的管理等功能。
首先,系統通過Spring Boot實作了快速開發和部署,簡化了項目的配置和管理。同時,利用Spring Boot的自動裝配特性,友善地內建了MyBatis、MySQL資料庫等技術,實作了資料持久化存儲。
其次,系統前端采用HTML進行頁面設計,結合CSS和JavaScript實作了友好的使用者界面。使用者可以通過網頁進行實驗室預約,檢視預約狀态,取消預約等操作。同時,系統提供了管理者角色,管理者可以對實驗室進行管理,如添加、修改實驗室資訊,檢視所有預約記錄等。
最後,系統采用了分層架構設計,将業務邏輯層、資料通路層和表示層分離,降低了子產品間的耦合度,提高了代碼的可維護性和可擴充性。此外,系統還實作了權限控制和異常處理機制,保證了系統的安全性和穩定性。
總之,本研究設計的基于Java, Spring Boot和HTML的實驗室預約管理系統,不僅解決了實驗室資源配置設定和管理的問題,還為使用者提供了便捷的預約服務,具有較高的實用價值和推廣前景。
實作的功能
管理者、教師、學生三種角色;
管理者:使用者管理(學生管理、教師管理)、實驗室管理、教務管理(班級管理、課程管理)、預約(個人預約、教師預約、預約清單、稽核清單);
學生:實驗室清單、預約(我的預約、個人預約);
教師:班級管理、實驗室清單、預約(教師預約、我的預約)。
使用者在預約的時候可以看到實驗室的預約人數狀态是否滿了,也可以在實驗室清單檢視預約狀态。
使用的技術
後端:JAVA開發語言,SpringBoot架構,MySql資料庫,Maven;
前端:layUI架構、HTML頁面。
部分代碼展示
public String toTeacherIndexHtml(Model model) {
Map weeks = ConstantUtils.initWeeks();
Map days = ConstantUtils.initDays();
Map parts = ConstantUtils.initParts();
model.addAttribute("weeks", weeks);
model.addAttribute("days", days);
model.addAttribute("parts", parts);
return "/reservation/teacher/index.html";
}
@GetMapping("/individual/index.html")
public String toIndividualIndexHtml(Model model) {
Map weeks = ConstantUtils.initWeeks();
Map days = ConstantUtils.initDays();
Map parts = ConstantUtils.initParts();
model.addAttribute("weeks", weeks);
model.addAttribute("days", days);
model.addAttribute("parts", parts);
return "/reservation/individual/index.html";
}
@GetMapping("/index.html")
public String toReservationIndexHtml() {
return "/reservation/index.html";
}
@GetMapping("/lib")
@ResponseBody
public ResultVO getLibList(int startWeek, int day, int part) {
List<Lib> labList = libService.getCurrentlyUnusedLabList(startWeek, day, part);
return ResultVO.SUCCESS(labList);
}
@GetMapping("/libNum")
@ResponseBody
public ResultVO getLibList() {
List<Lib> labList = libService.getCurrentlyLabUsedNumList();
return ResultVO.SUCCESS(labList);
}
@GetMapping("/grade")
@ResponseBody
public ResultVO getGradeList(int teacherId,int startWeek, int day, int part) {
List<Grade> gradeList = gradeService.getCurrentGradeOfTeacher(teacherId, startWeek, day, part);
return ResultVO.SUCCESS(gradeList);
}
/**
* 添加預約
* */
@PostMapping("/teacher")
@ResponseBody
public ResultVO addReservation(Reservation reservation, HttpSession session) {
long userId = (long)session.getAttribute("userInfo");
reservation.setUserId(userId);
reservationService.save(reservation);
return ResultVO.SUCCESS();
}
/**
* 擷取所有預約單
* */
@GetMapping
@ResponseBody
public ResultVO getReservationList(@RequestParam(value = "page", defaultValue = "1") Integer page,
@RequestParam(value = "limit", defaultValue = "10") Integer limit) {
page -= 1;
long total = reservationService.count();
List<Reservation> reservationList = reservationService.getReservationList(page,limit);
HashMap<String,Object> data = new HashMap<>();
data.put("total",total);
data.put("reservationList",reservationList);
return ResultVO.SUCCESS(0,data);
}
/**
* 擷取個人預約單
* */
@GetMapping("/individual/mine")
@ResponseBody
public ResultVO getStudentReservationList(@RequestParam(value = "page", defaultValue = "1") Integer page,
@RequestParam(value = "limit", defaultValue = "10") Integer limit,
HttpSession session) {
page -= 1;
long userId = (long)session.getAttribute("userInfo");
long total = reservationService.studentCount(userId);
List<Reservation> reservationList = reservationService.getStudentReservationList(page,limit,userId);
HashMap<String,Object> data = new HashMap<>();
data.put("total",total);
data.put("reservationList",reservationList);
return ResultVO.SUCCESS(0,data);
}
/**
* 擷取教師預約單
* */
@GetMapping("/teacher/mine")
@ResponseBody
public ResultVO getTeacherReservationList(@RequestParam(value = "page", defaultValue = "1") Integer page,
@RequestParam(value = "limit", defaultValue = "10") Integer limit,
HttpSession session) {
page -= 1;
long userId = (long)session.getAttribute("userInfo");
long total = reservationService.teacherCount(userId);
List<Reservation> reservationList = reservationService.getTeacherReservationList(page,limit,userId);
HashMap<String,Object> data = new HashMap<>();
data.put("total",total);
data.put("reservationList",reservationList);
return ResultVO.SUCCESS(0,data);
}
/**
* 學生預約清單
* individual/mine.html
* */
@GetMapping("/individual/mine.html")
public String toIndividualMineHtml() {
return "/reservation/individual/mine.html";
}
/**
* 教師預約清單
* teacher/mine.html
* */
@GetMapping("/teacher/mine.html")
public String toTeacherMineHtml() {
return "/reservation/teacher/mine.html";
}
/**
* 擷取未深刻預約單
* */
@GetMapping("/audit")
@ResponseBody
public ResultVO getNoneAuditReservationList(@RequestParam(value = "page", defaultValue = "1") Integer page,
@RequestParam(value = "limit", defaultValue = "10") Integer limit) {
page -= 1;
long total = reservationService.noneAuditCount();
List<Reservation> reservationList = reservationService.getNoneAuditReservationList(page,limit);
HashMap<String,Object> data = new HashMap<>();
data.put("total",total);
data.put("reservationList",reservationList);
return ResultVO.SUCCESS(0,data);
}
@GetMapping("/Audit.html")
public String toAuditReservationIndexHtml() {
return "/reservation/Audit.html";
}
@GetMapping("update/audit")
@ResponseBody
public ResultVO UpdateReservation(long reservationId) {
Reservation reservation = reservationService.getReservationId(reservationId);
reservation.setStatus(1);
reservationService.save(reservation);
System.out.println(reservationId);
return ResultVO.SUCCESS(200);
}
@PostMapping("/delete")
@ResponseBody
public ResultVO deleteReservation(Reservation reservation) {
reservationService.delete(reservation);
return ResultVO.SUCCESS(200);
}
擷取源碼請關注後私信“20240423”