——————————DescriptionStart——————————
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明














基于javaweb的SSM自习室图书馆座位预约占座管理系统前台后台(java+ssm+jsp+layui+mysql)
管理员
admin 123456
学生
xs001 123456
xs002 123456
xs003 123456
xs004 123456
添加学生时会自动在用户表中注册
定时任务会定时生成座位信息,
阅览室分类中可设置信用等级,
学生被扣分后信用等级低于相应的值后不能预约相应的阅览室座位。
——————————CodeStart——————————
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| * 用户管理 */
@Controller @RequestMapping("user") public class UserController extends LogController{
private int page; private int rows; private User user; @Autowired private UserService<User> userService; @Autowired private StudentService<Student> studentStudentService; @RequestMapping("userIndex") public String index(){ return "sys/user"; } @RequestMapping("userList") public void userList(HttpServletRequest request,HttpServletResponse response){ try { page = Integer.parseInt(request.getParameter("page")); rows = Integer.parseInt(request.getParameter("limit")); user = new User(); user.setPage((page-1)*rows); user.setRows(rows); user.setUserName(request.getParameter("userName")); String roleId = request.getParameter("roleId"); if (StringUtil.isNotEmpty(roleId)) { user.setRoleId(Integer.parseInt(roleId)); } else { user.setRoleId(null); } List<User> list = userService.findUser(user); int total = userService.countUser(user); JSONObject jsonObj = new JSONObject(); jsonObj.put("code", 0); jsonObj.put("msg", ""); jsonObj.put("count",total );
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| WriterUtil.write(response, result.toString()); }
public boolean isLeaf(String menuId){ boolean flag = false; try { menu = new Menu(); menu.setParentId(Integer.parseInt(menuId)); List<Menu> list = menuService.findMenu(menu); if (list==null || list.size()==0) { flag = true; } } catch (Exception e) { e.printStackTrace(); } return flag; }
@RequestMapping("deleteMenu") public void deleteMenu(HttpServletRequest request,HttpServletResponse response){ JSONObject result = new JSONObject(); try { String menuId = request.getParameter("menuId"); String parentId = request.getParameter("parentId"); if (!isLeaf(menuId)) { result.put("errorMsg", "该菜单下面有子菜单,不能直接删除"); } else { menu = new Menu(); menu.setParentId(Integer.parseInt(parentId)); int sonNum = menuService.countMenu(menu); if (sonNum == 1) { menu = new Menu(); menu.setMenuId(Integer.parseInt(parentId)); menu.setState("open"); menuService.updateMenu(menu); menuService.deleteMenu(Integer.parseInt(menuId));
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| }
@RequestMapping("reserveIllegal") public void reserveIllegal(HttpServletRequest request,HttpServletResponse response,Illegal illegal) { JSONObject result = new JSONObject(); String illegalId = request.getParameter("id"); if (StringUtil.isNotEmpty(illegalId)) { try { illegal.setId(Integer.parseInt(illegalId)); this.illegal=illegalService.findOneIllegal(Integer.parseInt(illegalId)); String studentno = this.illegal.getStudentno(); score = scoreService.findOneScore(studentno); int total = score.getTotal(); int oldScore = this.illegal.getScore(); int newScore = illegal.getScore(); int changeScore = newScore-oldScore; if(changeScore!=0) { score.setTotal(total - changeScore); scoreService.updateScore(score); } illegalService.updateIllegal(illegal); result.put("returnCode",200); } catch (Exception e) { e.printStackTrace(); result.put("returnCode", "对不起,操作失败"); } }else { try { String studentno = illegal.getStudentno(); score = scoreService.findOneScore(studentno); int total = score.getTotal(); int thisScore = illegal.getScore(); if(thisScore > total){ result.put("returnCode", "对不起!扣除失败,要扣除的分数大于剩余积分!"); } else { illegalService.addIllegal(illegal);
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| Field[] fields = o.getClass().getDeclaredFields(); String[] fieldNames = new String[fields.length]; for (int i = 0; i < fieldNames.length; i++) { fieldNames[i] = fields[i].getName(); } return fieldNames; }
public static String getFieldsInfo(Object o){ Field[] fields = o.getClass().getDeclaredFields(); StringBuffer sb = new StringBuffer("属性名和值:");
for (int i = 1; i < fields.length; i++) { sb.append(fields[i].getName()+ "-->"+getFieldValueByName(fields[i].getName(), o)+" ");
} return sb.toString(); } }
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| return jsonArray; }
public JSONArray getOperationJsonArray(int menuId,String operationIds){ JSONArray jsonArray=new JSONArray(); try { operation = new Operation(); operation.setMenuId(menuId); List<Operation> list = operationService.findOperation(operation); for(Operation operation : list){ JSONObject jsonObject = new JSONObject(); int operationId = operation.getOperationId(); jsonObject.put("id", operationId); jsonObject.put("text", operation.getOperationName()); jsonObject.put("iconCls", ""); jsonObject.put("state", "open"); if (StringUtil.isNotEmpty(operationIds)) { if (dingzhen.util.StringUtil.existStrArr(operationId+"", operationIds.split(","))) { jsonObject.put("checked", true); } } jsonArray.add(jsonObject); } return jsonArray; } catch (Exception e) { e.printStackTrace(); return null; } }
@RequestMapping("updateRoleMenu") public void updateRoleMenu(HttpServletRequest request,HttpServletResponse response){ JSONObject result = new JSONObject(); try { String roleId = request.getParameter("roleId"); String[] ids = request.getParameter("menuIds").split(","); String menuIds = ""; String operationIds = "";
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| if(request.getParameter("roomid")!=null && request.getParameter("roomid").length() > 0){ seat.setRoomid(Integer.parseInt(request.getParameter("roomid"))); room.setId(Integer.parseInt(request.getParameter("roomid"))); } else { seat.setRoomid(1); room.setId(1); } String time = request.getParameter("time"); if(time == null || time.length()==0){ seat.setTime("08点-12点"); }else { seat.setTime(time); } List<Seat> list = seatService.findSeat(seat); for (Seat seat:list){ Student oneStudentByno = studentService.findOneStudentByno(seat.getStudentno()); if (oneStudentByno!=null){ seat.setStudentname(oneStudentByno.getName()); }
} List<Room> roomlist = roomService.findRoom(room); room = roomlist.get(0); JSONObject jsonObject = new JSONObject(); jsonObject.put("seatList", list); jsonObject.put("row", room.getRow()); jsonObject.put("col", room.getCol()); WriterUtil.write(response, jsonObject.toString()); } catch (Exception e) { e.printStackTrace(); } }
@RequestMapping("dateCombo") public void dateCombo(HttpServletRequest request,HttpServletResponse response){ try { Date todayDate = new Date(); Date tomorrowDate = getNextDay(todayDate); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=211923082708201ce
https://javayms.pages.dev?id=211923082708201ce