项目介绍
基于springboot的养老院管理系统,本系统为后台管理系统,分为三个角色,分别是超级管理员、管理员、用户。
超级管理员、管理员的功能如下:
登录、修改密码、账号管理、健康档案管理、病例管理、药品管理、每月餐饮管理、外出报备、入住登记、寝室分配、事故记录、访客记录、收费管理; 其中超级管理员可进行管理员账号管理;
用户的功能如下:
登录、修改密码、个人信息、家人情况、每月餐饮管理、外出报备、查看收费标准
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.数据库:MySql 5.7版本;
6.是否Maven项目: 是;查看源码目录中是否包含pom.xml;
若包含,则为maven项目,否则为非maven项目
技术栈
1.后端:springboot+Mybatis
2.前端:HTML+thymeleaf+Javascript+css
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
- 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat; - 将项目中application-dev.yml配置文件中的数据库配置改为自己的配置
- 运行项目,在浏览器中输入地址:http://localhost:8080/ 登录账号;
超级管理员:root/123456
管理员:admin/123456
用户:user/123456
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
}
userInfoService.addUserInfo(userInfo);
message = "用户添加成功!";
success = true;
writeJsonResponse(response, success, message);
}
/*ajax方式按照查询条件分页查询用户信息*/
@RequestMapping(value = { "/list" }, method = {RequestMethod.GET,RequestMethod.POST})
public void list(String user_name,String name,String birthDate,String telephone,Integer page,Integer rows, Model model, HttpServletRequest request,HttpServletResponse response) throws Exception {
if (page==null || page == 0) page = 1;
if (user_name == null) user_name = "";
if (name == null) name = "";
if (birthDate == null) birthDate = "";
if (telephone == null) telephone = "";
if(rows != 0)userInfoService.setRows(rows);
List<UserInfo> userInfoList = userInfoService.queryUserInfo(user_name, name, birthDate, telephone, page);
/*计算总的页数和总的记录数*/
userInfoService.queryTotalPageAndRecordNumber(user_name, name, birthDate, telephone);
/*获取到总的页码数目*/
int totalPage = userInfoService.getTotalPage();
/*当前查询条件下总记录数*/
message = "老人添加成功!";
success = true;
writeJsonResponse(response, success, message);
}
/*ajax方式按照查询条件分页查询老人信息*/
@RequestMapping(value = { "/list" }, method = {RequestMethod.GET,RequestMethod.POST})
public void list(String name,@ModelAttribute("userObj") UserInfo userObj,String addTime,Integer page,Integer rows, Model model, HttpServletRequest request,HttpServletResponse response) throws Exception {
if (page==null || page == 0) page = 1;
if (name == null) name = "";
if (addTime == null) addTime = "";
if(rows != 0)oldManService.setRows(rows);
List<OldMan> oldManList = oldManService.queryOldMan(name, userObj, addTime, page);
/*计算总的页数和总的记录数*/
oldManService.queryTotalPageAndRecordNumber(name, userObj, addTime);
/*获取到总的页码数目*/
int totalPage = oldManService.getTotalPage();
}
out.println(jsonArray.toString());
out.flush();
out.close();
}
/*前台按照查询条件分页查询房间信息*/
@RequestMapping(value = { "/frontlist" }, method = {RequestMethod.GET,RequestMethod.POST})
public String frontlist(String roomNo,@ModelAttribute("roomTypeObj") RoomType roomTypeObj,String roomName,String roomState,Integer currentPage, Model model, HttpServletRequest request) throws Exception {
if (currentPage==null || currentPage == 0) currentPage = 1;
if (roomNo == null) roomNo = "";
if (roomName == null) roomName = "";
if (roomState == null) roomState = "";
List<Room> roomList = roomService.queryRoom(roomNo, roomTypeObj, roomName, roomState, currentPage);
/*计算总的页数和总的记录数*/
roomService.queryTotalPageAndRecordNumber(roomNo, roomTypeObj, roomName, roomState);
/*获取到总的页码数目*/
int totalPage = roomService.getTotalPage();
/*当前查询条件下总记录数*/
int recordNumber = roomService.getRecordNumber();
request.setAttribute("roomList", roomList);
message = "输入的信息有错误!";
writeJsonResponse(response, success, message);
return;
}
String userPhotoFileName = this.handlePhotoUpload(request, "userPhotoFile");
if(!userPhotoFileName.equals("upload/NoImage.jpg"))userInfo.setUserPhoto(userPhotoFileName);
try {
userInfoService.updateUserInfo(userInfo);
message = "用户更新成功!";
success = true;
writeJsonResponse(response, success, message);
} catch (Exception e) {
e.printStackTrace();
message = "用户更新失败!";
writeJsonResponse(response, success, message);
}
}
/*删除用户信息*/
@RequestMapping(value="/{user_name}/delete",method=RequestMethod.GET)
public String delete(@PathVariable String user_name,HttpServletRequest request) throws UnsupportedEncodingException {
jsonOldMan.accumulate("name", oldMan.getName());
jsonArray.put(jsonOldMan);
}
out.println(jsonArray.toString());
out.flush();
out.close();
}
/*前台按照查询条件分页查询老人信息*/
@RequestMapping(value = { "/frontlist" }, method = {RequestMethod.GET,RequestMethod.POST})
public String frontlist(String name,@ModelAttribute("userObj") UserInfo userObj,String addTime,Integer currentPage, Model model, HttpServletRequest request) throws Exception {
if (currentPage==null || currentPage == 0) currentPage = 1;
if (name == null) name = "";
if (addTime == null) addTime = "";
out.flush();
out.close();
}
/*ajax方式按照查询条件分页查询老人信息*/
@RequestMapping(value = { "/listAll" }, method = {RequestMethod.GET,RequestMethod.POST})
public void listAll(HttpServletResponse response) throws Exception {
List<OldMan> oldManList = oldManService.queryAllOldMan();
response.setContentType("text/json;charset=UTF-8");
PrintWriter out = response.getWriter();
JSONArray jsonArray = new JSONArray();
for(OldMan oldMan:oldManList) {
JSONObject jsonOldMan = new JSONObject();
jsonOldMan.accumulate("oldManId", oldMan.getOldManId());
jsonOldMan.accumulate("name", oldMan.getName());
jsonArray.put(jsonOldMan);
}
out.println(jsonArray.toString());
out.flush();
out.close();
PrintWriter out = response.getWriter();
JSONArray jsonArray = new JSONArray();
for(OldMan oldMan:oldManList) {
JSONObject jsonOldMan = new JSONObject();
jsonOldMan.accumulate("oldManId", oldMan.getOldManId());
jsonOldMan.accumulate("name", oldMan.getName());
jsonArray.put(jsonOldMan);
}
out.println(jsonArray.toString());
out.flush();
out.close();
}
/*前台按照查询条件分页查询老人信息*/
@RequestMapping(value = { "/frontlist" }, method = {RequestMethod.GET,RequestMethod.POST})
public String frontlist(String name,@ModelAttribute("userObj") UserInfo userObj,String addTime,Integer currentPage, Model model, HttpServletRequest request) throws Exception {
if (currentPage==null || currentPage == 0) currentPage = 1;
if (name == null) name = "";
if (addTime == null) addTime = "";
List<OldMan> oldManList = oldManService.queryOldMan(name, userObj, addTime, currentPage);
/*计算总的页数和总的记录数*/
oldManService.queryTotalPageAndRecordNumber(name, userObj, addTime);
OldMan oldMan = oldManService.getOldMan(oldManId);
response.setContentType("text/json;charset=UTF-8");
PrintWriter out = response.getWriter();
//将要被返回到客户端的对象
JSONObject jsonOldMan = oldMan.getJsonObject();
out.println(jsonOldMan.toString());
out.flush();
out.close();
}
/*ajax方式更新老人信息*/
@RequestMapping(value = "/{oldManId}/update", method = RequestMethod.POST)
public void update(@Validated OldMan oldMan, BindingResult br,
Model model, HttpServletRequest request,HttpServletResponse response) throws Exception {
String message = "";
boolean success = false;
if (br.hasErrors()) {
message = "输入的信息有错误!";
writeJsonResponse(response, success, message);
return;
ex.exportExcel(title,headers, dataset, out);
out.close();
} catch (Exception e) {
e.printStackTrace();
}
*/
OutputStream out = null;//创建一个输出流对象
try {
out = response.getOutputStream();//
response.setHeader("Content-disposition","attachment; filename="+"Room.xls");//filename是下载的xls的名,建议最好用英文
response.setContentType("application/msexcel;charset=UTF-8");//设置类型
response.setHeader("Pragma","No-cache");//设置头
response.setHeader("Cache-Control","no-cache");//设置头
response.setDateHeader("Expires", 0);//设置日期头
String rootPath = request.getSession().getServletContext().getRealPath("/");
ex.exportExcel(rootPath,_title,headers, dataset, out);
out.flush();
} catch (IOException e) {
e.printStackTrace();
}finally{
try{
if(out!=null){
out.close();
} catch (Exception e) {
e.printStackTrace();
message = "用户更新失败!";
writeJsonResponse(response, success, message);
}
}
/*删除用户信息*/
@RequestMapping(value="/{user_name}/delete",method=RequestMethod.GET)
public String delete(@PathVariable String user_name,HttpServletRequest request) throws UnsupportedEncodingException {
try {
userInfoService.deleteUserInfo(user_name);
request.setAttribute("message", "用户删除成功!");
return "message";
} catch (Exception e) {
e.printStackTrace();
/*计算总的页数和总的记录数*/
roomService.queryTotalPageAndRecordNumber(roomNo, roomTypeObj, roomName, roomState);
/*获取到总的页码数目*/
int totalPage = roomService.getTotalPage();
/*当前查询条件下总记录数*/
int recordNumber = roomService.getRecordNumber();
response.setContentType("text/json;charset=UTF-8");
PrintWriter out = response.getWriter();
//将要被返回到客户端的对象
JSONObject jsonObj=new JSONObject();
jsonObj.accumulate("total", recordNumber);
JSONArray jsonArray = new JSONArray();
for(Room room:roomList) {
JSONObject jsonRoom = room.getJsonObject();
jsonArray.put(jsonRoom);
}
jsonObj.accumulate("rows", jsonArray);
out.println(jsonObj.toString());
out.flush();
out.close();
}
/*ajax方式按照查询条件分页查询房间信息*/
@RequestMapping(value = { "/listAll" }, method = {RequestMethod.GET,RequestMethod.POST})
public void listAll(HttpServletResponse response) throws Exception {
List<Room> roomList = roomService.queryAllRoom();
response.setContentType("text/json;charset=UTF-8");
PrintWriter out = response.getWriter();