From b4bafc1866e66a661a54ca0523c20a4446fbc15d Mon Sep 17 00:00:00 2001 From: shoqying Date: Wed, 11 Dec 2024 09:29:26 +0900 Subject: [PATCH 1/7] =?UTF-8?q?cri=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ReceivingController.java | 37 +- .../com/stockm8/persistence/ReceivingDAO.java | 2 +- .../stockm8/persistence/ReceivingDAOImpl.java | 3 +- .../com/stockm8/service/ReceivingService.java | 2 +- .../stockm8/service/ReceivingServiceImpl.java | 5 +- .../WEB-INF/views/receiving/history.jsp | 8 +- .../webapp/WEB-INF/views/receiving/search.jsp | 329 ++++++++++++++++++ 7 files changed, 354 insertions(+), 32 deletions(-) create mode 100644 stockMate/src/main/webapp/WEB-INF/views/receiving/search.jsp diff --git a/stockMate/src/main/java/com/stockm8/controller/ReceivingController.java b/stockMate/src/main/java/com/stockm8/controller/ReceivingController.java index 1e20500..1d7f65b 100644 --- a/stockMate/src/main/java/com/stockm8/controller/ReceivingController.java +++ b/stockMate/src/main/java/com/stockm8/controller/ReceivingController.java @@ -56,36 +56,31 @@ public String historyGET(@RequestParam(value = "startDate", required = false) St List ReceivingList; + int totalCount = 0; + // 날짜와 키워드가 모두 있는 경우 if (startDate != null && endDate != null && keyword != null) { ReceivingList = rService.getHistoryByDateRange(startDate, endDate, keyword, cri); - int totalCount = rService.getTotalCountBySearch(startDate, endDate, keyword, cri); - PageVO pageVO = new PageVO(); - pageVO.setCri(cri); - pageVO.setTotalCount(totalCount); // 총 개수를 검색 조건에 맞게 계산 - model.addAttribute("pageVO", pageVO); + totalCount = rService.getTotalCountBySearch(startDate, endDate, keyword); + } else if (keyword != null) { ReceivingList = rService.getHistoryByDateRange(null, null, keyword, cri); - int totalCount = rService.getTotalCountBySearch(null, null, keyword, cri); - PageVO pageVO = new PageVO(); - pageVO.setCri(cri); - pageVO.setTotalCount(totalCount); - model.addAttribute("pageVO", pageVO); + totalCount = rService.getTotalCountBySearch(null, null, keyword); + } else if (startDate != null && endDate != null) { ReceivingList = rService.getHistoryByDateRange(startDate, endDate, null, cri); - int totalCount = rService.getTotalCountBySearch(startDate, endDate, null, cri); - PageVO pageVO = new PageVO(); - pageVO.setCri(cri); - pageVO.setTotalCount(totalCount); - model.addAttribute("pageVO", pageVO); + totalCount = rService.getTotalCountBySearch(startDate, endDate, null); + } else { ReceivingList = rService.getReceivingHistoryList(cri); - int totalCount = rService.getTotalCount(); // 전체 개수 - PageVO pageVO = new PageVO(); - pageVO.setCri(cri); - pageVO.setTotalCount(totalCount); - model.addAttribute("pageVO", pageVO); + totalCount = rService.getTotalCount(); // 전체 개수 + } + + PageVO pageVO = new PageVO(); + pageVO.setCri(cri); + pageVO.setTotalCount(totalCount); + model.addAttribute("pageVO", pageVO); logger.info(ReceivingList.size() + "개"); model.addAttribute("ReceivingList", ReceivingList); @@ -98,4 +93,4 @@ public String historyGET(@RequestParam(value = "startDate", required = false) St -} // ReceivingController end +} // ReceivingController end \ No newline at end of file diff --git a/stockMate/src/main/java/com/stockm8/persistence/ReceivingDAO.java b/stockMate/src/main/java/com/stockm8/persistence/ReceivingDAO.java index 9117ff8..2bfb7d2 100644 --- a/stockMate/src/main/java/com/stockm8/persistence/ReceivingDAO.java +++ b/stockMate/src/main/java/com/stockm8/persistence/ReceivingDAO.java @@ -23,7 +23,7 @@ public interface ReceivingDAO { public List selectHistoryByDateRange(String startDate, String endDate, String keyword, Criteria cri) throws Exception; // 검색시 모든 리스트 개수 - public int selectTotalCountBySearch(String startDate, String endDate, String keyword, Criteria cri) throws Exception; + public int selectTotalCountBySearch(String startDate, String endDate, String keyword) throws Exception; // 리스트 모든 개수 public int selectTotalCount() throws Exception; diff --git a/stockMate/src/main/java/com/stockm8/persistence/ReceivingDAOImpl.java b/stockMate/src/main/java/com/stockm8/persistence/ReceivingDAOImpl.java index ac9220b..d0868a8 100644 --- a/stockMate/src/main/java/com/stockm8/persistence/ReceivingDAOImpl.java +++ b/stockMate/src/main/java/com/stockm8/persistence/ReceivingDAOImpl.java @@ -72,13 +72,12 @@ public List selectHistoryByDateRange(String startDate, Stri } @Override - public int selectTotalCountBySearch(String startDate, String endDate, String keyword, Criteria cri) throws Exception { + public int selectTotalCountBySearch(String startDate, String endDate, String keyword) throws Exception { Map paramMap = new HashMap<>(); paramMap.put("startDate", startDate); paramMap.put("endDate", endDate); paramMap.put("keyword", keyword); - paramMap.put("cri", cri); return sqlSession.selectOne(NAMESPACE + "getTotalCountBySearch", paramMap); } diff --git a/stockMate/src/main/java/com/stockm8/service/ReceivingService.java b/stockMate/src/main/java/com/stockm8/service/ReceivingService.java index b9b8592..e1d6f36 100644 --- a/stockMate/src/main/java/com/stockm8/service/ReceivingService.java +++ b/stockMate/src/main/java/com/stockm8/service/ReceivingService.java @@ -24,7 +24,7 @@ public interface ReceivingService { public List getHistoryByDateRange(String startDate, String endDate, String keyword, Criteria cri) throws Exception; // 입고 내역 검색 - public int getTotalCountBySearch(String startDate, String endDate, String keyword, Criteria cri) throws Exception; + public int getTotalCountBySearch(String startDate, String endDate, String keyword) throws Exception; // 글 모든 개수 public int getTotalCount() throws Exception; diff --git a/stockMate/src/main/java/com/stockm8/service/ReceivingServiceImpl.java b/stockMate/src/main/java/com/stockm8/service/ReceivingServiceImpl.java index dda4167..b3c6b7c 100644 --- a/stockMate/src/main/java/com/stockm8/service/ReceivingServiceImpl.java +++ b/stockMate/src/main/java/com/stockm8/service/ReceivingServiceImpl.java @@ -52,10 +52,9 @@ public List getHistoryByDateRange(String startDate, String } @Override - public int getTotalCountBySearch(String startDate, String endDate, String keyword, - Criteria cri) throws Exception { + public int getTotalCountBySearch(String startDate, String endDate, String keyword) throws Exception { logger.info("getTotalCountBySearch() 호출"); - return rdao.selectTotalCountBySearch(startDate, endDate, keyword, cri); + return rdao.selectTotalCountBySearch(startDate, endDate, keyword); } @Override diff --git a/stockMate/src/main/webapp/WEB-INF/views/receiving/history.jsp b/stockMate/src/main/webapp/WEB-INF/views/receiving/history.jsp index 76c8bc2..a54195c 100644 --- a/stockMate/src/main/webapp/WEB-INF/views/receiving/history.jsp +++ b/stockMate/src/main/webapp/WEB-INF/views/receiving/history.jsp @@ -241,7 +241,7 @@ tr:hover { 입고 메인 -