package com.persagy.controller; import com.fasterxml.jackson.databind.ObjectMapper; import com.persagy.domain.*; import com.persagy.service.ReservationService; import com.persagy.service.RoomService; import com.persagy.service.UserService; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import java.util.List; /** * Created by Admiral on 2018/1/20. */ @Controller @ResponseBody @RequestMapping("/ordinary") public class OrdinaryController { @Resource(name = "roomServiceImpl") private RoomService roomService; @Resource(name = "reservationServiceImpl") private ReservationService reservationService; /** * 获取会议室列表 * @return * @throws Exception */ @RequestMapping(value="/roomList", method=RequestMethod.GET) @ResponseBody public List roomList() throws Exception { List list = roomService.findByPaging(1); return list; } /** * 根据会议室名称模糊搜索会议室 * @param roomName * @return * @throws Exception */ @RequestMapping(value = "/queryRoomByName", method = {RequestMethod.POST,RequestMethod.GET}) private List queryRoomByName(String roomName) throws Exception { List list = roomService.findByName(roomName); return list; } /** * 根据会议室id查询会议室详情 * @param roomID * @return * @throws Exception */ @RequestMapping(value = "/queryRoomById", method = {RequestMethod.POST,RequestMethod.GET}) private Room queryRoomById(Integer roomID) throws Exception { Room room = roomService.findById(roomID); return room; } /** * 查询所有的会议室预约记录 * @return * @throws Exception */ @RequestMapping("/showRecord") public List findAllReservation() throws Exception { List list = null; list = reservationService.findAllByPaging(1); return list; } /** * 根据会议室id查询会议室记录 * @param id * @return * @throws Exception */ @RequestMapping("/showRecordByRoomId") public List findAllReservationByRoomId(Integer id) throws Exception { List list = null; list = reservationService.findByRoomId(id); return list; } //搜索借用人 /** * 搜索我组织的会议 * @param userName * @return * @throws Exception */ @RequestMapping(value = "/queryByUser") private List queryUser(String userName) throws Exception { List list = reservationService.queryByUser(userName); return list; } //预约会议室页面跳转 @RequestMapping(value = "/reserveRoom", method = RequestMethod.GET) public String reserveRoomUI(Model model) throws Exception { //从数据库查询出所有会议室信息回显到页面 List list = roomService.nameList(); model.addAttribute("nameList", list); return "/ordinary/reserveRoom"; } //预约会议室功能实现 @RequestMapping(value = "/reserveRoom", method = RequestMethod.POST) public String reserveRoom(ReservationCustom reservationCustom) throws Exception { reservationService.addReservation(reservationCustom); return "redirect:/ordinary/showRecord"; } //取消预约申请页面跳转 @RequestMapping(value = "/cancelApplication",method = RequestMethod.GET) public String cancelApplicationUI(String user,Model model) throws Exception{ List list=reservationService.findByUser(user); model.addAttribute("reserveList",list); return "/ordinary/cancelApplication"; } //取消预约申请业务实现 @RequestMapping("/cancelApply") public String cancelApplication(Integer id) throws Exception{ reservationService.cancelApplication(id); return "redirect:/ordinary/showRecord"; } }