OrdinaryController.java 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. package com.persagy.controller;
  2. import com.fasterxml.jackson.databind.ObjectMapper;
  3. import com.persagy.domain.*;
  4. import com.persagy.service.ReservationService;
  5. import com.persagy.service.RoomService;
  6. import com.persagy.service.UserService;
  7. import org.springframework.stereotype.Controller;
  8. import org.springframework.ui.Model;
  9. import org.springframework.web.bind.annotation.RequestMapping;
  10. import org.springframework.web.bind.annotation.RequestMethod;
  11. import org.springframework.web.bind.annotation.ResponseBody;
  12. import javax.annotation.Resource;
  13. import java.util.List;
  14. /**
  15. * Created by Admiral on 2018/1/20.
  16. */
  17. @Controller
  18. @ResponseBody
  19. @RequestMapping("/ordinary")
  20. public class OrdinaryController {
  21. @Resource(name = "roomServiceImpl")
  22. private RoomService roomService;
  23. @Resource(name = "reservationServiceImpl")
  24. private ReservationService reservationService;
  25. /**
  26. * 获取会议室列表
  27. * @return
  28. * @throws Exception
  29. */
  30. @RequestMapping(value="/roomList", method=RequestMethod.GET)
  31. @ResponseBody
  32. public List<Room> roomList() throws Exception {
  33. List<Room> list = roomService.findByPaging(1);
  34. return list;
  35. }
  36. /**
  37. * 根据会议室名称模糊搜索会议室
  38. * @param roomName
  39. * @return
  40. * @throws Exception
  41. */
  42. @RequestMapping(value = "/queryRoomByName", method = {RequestMethod.POST,RequestMethod.GET})
  43. private List<Room> queryRoomByName(String roomName) throws Exception {
  44. List<Room> list = roomService.findByName(roomName);
  45. return list;
  46. }
  47. /**
  48. * 根据会议室id查询会议室详情
  49. * @param roomID
  50. * @return
  51. * @throws Exception
  52. */
  53. @RequestMapping(value = "/queryRoomById", method = {RequestMethod.POST,RequestMethod.GET})
  54. private Room queryRoomById(Integer roomID) throws Exception {
  55. Room room = roomService.findById(roomID);
  56. return room;
  57. }
  58. /**
  59. * 查询所有的会议室预约记录
  60. * @return
  61. * @throws Exception
  62. */
  63. @RequestMapping("/showRecord")
  64. public List<ReservationVo> findAllReservation() throws Exception {
  65. List<ReservationVo> list = null;
  66. list = reservationService.findAllByPaging(1);
  67. return list;
  68. }
  69. /**
  70. * 根据会议室id查询会议室记录
  71. * @param id
  72. * @return
  73. * @throws Exception
  74. */
  75. @RequestMapping("/showRecordByRoomId")
  76. public List<ReservationVo> findAllReservationByRoomId(Integer id) throws Exception {
  77. List<ReservationVo> list = null;
  78. list = reservationService.findByRoomId(id);
  79. return list;
  80. }
  81. //搜索借用人
  82. /**
  83. * 搜索我组织的会议
  84. * @param userName
  85. * @return
  86. * @throws Exception
  87. */
  88. @RequestMapping(value = "/queryByUser")
  89. private List<ReservationVo> queryUser(String userName) throws Exception {
  90. List<ReservationVo> list = reservationService.queryByUser(userName);
  91. return list;
  92. }
  93. //预约会议室页面跳转
  94. @RequestMapping(value = "/reserveRoom", method = RequestMethod.GET)
  95. public String reserveRoomUI(Model model) throws Exception {
  96. //从数据库查询出所有会议室信息回显到页面
  97. List<Room> list = roomService.nameList();
  98. model.addAttribute("nameList", list);
  99. return "/ordinary/reserveRoom";
  100. }
  101. //预约会议室功能实现
  102. @RequestMapping(value = "/reserveRoom", method = RequestMethod.POST)
  103. public String reserveRoom(ReservationCustom reservationCustom) throws Exception {
  104. reservationService.addReservation(reservationCustom);
  105. return "redirect:/ordinary/showRecord";
  106. }
  107. //取消预约申请页面跳转
  108. @RequestMapping(value = "/cancelApplication",method = RequestMethod.GET)
  109. public String cancelApplicationUI(String user,Model model) throws Exception{
  110. List<ReservationCustom> list=reservationService.findByUser(user);
  111. model.addAttribute("reserveList",list);
  112. return "/ordinary/cancelApplication";
  113. }
  114. //取消预约申请业务实现
  115. @RequestMapping("/cancelApply")
  116. public String cancelApplication(Integer id) throws Exception{
  117. reservationService.cancelApplication(id);
  118. return "redirect:/ordinary/showRecord";
  119. }
  120. }