AdminController.java 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. package com.persagy.controller;
  2. import com.persagy.domain.*;
  3. import com.persagy.service.ReservationService;
  4. import com.persagy.service.RoomService;
  5. import com.persagy.service.UserService;
  6. import org.springframework.stereotype.Controller;
  7. import org.springframework.ui.Model;
  8. import org.springframework.web.bind.annotation.RequestMapping;
  9. import org.springframework.web.bind.annotation.RequestMethod;
  10. import javax.annotation.Resource;
  11. import java.util.List;
  12. /**
  13. * Created by Admiral on 2018/1/19.
  14. */
  15. @Controller
  16. @RequestMapping("/admin")
  17. public class AdminController {
  18. @Resource(name = "roomServiceImpl")
  19. private RoomService roomService;
  20. @Resource(name = "reservationServiceImpl")
  21. private ReservationService reservationService;
  22. @Resource(name = "userServiceImpl")
  23. private UserService userService;
  24. /*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<会议室信息管理>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
  25. // 会议室信息显示
  26. @RequestMapping("/showRoom")
  27. public String showRoom(Model model, Integer page) throws Exception {
  28. List<Room> list = null;
  29. //页码对象
  30. PagingVO pagingVO = new PagingVO();
  31. //设置总页数
  32. pagingVO.setTotalCount(roomService.roomCount());
  33. if (page == null || page == 0) {
  34. pagingVO.setToPageNo(1);
  35. list = roomService.findByPaging(1);
  36. } else {
  37. pagingVO.setToPageNo(page);
  38. list = roomService.findByPaging(page);
  39. }
  40. model.addAttribute("roomList", list);
  41. model.addAttribute("pagingVO", pagingVO);
  42. return "/admin/showRoom";
  43. }
  44. //搜索会议室
  45. @RequestMapping(value = "/queryRoom", method = {RequestMethod.POST})
  46. private String queryRoom(String findByName, Model model) throws Exception {
  47. List<Room> list = roomService.findByName(findByName);
  48. model.addAttribute("roomList", list);
  49. return "/admin/showRoom";
  50. }
  51. //添加会议室页面跳转
  52. @RequestMapping(value = "/addRoom", method = {RequestMethod.GET})
  53. public String addRoom(Model model) throws Exception {
  54. return "/admin/addRoom";
  55. }
  56. //添加会议室业务实现
  57. @RequestMapping(value = "/addRoom", method = {RequestMethod.POST})
  58. public String addRoom(Room room, Model model) throws Exception {
  59. roomService.add(room);
  60. return "redirect:/admin/showRoom";
  61. }
  62. // 修改会议室信息页面显示
  63. @RequestMapping(value = "/editRoom", method = {RequestMethod.GET})
  64. public String editRoomUI(Integer id, Model model) throws Exception {
  65. if (id == null) {
  66. return "redirect:/admin/showRoom";
  67. }
  68. Room room = roomService.findById(id);
  69. model.addAttribute("roomList", room);
  70. return "/admin/editRoom";
  71. }
  72. // 修改会议室信息页面处理
  73. @RequestMapping(value = "/editRoom", method = {RequestMethod.POST})
  74. public String editRoom(Room room) throws Exception {
  75. roomService.updateById(room);
  76. //重定向
  77. return "redirect:/admin/showRoom";
  78. }
  79. // 删除会议室信息
  80. @RequestMapping("/removeRoom")
  81. public String removeRoom(Integer id) throws Exception {
  82. if (id == null) {
  83. //加入没有带教师id就进来的话就返回教师显示页面
  84. return "/admin/showRoom";
  85. }
  86. roomService.removeById(id);
  87. return "redirect:/admin/showRoom";
  88. }
  89. /*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<会议室预约管理>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
  90. //查询所有待审核预约记录
  91. @RequestMapping("/showReservation")
  92. public String findAllReservation(Model model,Integer page) throws Exception {
  93. List<ReservationVo> list = null;
  94. //页码对象
  95. PagingVO pagingVO = new PagingVO();
  96. //设置总页数
  97. pagingVO.setTotalCount(reservationService.reservationCount());
  98. if (page == null || page == 0) {
  99. pagingVO.setToPageNo(1);
  100. list = reservationService.findByPaging(1);
  101. } else {
  102. pagingVO.setToPageNo(page);
  103. list = reservationService.findByPaging(page);
  104. }
  105. model.addAttribute("reservationList", list);
  106. model.addAttribute("pagingVO", pagingVO);
  107. return "/admin/showReservation";
  108. }
  109. //搜索借用人
  110. @RequestMapping(value = "queryUser", method = {RequestMethod.POST})
  111. private String queryUser(String findByName, Model model) throws Exception {
  112. List<Reservation> list = reservationService.findByName(findByName);
  113. model.addAttribute("reservationList", list);
  114. return "/admin/showReservation";
  115. }
  116. //同意会议室申请
  117. @RequestMapping("/reviewReservation")
  118. public String reviewReservation(Integer id) throws Exception{
  119. reservationService.reviewReservation(id);
  120. return "redirect:/admin/showReservation";
  121. }
  122. //查询所有审核通过预约记录
  123. @RequestMapping("/showRecord")
  124. public String findRecord(Model model,Integer page) throws Exception{
  125. List<ReservationVo> list = null;
  126. //页码对象
  127. PagingVO pagingVO = new PagingVO();
  128. //设置总页数
  129. pagingVO.setTotalCount(reservationService.reservationPassCount());
  130. if (page == null || page == 0) {
  131. pagingVO.setToPageNo(1);
  132. list = reservationService.findRecord(1);
  133. } else {
  134. pagingVO.setToPageNo(page);
  135. list = reservationService.findRecord(page);
  136. }
  137. model.addAttribute("recordList", list);
  138. model.addAttribute("pagingVo", pagingVO);
  139. return "/admin/showRecord";
  140. }
  141. /*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<用户信息管理>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
  142. //添加新用户
  143. @RequestMapping(value = "/userRegister", method = {RequestMethod.GET})
  144. public String userRegister(Model model) throws Exception {
  145. return "/admin/userRegister";
  146. }
  147. @RequestMapping(value = "/userRegister",method = RequestMethod.POST)
  148. public String userRegister(User user) throws Exception{
  149. if(user.getId()!=null && user.getId()!="" && user.getPassword()!=null && user.getPassword()!=""){
  150. userService.addNewUser(user);
  151. }
  152. return "redirect:/admin/userRegister";
  153. }
  154. }