Procházet zdrojové kódy

修改会议室查询,会议查询接口

lgy před 6 roky
rodič
revize
074a3273ab

+ 60 - 62
src/main/java/com/persagy/controller/OrdinaryController.java

@@ -18,6 +18,7 @@ import java.util.List;
  * Created by Admiral on 2018/1/20.
  */
 @Controller
+@ResponseBody
 @RequestMapping("/ordinary")
 public class OrdinaryController {
 
@@ -27,82 +28,79 @@ public class OrdinaryController {
     @Resource(name = "reservationServiceImpl")
     private ReservationService reservationService;
 
-    @RequestMapping(value="/getString", method=RequestMethod.GET)
+    /**
+     * 获取会议室列表
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value="/roomList", method=RequestMethod.GET)
     @ResponseBody
-    public String getString() throws Exception {
-        List<Room> list = null;
-        list = roomService.findByPaging(1);
-        ObjectMapper mapper = new ObjectMapper();
-        String jsonString = mapper.writeValueAsString(list);
-        return jsonString;
+    public List<Room> roomList() throws Exception {
+        List<Room> list = roomService.findByPaging(1);
+        return list;
     }
 
-    /*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<会议室信息管理>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
-    // 会议室信息显示
-    @RequestMapping("/showRoom")
-    public String showRoom(Model model, Integer page) throws Exception {
-
-        List<Room> list = null;
-        //页码对象
-        PagingVO pagingVO = new PagingVO();
-        //设置总页数
-        pagingVO.setTotalCount(roomService.roomCount());
-        if (page == null || page == 0) {
-            pagingVO.setToPageNo(1);
-            list = roomService.findByPaging(1);
-        } else {
-            pagingVO.setToPageNo(page);
-            list = roomService.findByPaging(page);
-        }
-
-        model.addAttribute("roomList", list);
-        model.addAttribute("pagingVO", pagingVO);
-
-        return "/ordinary/showRoom";
+    /**
+     * 根据会议室名称模糊搜索会议室
+     * @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;
     }
 
-    //搜索会议室
-    @RequestMapping(value = "/queryRoom", method = {RequestMethod.POST})
-    private String queryRoom(String findByName, Model model) throws Exception {
-
-        List<Room> list = roomService.findByName(findByName);
-
-        model.addAttribute("roomList", list);
-        return "/ordinary/showRoom";
+    /**
+     * 根据会议室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;
     }
 
-    //查询接下来的15天内所有已被预约的会议室记录
+    /**
+     * 查询所有的会议室预约记录
+     * @return
+     * @throws Exception
+     */
     @RequestMapping("/showRecord")
-    public String findAllReservation(Model model, Integer page) throws Exception {
+    public List<ReservationVo> findAllReservation() throws Exception {
         List<ReservationVo> list = null;
+        list = reservationService.findAllByPaging(1);
+        return list;
+    }
 
-        //页码对象
-        PagingVO pagingVO = new PagingVO();
-        //设置总页数
-        pagingVO.setTotalCount(reservationService.reserveCount());
-        if (page == null || page == 0) {
-            pagingVO.setToPageNo(1);
-            list = reservationService.findAllByPaging(1);
-        } else {
-            pagingVO.setToPageNo(page);
-            list = reservationService.findAllByPaging(page);
-        }
-
-        model.addAttribute("recordList", list);
-        model.addAttribute("pagingVo", pagingVO);
-
-        return "/ordinary/showRecord";
+    /**
+     * 根据会议室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;
     }
 
     //搜索借用人
-    @RequestMapping(value = "/queryByUser", method = {RequestMethod.POST})
-    private String queryUser(String findByName, Model model) throws Exception {
-
-        List<ReservationVo> list = reservationService.queryByUser(findByName);
-
-        model.addAttribute("recordList", list);
 
-        return "/ordinary/showRecord";
+    /**
+     * 搜索我组织的会议
+     * @param userName
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "/queryByUser")
+    private List<ReservationVo> queryUser(String userName) throws Exception {
+        List<ReservationVo> list = reservationService.queryByUser(userName);
+        return list;
     }
 
     //预约会议室页面跳转

+ 2 - 0
src/main/java/com/persagy/dao/ReservationMapper.java

@@ -17,6 +17,8 @@ public interface ReservationMapper {
 
     public List<Reservation> findByName(String name);
 
+    public List<ReservationVo> findByRoomId(Integer id);
+
     public Integer reservationPassCount();
 
     public List<ReservationVo> findRecord(PagingVO pagingVO);

+ 6 - 0
src/main/java/com/persagy/dao/ReservationMapper.xml

@@ -30,6 +30,12 @@
         WHERE date>CURDATE() AND a.mark='待审核' AND a.user LIKE '%${value}%' ORDER BY id
     </select>
 
+    <select id="findByRoomId" parameterType="int" resultType="com.persagy.domain.ReservationVo">
+        SELECT a.id,b.`name` ,a.date,a.begintime,a.endtime,a.`user`,a.mobile,a.mark FROM reservation a
+        LEFT JOIN room b on a.room_id=b.id
+        WHERE date>CURDATE() AND mark!='取消申请' AND a.room_id=#{id} ORDER BY id
+    </select>
+
     <select id="reservationPassCount" resultType="int">
         SELECT count(*) FROM reservation a WHERE date BETWEEN CURDATE()-30 AND CURDATE() AND a.mark='审核通过' ORDER BY date DESC
     </select>

+ 1 - 1
src/main/java/com/persagy/domain/PagingVO.java

@@ -10,7 +10,7 @@ public class PagingVO {
     //总页数
     private int totalCount;
     //页面容量
-    private int pageSize=5;
+    private int pageSize=500;
     //上一页
     private int upPageNo;
     //下一页

+ 6 - 1
src/main/java/com/persagy/service/ReservationService.java

@@ -28,7 +28,12 @@ public interface ReservationService {
      * @return
      */
     public List<Reservation> findByName(String name);
-
+    /**
+     * 根据会议室ID查询其所有预约记录
+     * @param id
+     * @return
+     */
+    public List<ReservationVo> findByRoomId(Integer id);
     /**
      * 查询15天内的审核通过的预约总数
      * @return

+ 4 - 1
src/main/java/com/persagy/service/impl/ReservationServiceImpl.java

@@ -38,7 +38,10 @@ public class ReservationServiceImpl implements ReservationService {
     public List<Reservation> findByName(String name) {
         return reservationMapper.findByName(name);
     }
-
+    @Override
+    public List<ReservationVo> findByRoomId(Integer id){
+        return reservationMapper.findByRoomId(id);
+    }
     @Override
     public Integer reservationPassCount() {
         return reservationMapper.reservationPassCount();