基于javaweb+mysql的springboot宿舍管理系统(java+springboot+jsp+bootstrap+maven+mysql)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot宿舍管理系统(java+springboot+jsp+bootstrap+maven+mysql)
项目介绍
宿舍管理系统的用户可以分为三种:系统管理员、宿舍管理员、学生。系统管理员主要功能: 学生信息管理:包括学生信息的导入、编辑、删除、查找等; 职工信息管理:包括职工信息的导入、添加、编辑、删除、查找等; 宿舍楼信息管理:宿舍楼信息的导入功能;宿舍管理员主要功能: 个人信息管理:个人信息、修改密码; 学生信息查询:学生信息查询; 报修单管理:处理中报修单、未处理报修单、历史报修单; 假期登记:离校登记管理、离校登记历史管理、入校登记管理、入校登记历史管理; 宿舍评分管理:评分录入、历史评分表; 来访人员管理:来访人员信息登记、历史来访记录;学生主要功能: 个人信息管理:个人信息、修改密码; 假期登记:入校登记、离校登记; 报修:申请报修、历史报修记录; 宿舍评分查看:宿舍评分查看;
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.是否Maven项目: 是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目
6.数据库:MySql 5.7版本;
7.lombok插件 注:需要安装lombok插件-否则会报错;
技术栈
- 后端:SpringBoot+jpa 2. 前端:JSP+bootstrap+easypoi+jQuery
运行说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库(dorm),并导入项目的sql文件; 2. 将项目中resources/application.properties配置文件中的数据库配置改为自己的配置 3. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行; 4. 运行项目,输入localhost:8082 登录
}
/**
* 是否创建入校登记
* @return
*/
@GetMapping("/isCreateRegister")
@ResponseBody
public Boolean isCreateRegister() {
return registerServiceI.isCreateRegister();
}
/**
* 创建入校登记
* @return
*/
@PostMapping("/createRegister")
@ResponseBody
public Boolean createRegister(String name, HttpSession session) {
try {
UserExpand user = (UserExpand) session.getAttribute("LOGIN_USER");
registerServiceI.createRegister(name, user.getStaffinfo());
return true;
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
/**
* 查询入校登记名称列表
* @param session
* @return
*/
@GetMapping("/getRegisterNames")
@ResponseBody
public List<Registerbatch> getRegisterNames(HttpSession session) {
UserExpand user = (UserExpand) session.getAttribute("LOGIN_USER");
return registerServiceI.getRegisterNames(user.getStaffinfo().getId(), "in");
}
/**
* 查询入校登记列表
* @param pageable
* @param session
* @return
*/
@GetMapping("/inRegisterList")
@ResponseBody
public Page<InRegisterExtend> inRegisterList(@PageableDefault Pageable pageable, HttpSession session) {
UserExpand user = (UserExpand) session.getAttribute("LOGIN_USER");
return registerServiceI.inRegisterList(pageable, user.getStaffinfo());
}
@Controller
@RequestMapping("/external")
public class ExternalController {
@Autowired
private ExternalServiceI externalServiceI;
/**
* 跳转来访人员信息登记页面
* @return
*/
@GetMapping("/externalView")
public String getExternalView() {
return "external/externalView";
}
/**
* 添加来访人员登记
* @param external
* @param session
* @return
*/
@PostMapping("/saveExternal")
@ResponseBody
public Boolean saveExternal(External external, HttpSession session) {
try {
UserExpand user = (UserExpand) session.getAttribute("LOGIN_USER");
externalServiceI.saveExternal(external, user.getStaffinfo());
return true;
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
/**
* 查询来访人员登记列表
* @param pageable
score.setSum(score.getSanitary() + score.getTidy());
}
scoreServiceI.updateScore(score);
} catch (Exception e) {
e.printStackTrace();
return false;
}
return true;
}
/**
* 发布宿舍评分
* @param session
* @return
*/
@GetMapping("/push")
@ResponseBody
public Boolean push(HttpSession session) {
UserExpand user = (UserExpand) session.getAttribute("LOGIN_USER");
try {
scoreServiceI.push(user.getStaffinfo());
return true;
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
/**
* 查询宿舍评分名称列表
* @param session
* @return
*/
@GetMapping("/getScoreNames")
@ResponseBody
public List<Scoringbatch> getScoreNames(HttpSession session) {
UserExpand user = (UserExpand) session.getAttribute("LOGIN_USER");
return scoreServiceI.getScoreNames(user);
}
/**
* 查询宿舍评分列表
* @param pageable
* @param session
* @param scoringBatchId
* @return
*/
@GetMapping("/historyList")
@ResponseBody
public Page<ScoreExtend> historyList(@PageableDefault Pageable pageable, HttpSession session, String scoringBatchId) {
UserExpand user = (UserExpand) session.getAttribute("LOGIN_USER");
public Page<ScoreExtend> historyList(@PageableDefault Pageable pageable, HttpSession session, String scoringBatchId) {
UserExpand user = (UserExpand) session.getAttribute("LOGIN_USER");
return scoreServiceI.historyList(pageable, user, scoringBatchId);
}
/**
* 导出宿舍历史评分文件
* @param session
* @param response
*/
@GetMapping("/exportHistoryExcel")
public void exportExcel(HttpSession session, HttpServletResponse response) {
UserExpand user = (UserExpand) session.getAttribute("LOGIN_USER");
Staffinfo staffinfo = user.getStaffinfo();
List<ExportScoreHistoryEntity> list = scoreServiceI.findHistory(staffinfo);
if (list.size() > 0) {
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("历史评分表", "历史评分表1"), ExportScoreHistoryEntity.class, list);
ExportExcelUtil.downLoadExcel(response, "历史评分表", workbook);
}
}
/**
* 跳转宿舍评分页面
* @param model
* @param session
* @return
*/
@GetMapping("/stuScoreView")
public String getScoreView(Model model, HttpSession session) {
UserExpand user = (UserExpand) session.getAttribute("LOGIN_USER");
Stuinfo stuinfo = stuServiceI.findById(user.getUsername());
model.addAttribute("dormId", stuinfo.getDormid());
return "score/stuScoreView";
}
}
return false;
}
/**
* 跳转历史来访记录页面
* @return
*/
@GetMapping("/historyView")
public String getHistoryView() {
return "external/historyView";
}
/**
* 历史来访记录列表
* @return
*/
@GetMapping("/externalHistoryList")
@ResponseBody
public Page<External> externalHistoryList(@PageableDefault Pageable pageable, HttpSession session, String stuname, String startTime, String endTime) {
UserExpand user = (UserExpand) session.getAttribute("LOGIN_USER");
return externalServiceI.externalHistoryList(pageable, user.getStaffinfo(), stuname, startTime, endTime);
}
/**
* 导出历史来访登记表
* @param session
* @param response
*/
@GetMapping("/exportHistoryExcel")
public void exportHistoryExcel(HttpSession session, HttpServletResponse response) {
UserExpand user = (UserExpand) session.getAttribute("LOGIN_USER");
List<External> list = externalServiceI.findHistoryList(user.getStaffinfo());
if (list.size() > 0) {
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("历史来访登记表", "历史来访登记表1"), External.class, list);
ExportExcelUtil.downLoadExcel(response, "历史来访登记表", workbook);
}
}
}
public class ExportExcelUtil {
/**
* 下载
*/
@GetMapping("/getRegisterNames")
@ResponseBody
public List<Registerbatch> getRegisterNames(HttpSession session) {
UserExpand user = (UserExpand) session.getAttribute("LOGIN_USER");
return registerServiceI.getRegisterNames(user.getStaffinfo().getId(), "in");
}
/**
* 查询入校登记列表
* @param pageable
* @param session
* @return
*/
@GetMapping("/inRegisterList")
@ResponseBody
public Page<InRegisterExtend> inRegisterList(@PageableDefault Pageable pageable, HttpSession session) {
UserExpand user = (UserExpand) session.getAttribute("LOGIN_USER");
return registerServiceI.inRegisterList(pageable, user.getStaffinfo());
}
/**
* 创建历史登记
* @param session
* @return
*/
@GetMapping("/createInHistory")
@ResponseBody
public Boolean createInHistory(HttpSession session) {
UserExpand user = (UserExpand) session.getAttribute("LOGIN_USER");
return registerServiceI.createInHistory(user.getStaffinfo());
}
/**
* 查询入校登记历史列表
* @param pageable
* @param session
* @param registerBatchId
* @return
*/
@GetMapping("/inHistoryList")
@ResponseBody
public Page<InRegisterExtend> historyList(@PageableDefault Pageable pageable, HttpSession session, String registerBatchId) {
UserExpand user = (UserExpand) session.getAttribute("LOGIN_USER");
return registerServiceI.historyList(pageable, user.getStaffinfo(), registerBatchId);
}
* @param session
* @return
*/
@GetMapping("/logout")
@ResponseBody
public Boolean logout(HttpSession session) {
session.removeAttribute("LOGIN_USER");
return true;
}
}
@Component
public class LoginInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
HttpSession session = request.getSession();
UserExpand info = (UserExpand) session.getAttribute("LOGIN_USER");
if (info != null) {
// 登录成功不拦截
return true;
} else {
response.sendRedirect(request.getContextPath() + "/login/toLogin");
return false;
}
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
ModelAndView modelAndView) throws Exception {
// TODO Auto-generated method stub
HandlerInterceptor.super.postHandle(request, response, handler, modelAndView);
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
* @return
*/
@GetMapping("/repairHistoryView")
public String getRepairHistoryView() {
return "staff/repairHistory";
}
/**
* 查询历史报修单列表
* @param pageable
* @param session
* @param reason
* @return
*/
@GetMapping("/repairHistory")
@ResponseBody
public Page<Repair> getRepairHistory(@PageableDefault Pageable pageable, HttpSession session, String reason) {
UserExpand user = (UserExpand) session.getAttribute("LOGIN_USER");
return staffServiceI.findRepairHistory(pageable, reason, user.getStaffinfo());
}
}
}
/**
*
* @param session
* @param response
*/
@PostMapping("/exportInfo")
public void exportInfo(HttpSession session, HttpServletResponse response) {
UserExpand user = (UserExpand) session.getAttribute("LOGIN_USER");
List<Stuinfo> list = stuServiceI.findAll(user);
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("学生信息", "学生信息表1"), Stuinfo.class, list);
ExportExcelUtil.downLoadExcel(response, "学生信息表", workbook);
}
/**
* 跳转学生个人主页
* @param session
* @param model
* @return
* @throws Exception
*/
@GetMapping("/infoView")
public String getInfoView(HttpSession session, Model model) throws Exception {
UserExpand user = (UserExpand) session.getAttribute("LOGIN_USER");
Stuinfo stuinfo = stuServiceI.findById(user.getUsername());
model.addAttribute("stuinfo", new ObjectMapper().writeValueAsString(stuinfo));
return "stu/infoView";
}
/**
* 学生更新密码
* @param session
* @param model
* @return
*/
@GetMapping("/updatePwd")
public String updatePwd(HttpSession session, Model model) {
UserExpand user = (UserExpand) session.getAttribute("LOGIN_USER");
Stuinfo stuinfo = stuServiceI.findById(user.getUsername());
model.addAttribute("id", stuinfo.getId());
return "stu/updatePwd";
}
/**
* 学生更新电话
* @param stuinfo
* @return
*/
@PostMapping("/updatePhone")
@ResponseBody
public Boolean updatePhone(Stuinfo stuinfo) {
public Page<External> externalHistoryList(@PageableDefault Pageable pageable, HttpSession session, String stuname, String startTime, String endTime) {
UserExpand user = (UserExpand) session.getAttribute("LOGIN_USER");
return externalServiceI.externalHistoryList(pageable, user.getStaffinfo(), stuname, startTime, endTime);
}
/**
* 导出历史来访登记表
* @param session
* @param response
*/
@GetMapping("/exportHistoryExcel")
public void exportHistoryExcel(HttpSession session, HttpServletResponse response) {
UserExpand user = (UserExpand) session.getAttribute("LOGIN_USER");
List<External> list = externalServiceI.findHistoryList(user.getStaffinfo());
if (list.size() > 0) {
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("历史来访登记表", "历史来访登记表1"), External.class, list);
ExportExcelUtil.downLoadExcel(response, "历史来访登记表", workbook);
}
}
}
public class ExportExcelUtil {
/**
* 下载
*
* @param response HttpServletResponse
* @param fileName 文件名
* @param workbook Workbook
*/
public static void downLoadExcel(HttpServletResponse response, String fileName, Workbook workbook) {
try {
response.setCharacterEncoding("UTF-8");
response.setHeader("content-Type", "application/vnd.ms-excel");
response.setHeader("Content-Disposition",
"attachment;filename=" + URLEncoder.encode(fileName + ".xls", "UTF-8"));
return true;
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
/**
* 跳转历史来访记录页面
* @return
*/
@GetMapping("/historyView")
public String getHistoryView() {
return "external/historyView";
}
/**
* 历史来访记录列表
* @return
*/
@GetMapping("/externalHistoryList")
@ResponseBody
public Page<External> externalHistoryList(@PageableDefault Pageable pageable, HttpSession session, String stuname, String startTime, String endTime) {
UserExpand user = (UserExpand) session.getAttribute("LOGIN_USER");
return externalServiceI.externalHistoryList(pageable, user.getStaffinfo(), stuname, startTime, endTime);
}
/**
* 导出历史来访登记表
* @param session
* @param response
*/
@GetMapping("/exportHistoryExcel")
public void exportHistoryExcel(HttpSession session, HttpServletResponse response) {
UserExpand user = (UserExpand) session.getAttribute("LOGIN_USER");
List<External> list = externalServiceI.findHistoryList(user.getStaffinfo());
if (list.size() > 0) {
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("历史来访登记表", "历史来访登记表1"), External.class, list);
ExportExcelUtil.downLoadExcel(response, "历史来访登记表", workbook);
}
}
}
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("学生信息", "学生信息表1"), Stuinfo.class, list);
ExportExcelUtil.downLoadExcel(response, "学生信息表", workbook);
}
/**
* 跳转学生个人主页
* @param session
* @param model
* @return
* @throws Exception
*/
@GetMapping("/infoView")
public String getInfoView(HttpSession session, Model model) throws Exception {
UserExpand user = (UserExpand) session.getAttribute("LOGIN_USER");
Stuinfo stuinfo = stuServiceI.findById(user.getUsername());
model.addAttribute("stuinfo", new ObjectMapper().writeValueAsString(stuinfo));
return "stu/infoView";
}
/**
* 学生更新密码
* @param session
* @param model
* @return
*/
@GetMapping("/updatePwd")
public String updatePwd(HttpSession session, Model model) {
UserExpand user = (UserExpand) session.getAttribute("LOGIN_USER");
Stuinfo stuinfo = stuServiceI.findById(user.getUsername());
model.addAttribute("id", stuinfo.getId());
return "stu/updatePwd";
}
/**
* 学生更新电话
* @param stuinfo
* @return
*/
@PostMapping("/updatePhone")
@ResponseBody
public Boolean updatePhone(Stuinfo stuinfo) {
return stuServiceI.updatePhone(stuinfo);
}
/**
return stuServiceI.updatePwd(id, oldPwd, newPwd);
}
/**
* 带分页信息-学生列表
* @param pageable
* @param session
* @param searchId
* @param searchDormName
* @return
*/
@GetMapping("/list")
@ResponseBody
public Page<Stuinfo> getStuInfo(@PageableDefault Pageable pageable, HttpSession session, String searchId, String searchDormName) {
UserExpand user = (UserExpand) session.getAttribute("LOGIN_USER");
return stuServiceI.findStus(pageable, user, searchId, searchDormName);
}
/**
* 导入文件-学生信息
* @param file
* @return
*/
@PostMapping("/importExcel")
@ResponseBody
public Boolean importExcel(@RequestParam("file") MultipartFile file) {
return stuServiceI.importExcel(file);
}
/**
* 编辑学生离校
* @param ids
* @return
*/
@PostMapping("/leaveSchool")
@ResponseBody
public Boolean leaveSchool(@RequestBody(required = true) List<String> ids) {
return stuServiceI.leaveSchool(ids);
}
/**
* 重置密码 123456
* @param stuId
* @return
*/
@GetMapping("/resetPwd")
@ResponseBody
public Boolean resetPwd(String stuId) {
return stuServiceI.resetPwd(stuId);
}
* 导出入校登记表
* @param session
* @param response
*/
@GetMapping("/inExportExcel")
public void inExportExcel(HttpSession session, HttpServletResponse response) {
UserExpand user = (UserExpand) session.getAttribute("LOGIN_USER");
List<ExportInRegisterEntity> list = registerServiceI.findInHistoryList(user.getStaffinfo());
if (list.size() > 0) {
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("入校登记表", "入校登记表1"), ExportInRegisterEntity.class, list);
ExportExcelUtil.downLoadExcel(response, "入校登记表", workbook);
}
}
/**
* 跳转学生入校登记页面
* @param model
* @param session
* @return
*/
@GetMapping("/stuInRegisterView")
public String getInRegisterView(Model model, HttpSession session) {
UserExpand user = (UserExpand) session.getAttribute("LOGIN_USER");
InRegister inRegister = registerServiceI.getInRegisterId(user.getUsername());
String inRegisterId = null;
if (inRegister != null) {
inRegisterId = inRegister.getId();
}
model.addAttribute("inRegisterId", inRegisterId);
return "register/stuInRegisterView";
}
/**
* 保存学生入校登记
* @param arrivetime
* @param inRegisterId
* @return
*/
@PostMapping("/saveStuRegister")
@ResponseBody
public Boolean saveStuRegister(Date arrivetime, String inRegisterId) {
try {
registerServiceI.saveStuRegister(arrivetime, inRegisterId);
return true;
e.printStackTrace();
}
return false;
}
/**
* 学生进行入校登记
* @param session
* @return
*/
@GetMapping("/isStuSaveRegister")
@ResponseBody
public Boolean isStuSaveRegister(HttpSession session) {
UserExpand user = (UserExpand) session.getAttribute("LOGIN_USER");
return registerServiceI.isStuSaveRegister(user.getUsername());
}
/**
* 查询学生入校登记列表
* @param pageable
* @param session
* @return
*/
@GetMapping("/stuHistoryList")
@ResponseBody
public Page<InRegisterExtend> stuHistoryList(@PageableDefault Pageable pageable, HttpSession session) {
UserExpand user = (UserExpand) session.getAttribute("LOGIN_USER");
return registerServiceI.stuHistoryList(pageable, user.getUsername());
}
/**
* 跳转离校登记页面
* @return
*/
@GetMapping("/outRegisterView")
public String getOutRegisterView() {
return "register/outRegisterView";
}
/**
* 创建离校登记
* @return
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
/**
* 学生进行入校登记
* @param session
* @return
*/
@GetMapping("/isStuSaveRegister")
@ResponseBody
public Boolean isStuSaveRegister(HttpSession session) {
UserExpand user = (UserExpand) session.getAttribute("LOGIN_USER");
return registerServiceI.isStuSaveRegister(user.getUsername());
}
/**
* 查询学生入校登记列表
* @param pageable
* @param session
* @return
*/
@GetMapping("/stuHistoryList")
@ResponseBody
public Page<InRegisterExtend> stuHistoryList(@PageableDefault Pageable pageable, HttpSession session) {
UserExpand user = (UserExpand) session.getAttribute("LOGIN_USER");
return registerServiceI.stuHistoryList(pageable, user.getUsername());
}
/**
* 跳转离校登记页面
* @return
*/
@GetMapping("/outRegisterView")
public String getOutRegisterView() {
return "register/outRegisterView";
}
/**
* 创建离校登记
* @return
*/
@GetMapping("/isCreateOutRegister")
@ResponseBody
public Boolean isCreateOutRegister() {
return registerServiceI.isCreateOutRegister();
}
registerServiceI.createOutRegister(name, user.getStaffinfo());
return true;
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
/**
* 查询离校登记分类
* @param session
* @return
*/
@GetMapping("/getOutRegisterNames")
@ResponseBody
public List<Registerbatch> getOutRegisterNames(HttpSession session) {
UserExpand user = (UserExpand) session.getAttribute("LOGIN_USER");
return registerServiceI.getRegisterNames(user.getStaffinfo().getId(), "out");
}
/**
* 查询离校登记历史管理列表
* @param pageable
* @param session
* @param registerBatchId
* @return
*/
@GetMapping("/outHistoryList")
@ResponseBody
public Page<OutRegisterExtend> outHistoryList(@PageableDefault Pageable pageable, HttpSession session, String registerBatchId) {
UserExpand user = (UserExpand) session.getAttribute("LOGIN_USER");
return registerServiceI.outHistoryList(pageable, user.getStaffinfo(), registerBatchId);
}
/**
* 查询离校登记列表
* @param pageable
* @param session
* @return
*/