| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- 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<Room> roomList() throws Exception {
- List<Room> list = roomService.findByPaging(1);
- return list;
- }
- /**
- * 根据会议室名称模糊搜索会议室
- * @param roomName
- * @return
- * @throws Exception
- */
- @RequestMapping(value = "/queryRoomByName", method = {RequestMethod.POST,RequestMethod.GET})
- private List<Room> queryRoomByName(String roomName) throws Exception {
- List<Room> 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<ReservationVo> findAllReservation() throws Exception {
- List<ReservationVo> list = null;
- list = reservationService.findAllByPaging(1);
- return list;
- }
- /**
- * 根据会议室id查询会议室记录
- * @param id
- * @return
- * @throws Exception
- */
- @RequestMapping("/showRecordByRoomId")
- public List<ReservationVo> findAllReservationByRoomId(Integer id) throws Exception {
- List<ReservationVo> list = null;
- list = reservationService.findByRoomId(id);
- return list;
- }
- //搜索借用人
- /**
- * 搜索我组织的会议
- * @param userName
- * @return
- * @throws Exception
- */
- @RequestMapping(value = "/queryByUser")
- private List<ReservationVo> queryUser(String userName) throws Exception {
- List<ReservationVo> list = reservationService.queryByUser(userName);
- return list;
- }
- //预约会议室页面跳转
- @RequestMapping(value = "/reserveRoom", method = RequestMethod.GET)
- public String reserveRoomUI(Model model) throws Exception {
- //从数据库查询出所有会议室信息回显到页面
- List<Room> 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<ReservationCustom> 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";
- }
- }
|