diff --git a/stockMate/src/main/java/com/stockm8/controller/ProductController.java b/stockMate/src/main/java/com/stockm8/controller/ProductController.java index 88e6791..c3ed001 100644 --- a/stockMate/src/main/java/com/stockm8/controller/ProductController.java +++ b/stockMate/src/main/java/com/stockm8/controller/ProductController.java @@ -39,10 +39,10 @@ public class ProductController { @Autowired private ProductService productService; - + @Autowired private UserService userService; - + @Autowired private CategoryService categoryService; @@ -51,23 +51,23 @@ public class ProductController { @GetMapping("/register") public String productRegistGET(Model model, HttpServletRequest request) throws Exception { logger.info("productRegistGET() 호출"); - - // 세션에서 userId 가져오기 - HttpSession session = request.getSession(false); - Long userId = (session != null) ? (Long)session.getAttribute("userId") : null; - - // userId로 사용자 정보 조회 - UserVO user = userService.getUserById(userId); - int businessId = user.getBusinessId(); - - // DB에서 카테고리 정보 가져오기 - List categoryList = categoryService.getCategoriesByBusinessId(businessId); - - // 모델에 데이터 추가 - model.addAttribute("categoryList", categoryList); - - // 창고 정보와 카테고리 정보가 없으면 추가 버튼 표시를 위한 플래그 설정 - model.addAttribute("hasCategories", !categoryList.isEmpty()); + + // 세션에서 userId 가져오기 + HttpSession session = request.getSession(false); + Long userId = (session != null) ? (Long) session.getAttribute("userId") : null; + + // userId로 사용자 정보 조회 + UserVO user = userService.getUserById(userId); + int businessId = user.getBusinessId(); + + // DB에서 카테고리 정보 가져오기 + List categoryList = categoryService.getCategoriesByBusinessId(businessId); + + // 모델에 데이터 추가 + model.addAttribute("categoryList", categoryList); + + // 창고 정보와 카테고리 정보가 없으면 추가 버튼 표시를 위한 플래그 설정 + model.addAttribute("hasCategories", !categoryList.isEmpty()); logger.info("연결된 뷰페이지(/product/register.jsp) 이동"); return "product/register"; // 상품 등록 페이지로 이동 @@ -75,137 +75,134 @@ public String productRegistGET(Model model, HttpServletRequest request) throws E // 상품 등록 처리 @PostMapping("/register") - public String productRegistPOST(ProductVO product, - @SessionAttribute("userId") Long userId, - HttpServletRequest request, - RedirectAttributes rttr) throws Exception { + public String productRegistPOST(ProductVO product, @SessionAttribute("userId") Long userId, + HttpServletRequest request, RedirectAttributes rttr) throws Exception { logger.info("productRegistPOST() 호출"); // 전달정보(파라미터) 확인 logger.info("product: {}", product); - - // 사용자 정보 및 회사정보 가져오기 - UserVO user = userService.getUserById(userId); - int businessId = user.getBusinessId(); - logger.info("Business ID for user: {}", businessId); - - // user의 businessId 설정 - product.setBusinessId(user.getBusinessId()); - - // DB등록처리 / Service -> DAO -> mapper(sql 호출) + + // 사용자 정보 및 회사정보 가져오기 + UserVO user = userService.getUserById(userId); + int businessId = user.getBusinessId(); + logger.info("Business ID for user: {}", businessId); + + // user의 businessId 설정 + product.setBusinessId(user.getBusinessId()); + + // DB등록처리 / Service -> DAO -> mapper(sql 호출) productService.registerProduct(product); - + // DB insert 후 생성된 productId PK int productId = product.getProductId(); - + logger.info("연결된 뷰페이지(/product/detail.jsp) 이동"); return "redirect:/product/detail?productId=" + productId; } - + // QR코드 등록 처리 @GetMapping("/generateQR") public String generateQRGET(@RequestParam("productId") int productId, RedirectAttributes rttr) throws Exception { - logger.info("generateQR() 호출"); - logger.info("전송된 productId: {}", productId); - - if (productId == 0) { - rttr.addFlashAttribute("errorMessage", "유효한 상품 ID가 필요합니다."); - return "redirect:/product/detail?productId=" + productId; - } - - // 상품 정보 가져오기 - ProductVO product = productService.getProductByID(productId); - if (product == null) { - rttr.addFlashAttribute("errorMessage", "상품 정보를 찾을 수 없습니다."); - return "redirect:/product/detail?productId=" + productId; - } - - // QR 코드 생성 (예외 발생 시 @ControllerAdvice에서 처리) - productService.generateQRCode(productId); - rttr.addFlashAttribute("successMessage", "QR 코드가 성공적으로 생성되었습니다. (상품 ID: " + productId + ")"); - return "redirect:/product/detail?productId=" + productId; + logger.info("generateQR() 호출"); + logger.info("전송된 productId: {}", productId); + + if (productId == 0) { + rttr.addFlashAttribute("errorMessage", "유효한 상품 ID가 필요합니다."); + return "redirect:/product/detail?productId=" + productId; + } + + // 상품 정보 가져오기 + ProductVO product = productService.getProductByID(productId); + if (product == null) { + rttr.addFlashAttribute("errorMessage", "상품 정보를 찾을 수 없습니다."); + return "redirect:/product/detail?productId=" + productId; + } + + // QR 코드 생성 (예외 발생 시 @ControllerAdvice에서 처리) + productService.generateQRCode(productId); + rttr.addFlashAttribute("successMessage", "QR 코드가 성공적으로 생성되었습니다. (상품 ID: " + productId + ")"); + return "redirect:/product/detail?productId=" + productId; } // http://localhost:8088/product/downloadQr // QR코드 다운로드 처리 @GetMapping("/downloadQr") - public void downloadQrCodeGET( - @RequestParam("productId") int productId, - HttpServletResponse response) throws Exception { - - // 상품 정보 가져오기 - ProductVO product = productService.getProductByID(productId); - if (product == null || product.getProductQrCodePath() == null) { - throw new IllegalArgumentException("QR 코드가 존재하지 않습니다."); - } - - // QR 코드 파일 경로 - File qrCodeFile = new File(product.getProductQrCodePath()); - if (!qrCodeFile.exists()) { - throw new IllegalArgumentException("QR 코드 파일이 존재하지 않습니다."); - } - - // 파일명 인코딩 (한글 처리 포함) - String encodedFileName = URLEncoder.encode(qrCodeFile.getName(), "UTF-8").replaceAll("\\+", "%20"); - - // 파일 다운로드 설정 - response.setContentType("application/octet-stream"); - response.setHeader("Content-Disposition", "attachment; filename=\"" + encodedFileName + "\""); - response.setContentLengthLong(qrCodeFile.length()); - - // 파일 데이터 출력 - try (FileInputStream fileInputStream = new FileInputStream(qrCodeFile); - OutputStream outputStream = response.getOutputStream()) { - byte[] buffer = new byte[1024]; - int bytesRead; - while ((bytesRead = fileInputStream.read(buffer)) != -1) { - outputStream.write(buffer, 0, bytesRead); - } - outputStream.flush(); - } + public void downloadQrCodeGET(@RequestParam("productId") int productId, HttpServletResponse response) + throws Exception { + + // 상품 정보 가져오기 + ProductVO product = productService.getProductByID(productId); + if (product == null || product.getProductQrCodePath() == null) { + throw new IllegalArgumentException("QR 코드가 존재하지 않습니다."); + } + + // QR 코드 파일 경로 + File qrCodeFile = new File(product.getProductQrCodePath()); + if (!qrCodeFile.exists()) { + throw new IllegalArgumentException("QR 코드 파일이 존재하지 않습니다."); + } + + // 파일명 인코딩 (한글 처리 포함) + String encodedFileName = URLEncoder.encode(qrCodeFile.getName(), "UTF-8").replaceAll("\\+", "%20"); + + // 파일 다운로드 설정 + response.setContentType("application/octet-stream"); + response.setHeader("Content-Disposition", "attachment; filename=\"" + encodedFileName + "\""); + response.setContentLengthLong(qrCodeFile.length()); + + // 파일 데이터 출력 + try (FileInputStream fileInputStream = new FileInputStream(qrCodeFile); + OutputStream outputStream = response.getOutputStream()) { + byte[] buffer = new byte[1024]; + int bytesRead; + while ((bytesRead = fileInputStream.read(buffer)) != -1) { + outputStream.write(buffer, 0, bytesRead); + } + outputStream.flush(); + } } - + // http://localhost:8088/product/detail // 상품 상세 정보 페이지 @GetMapping("/detail") public String detailGET(@RequestParam("productId") int productId, Model model) throws Exception { - // 상품 상세 정보 조회 - ProductVO product = productService.getProductByID(productId); - if (product == null) { - throw new IllegalArgumentException("상품 정보를 찾을 수 없습니다. productId: " + productId); - } - - // 카테고리명 조회 - String categoryName = categoryService.getCategoryNameById(product.getCategoryId()); - if (categoryName == null) { - categoryName = "알 수 없음"; // 카테고리가 없을 경우 기본값 설정 - } - - // 뷰(JSP)에서 EL로 접근할 수 있도록 Model에 상품 및 카테고리 정보 등록 - model.addAttribute("product", product); - model.addAttribute("categoryName", categoryName); - - logger.info("연결된 뷰페이지(/product/detail.jsp) 이동"); - return "product/detail"; // JSP 파일 경로 + // 상품 상세 정보 조회 + ProductVO product = productService.getProductByID(productId); + if (product == null) { + throw new IllegalArgumentException("상품 정보를 찾을 수 없습니다. productId: " + productId); + } + + // 카테고리명 조회 + String categoryName = categoryService.getCategoryNameById(product.getCategoryId()); + if (categoryName == null) { + categoryName = "알 수 없음"; // 카테고리가 없을 경우 기본값 설정 + } + + // 뷰(JSP)에서 EL로 접근할 수 있도록 Model에 상품 및 카테고리 정보 등록 + model.addAttribute("product", product); + model.addAttribute("categoryName", categoryName); + + logger.info("연결된 뷰페이지(/product/detail.jsp) 이동"); + return "product/detail"; // JSP 파일 경로 } - + // http://localhost:8088/product/list - @GetMapping("/list") - public String listProductsGET(HttpServletRequest request, Model model) throws Exception{ - // 세션에서 userId 가져오기 - HttpSession session = request.getSession(false); - Long userId = (session != null) ? (Long)session.getAttribute("userId") : null; - - // userId로 사용자 정보 조회 - UserVO user = userService.getUserById(userId); - int businessId = user.getBusinessId(); - - // 비즈니스 ID로 상품 리스트 조회 - List products = productService.getProductsWithQRCode(businessId); - - // 모델에 데이터 추가 - model.addAttribute("products", products); - - return "product/list"; // /WEB-INF/views/product/list.jsp로 매핑 - } + @GetMapping("/list") + public String listProductsGET(HttpServletRequest request, Model model) throws Exception { + // 세션에서 userId 가져오기 + HttpSession session = request.getSession(false); + Long userId = (session != null) ? (Long) session.getAttribute("userId") : null; + + // userId로 사용자 정보 조회 + UserVO user = userService.getUserById(userId); + int businessId = user.getBusinessId(); + + // 비즈니스 ID로 상품 리스트 조회 + List products = productService.getProductsWithQRCode(businessId); + + // 모델에 데이터 추가 + model.addAttribute("products", products); + + return "product/list"; // /WEB-INF/views/product/list.jsp로 매핑 + } } \ No newline at end of file diff --git a/stockMate/src/main/java/com/stockm8/controller/StockController.java b/stockMate/src/main/java/com/stockm8/controller/StockController.java index 91bc134..38174a9 100644 --- a/stockMate/src/main/java/com/stockm8/controller/StockController.java +++ b/stockMate/src/main/java/com/stockm8/controller/StockController.java @@ -8,12 +8,14 @@ import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.SessionAttribute; +import com.stockm8.domain.dto.StockDTO; import com.stockm8.domain.vo.StockVO; import com.stockm8.domain.vo.UserVO; import com.stockm8.domain.vo.WarehouseVO; @@ -79,39 +81,34 @@ public String registerStockPost(@ModelAttribute StockVO stock, // 재고 목록 조회 // http://localhost:8088/stock/list - @RequestMapping(value = "/list", method = RequestMethod.GET) - public String getStockList(@SessionAttribute("userId") Long userId, Model model, - @RequestParam(required = false) Integer warehouseId, - @RequestParam(required = false) String categoryName, - @RequestParam(required = false) Integer minStock, - @RequestParam(required = false) Integer maxStock, - @RequestParam(required = false, defaultValue = "desc") String sortOrder) throws Exception { - logger.info("getStockList 호출"); - - // 사용자 정보 조회 - UserVO user = userService.getUserById(userId); - int businessId = user.getBusinessId(); - - // 창고 목록 조회 - List warehouseList = warehouseService.getWarehousesByBusinessId(businessId); - logger.info("조회된 창고 목록: {}", warehouseList.size()); - - // 창고명과 카테고리명 정보 제공 - model.addAttribute("warehouseList", warehouseList); - model.addAttribute("categoryList", stockService.getCategoryList()); - - // 재고 리스트 조회 - FilterCriteria criteria = new FilterCriteria(warehouseId, categoryName, minStock, maxStock, sortOrder, businessId); - List stockList = stockService.getStockList(criteria, sortOrder); - model.addAttribute("stockList", stockList); - - // 필터링된 파라미터들을 모델에 추가 - model.addAttribute("warehouseId", warehouseId); - model.addAttribute("categoryName", categoryName); - model.addAttribute("minStock", minStock); - model.addAttribute("maxStock", maxStock); - model.addAttribute("sortOrder", sortOrder); - - return "/stock/list"; - } + @GetMapping("/list") + public String getStockList( + @SessionAttribute("userId") Long userId, + @RequestParam(required = false, defaultValue = "updated_at") String sortColumn, + @RequestParam(required = false, defaultValue = "desc") String sortOrder, + Model model) throws Exception { + + logger.info(">>> 재고 리스트 요청 sortColumn: {}, sortOrder: {}", sortColumn, sortOrder); + + // 사용자 정보 조회 + UserVO user = userService.getUserById(userId); + int businessId = user.getBusinessId(); + + // 창고 및 카테고리 리스트 추가 + List warehouseList = warehouseService.getWarehousesByBusinessId(businessId); + model.addAttribute("warehouseList", warehouseList); + model.addAttribute("categoryList", stockService.getCategoryList()); + + // 재고 리스트 조회 + List stockList = stockService.getStockList(businessId, sortColumn, sortOrder); + model.addAttribute("stockList", stockList); + + // 정렬 정보 추가 + model.addAttribute("sortColumn", sortColumn); + model.addAttribute("sortOrder", sortOrder); + + logger.info("조회된 재고 수: {}", stockList.size()); + + return "/stock/list"; + } } diff --git a/stockMate/src/main/java/com/stockm8/controller/UserController.java b/stockMate/src/main/java/com/stockm8/controller/UserController.java index 7b7680d..1f45ba3 100644 --- a/stockMate/src/main/java/com/stockm8/controller/UserController.java +++ b/stockMate/src/main/java/com/stockm8/controller/UserController.java @@ -30,8 +30,6 @@ import java.util.Properties; import javax.mail.PasswordAuthentication; - - @Controller @RequestMapping(value = "/user/*") // *.me 처럼 /user/~ 시작하는 모든주소를 처리하겠다. @@ -51,7 +49,6 @@ public class UserController { // http://localhost:8088/user/main (o) // http://localhost:8088/user/info1 (o) // http://localhost:8088/user/info2 (o) - // http://localhost:8088/dashboard (o) // http://localhost:8088/user/info1 (o) // http://localhost:8088/user/info2 (o) @@ -93,8 +90,7 @@ public String userSignUpPOST(/* @ModelAttribute */ UserVO user) throws Exception // 로그인 - 정보입력 / GET @RequestMapping(value = "/signin", method = RequestMethod.GET) public String userSgininGET(HttpServletRequest request, Model model) { - logger.info("userSgininGET(HttpServletRequest request, Model model) 호출 "); - logger.info("!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"); + logger.info("userSgininGET() 호출 "); // FlashMap에서 에러 메시지 확인 Map flashMap = RequestContextUtils.getInputFlashMap(request); diff --git a/stockMate/src/main/java/com/stockm8/domain/dto/StockDTO.java b/stockMate/src/main/java/com/stockm8/domain/dto/StockDTO.java new file mode 100644 index 0000000..e602b58 --- /dev/null +++ b/stockMate/src/main/java/com/stockm8/domain/dto/StockDTO.java @@ -0,0 +1,18 @@ +package com.stockm8.domain.dto; + +import java.sql.Timestamp; + +import lombok.Data; + +@Data +public class StockDTO { + private Integer productId; // 상품 ID + private String productName; // 상품명 + private String productBarcode; // 바코드 + private String categoryName; // 카테고리명 + private Integer warehouseId; // 창고 ID + private String warehouseName; // 창고명 + private int totalQuantity; // 총 재고 수량 + private int availableStock; // 사용 가능한 재고 + private Timestamp updatedAt; // 최근 수정 시간 +} \ No newline at end of file diff --git a/stockMate/src/main/java/com/stockm8/domain/vo/WarehouseVO.java b/stockMate/src/main/java/com/stockm8/domain/vo/WarehouseVO.java index 9be9d3f..fb4cabd 100644 --- a/stockMate/src/main/java/com/stockm8/domain/vo/WarehouseVO.java +++ b/stockMate/src/main/java/com/stockm8/domain/vo/WarehouseVO.java @@ -20,5 +20,4 @@ public class WarehouseVO { private String warehouseDescription; // 창고에 대한 상세 설명 private WarehouseStatus warehouseStatus; // 창고 상태 ('active', 'inactive') private boolean isDeleted; // 논리 삭제 여부 (true: 삭제됨, false: 활성) - } diff --git a/stockMate/src/main/java/com/stockm8/persistence/StockDAO.java b/stockMate/src/main/java/com/stockm8/persistence/StockDAO.java index 2891526..2de3914 100644 --- a/stockMate/src/main/java/com/stockm8/persistence/StockDAO.java +++ b/stockMate/src/main/java/com/stockm8/persistence/StockDAO.java @@ -1,5 +1,6 @@ package com.stockm8.persistence; +import com.stockm8.domain.dto.StockDTO; import com.stockm8.domain.vo.CategoryVO; import com.stockm8.domain.vo.StockVO; @@ -14,7 +15,7 @@ public interface StockDAO { public List selectFilteredStocks(FilterCriteria criteria, String sortOrder) throws Exception; // 사업자 ID에 해당하는 재고 목록 조회 - public List selectStockListByBusinessId(int businessId) throws Exception; + public List selectStockListByBusinessId(int businessId, String sortColumn, String sortOrder) throws Exception; // 사업자 ID에 해당하는 재고 목록 조회 (단순 조회) public List selectOnlyStockByBusinessId(int businessId) throws Exception; diff --git a/stockMate/src/main/java/com/stockm8/persistence/StockDAOImpl.java b/stockMate/src/main/java/com/stockm8/persistence/StockDAOImpl.java index de53a50..54b0709 100644 --- a/stockMate/src/main/java/com/stockm8/persistence/StockDAOImpl.java +++ b/stockMate/src/main/java/com/stockm8/persistence/StockDAOImpl.java @@ -1,6 +1,7 @@ package com.stockm8.persistence; import com.stockm8.domain.vo.StockVO; +import com.stockm8.domain.dto.StockDTO; import com.stockm8.domain.vo.CategoryVO; import org.apache.ibatis.session.SqlSession; import org.slf4j.Logger; @@ -30,8 +31,13 @@ public void insertStock(StockVO stock) throws Exception { // 사업자 ID에 해당하는 재고 목록 조회 @Override - public List selectStockListByBusinessId(int businessId) throws Exception { - return sqlSession.selectList(NAMESPACE + "selectStockListByBusinessId", businessId); + public List selectStockListByBusinessId(int businessId, String sortColumn, String sortOrder) throws Exception { + Map params = new HashMap<>(); + params.put("businessId", businessId); + params.put("sortColumn", sortColumn); + params.put("sortOrder", sortOrder); + + return sqlSession.selectList(NAMESPACE + "selectStockListByBusinessId", params); } // 필터링된 재고 목록 조회 (정렬 기준 포함) diff --git a/stockMate/src/main/java/com/stockm8/service/StockService.java b/stockMate/src/main/java/com/stockm8/service/StockService.java index 8c60b6f..e1807bf 100644 --- a/stockMate/src/main/java/com/stockm8/service/StockService.java +++ b/stockMate/src/main/java/com/stockm8/service/StockService.java @@ -3,6 +3,7 @@ import com.stockm8.domain.vo.StockVO; import com.stockm8.domain.vo.WarehouseVO; // 추가된 VO import com.stockm8.persistence.FilterCriteria; +import com.stockm8.domain.dto.StockDTO; import com.stockm8.domain.vo.CategoryVO; import java.util.List; import java.util.Map; @@ -16,10 +17,10 @@ public interface StockService { public List getWarehousesByBusinessId(int businessId) throws Exception; // 사업자 ID에 해당하는 재고 목록 조회 - public List getStockListByBusinessId(int businessId) throws Exception; + public List getStockList(int businessId, String sortColumn, String sortOrder) throws Exception; - // 필터링된 재고 목록 조회 (정렬 기준 추가) - public List getStockList(FilterCriteria criteria, String sortOrder) throws Exception; +// // 필터링된 재고 목록 조회 (정렬 기준 추가) +// public List getStockList(FilterCriteria criteria, String sortOrder) throws Exception; // 카테고리 목록 조회 public List getCategoryList() throws Exception; diff --git a/stockMate/src/main/java/com/stockm8/service/StockServiceImpl.java b/stockMate/src/main/java/com/stockm8/service/StockServiceImpl.java index 7123dec..dacca19 100644 --- a/stockMate/src/main/java/com/stockm8/service/StockServiceImpl.java +++ b/stockMate/src/main/java/com/stockm8/service/StockServiceImpl.java @@ -3,6 +3,7 @@ import com.stockm8.domain.vo.StockVO; import com.stockm8.domain.vo.WarehouseVO; import com.stockm8.persistence.FilterCriteria; +import com.stockm8.domain.dto.StockDTO; import com.stockm8.domain.vo.CategoryVO; import com.stockm8.persistence.StockDAO; import com.stockm8.persistence.WarehouseDAO; @@ -37,20 +38,44 @@ public void registerStock(StockVO stock) throws Exception { // 사업자 ID에 해당하는 창고 목록 조회 @Override public List getWarehousesByBusinessId(int businessId) throws Exception { + return warehouseDAO.selectWarehousesByBusinessId(businessId); // WarehouseDAO에서 창고 목록 조회 } // 사업자 ID에 해당하는 재고 목록 조회 @Override - public List getStockListByBusinessId(int businessId) throws Exception { - return stockDAO.selectOnlyStockByBusinessId(businessId); + public List getStockList(int businessId, String sortColumn, String sortOrder) throws Exception { + // 정렬 기준과 순서에 대한 유효성 검사 및 기본값 설정 + final String defaultSortColumn = "updated_at"; + final String defaultSortOrder = "desc"; + + // 정렬 컬럼 허용 목록 (SQL 인젝션 방지) + List allowedSortColumns = List.of("updated_at", "product_name", "total_quantity", "available_stock"); + if (sortColumn == null || sortColumn.isBlank() || !allowedSortColumns.contains(sortColumn)) { + sortColumn = defaultSortColumn; // 기본 정렬 기준 + } + + // 정렬 순서 유효성 검사 + if (sortOrder == null || (!sortOrder.equalsIgnoreCase("asc") && !sortOrder.equalsIgnoreCase("desc"))) { + sortOrder = defaultSortOrder; // 기본 정렬 순서 + } + + // DAO 호출 및 예외 처리 + List stockList = stockDAO.selectStockListByBusinessId(businessId, sortColumn, sortOrder); + + // Null 체크 및 예외 처리 + if (stockList == null || stockList.isEmpty()) { + throw new Exception("No stock data found for the given business ID: " + businessId); + } + + return stockList; } - // 필터링된 재고 목록 조회 (정렬 기준 추가) - @Override - public List getStockList(FilterCriteria criteria, String sortOrder) throws Exception { - return stockDAO.selectFilteredStocks(criteria, sortOrder); // StockDAO에서 필터링된 재고 목록 조회 - } +// // 필터링된 재고 목록 조회 (정렬 기준 추가) +// @Override +// public List getStockList(FilterCriteria criteria, String sortOrder) throws Exception { +// return stockDAO.selectFilteredStocks(criteria, sortOrder); // StockDAO에서 필터링된 재고 목록 조회 +// } // 카테고리 목록 조회 @Override @@ -58,21 +83,27 @@ public List getCategoryList() throws Exception { return categoryDAO.selectAllCategories(); // CategoryDAO에서 카테고리 목록 조회 } + @Override + public Map getStockAndCategories(int businessId) throws Exception { + // TODO Auto-generated method stub + return null; + } + // 사업자 ID로 재고정보와 카테고리 정보 가져오기 - @Override - public Map getStockAndCategories(int businessId) throws Exception { - // 재고 목록 조회 - List stockList = stockDAO.selectStockListByBusinessId(businessId); - // 카테고리 목록 조회 - List categoryList = categoryDAO.selectCategoriesByBusinessId(businessId); - - // 결과를 Map에 담아서 반환 - Map result = new HashMap<>(); - result.put("stockList", stockList); - result.put("categoryList", categoryList); - - return result; - } +// @Override +// public Map getStockAndCategories(int businessId) throws Exception { +// // 재고 목록 조회 +// List stockList = stockDAO.selectStockListByBusinessId(businessId); +// // 카테고리 목록 조회 +// List categoryList = categoryDAO.selectCategoriesByBusinessId(businessId); +// +// // 결과를 Map에 담아서 반환 +// Map result = new HashMap<>(); +// result.put("stockList", stockList); +// result.put("categoryList", categoryList); +// +// return result; +// } // 사용 가능한 재고 자동 계산 (주석 처리) // @Override diff --git a/stockMate/src/main/resources/mappers/stockMapper.xml b/stockMate/src/main/resources/mappers/stockMapper.xml index 83c7253..09e7d7a 100644 --- a/stockMate/src/main/resources/mappers/stockMapper.xml +++ b/stockMate/src/main/resources/mappers/stockMapper.xml @@ -126,30 +126,26 @@ - - + + SELECT - warehouse_id AS warehouseId, - warehouse_name AS warehouseName, - warehouse_location AS warehouseLocation, - warehouse_region AS warehouseRegion, - warehouse_capacity AS warehouseCapacity, - warehouse_status AS warehouseStatus, - created_at AS createdAt, - updated_at AS updatedAt + warehouse_id, + warehouse_name, + warehouse_location, + warehouse_region, + warehouse_capacity, + warehouse_status, + created_at, + updated_at FROM warehouses WHERE business_id = #{businessId} AND is_deleted = 0; diff --git a/stockMate/src/main/webapp/WEB-INF/views/product/detail.jsp b/stockMate/src/main/webapp/WEB-INF/views/product/detail.jsp index c08aac0..b80bc6f 100644 --- a/stockMate/src/main/webapp/WEB-INF/views/product/detail.jsp +++ b/stockMate/src/main/webapp/WEB-INF/views/product/detail.jsp @@ -1,121 +1,95 @@ -<%@ page language="java" contentType="text/html; charset=UTF-8" - pageEncoding="UTF-8"%> -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> - -상품 상세정보 - - + + 상품 상세 정보 + -

상품 상세정보

- - - -
${errorMessage}
-
- - - -
${successMessage}
-
- 상품 리스트 - - -

카테고리명: ${categoryName}

-

상품명: ${product.productName}

-

바코드: ${product.productBarcode}

-

기본 단위: ${product.baseUnit}

-

세트 크기: ${product.setSize}

-

가격: ${product.productPrice}

-

설명: ${product.productDescription}

- - - -
- - -
-
- - - -
- - -
-
- -

등록일: ${product.createdAt}

- - -

수정일: ${product.updatedAt}

-
+
+ + + + +

상품 상세 정보

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
카테고리명${categoryName}
상품명${product.productName}
바코드${product.productBarcode}
기본 단위${product.baseUnit}
세트 크기${product.setSize}
가격 + 원 +
상세 설명 + + + ${product.productDescription} + + N/A + +
등록 날짜
수정 날짜 + + + + + 등록 이후 수정 없음 + +
- - + +
+ +
+ + +
+
+ +
+ + +
+
+
- -

해당 상품 정보가 없습니다.

-
- + + +
- \ No newline at end of file + diff --git a/stockMate/src/main/webapp/WEB-INF/views/product/list.jsp b/stockMate/src/main/webapp/WEB-INF/views/product/list.jsp index 38e7877..d902346 100644 --- a/stockMate/src/main/webapp/WEB-INF/views/product/list.jsp +++ b/stockMate/src/main/webapp/WEB-INF/views/product/list.jsp @@ -7,10 +7,8 @@ 상품 리스트 - - + + @@ -18,8 +16,8 @@
-
- 대시보드로 이동 + +

상품 리스트

diff --git a/stockMate/src/main/webapp/WEB-INF/views/stock/list.jsp b/stockMate/src/main/webapp/WEB-INF/views/stock/list.jsp index 51fb785..528c824 100644 --- a/stockMate/src/main/webapp/WEB-INF/views/stock/list.jsp +++ b/stockMate/src/main/webapp/WEB-INF/views/stock/list.jsp @@ -7,142 +7,134 @@ 재고 리스트 - +

재고 리스트

+ + + + + + +
- + + + - - + + + + - - - + + - + + - - + + + + + + + + - - - + + + + + + + - +
상품명 + + 상품명 + + ${sortOrder eq 'asc' ? '▲' : '▼'} + + + 바코드 카테고리명창고명창고 위치 + + 창고명 + + ${sortOrder eq 'asc' ? '▲' : '▼'} + + + 총 재고예약된 수량사용 가능한 재고최근 수정 시간 + + 가용 재고 + + ${sortOrder eq 'asc' ? '▲' : '▼'} + + + + + 마지막 수정 시간 + + ${sortOrder eq 'asc' ? '▲' : '▼'} + + +
- - - - - ${stock.product.productName} - - - N/A - + + ${stock.productName} + ${stock.product != null ? stock.product.productBarcode : 'N/A'}${stock.category != null ? stock.category.categoryName : 'N/A'}${stock.productBarcode}${stock.categoryName} - - - ${stock.warehouse.warehouseName} - - N/A - + + ${stock.warehouseName} + ${stock.warehouse != null ? stock.warehouse.warehouseLocation : 'N/A'}${stock.totalQuantity != null ? stock.totalQuantity : 0}${stock.reservedQuantity != null ? stock.reservedQuantity : 0}${stock.totalQuantity} - + ${stock.availableStock} - ${stock.availableStock != null ? stock.availableStock : 0} + ${stock.availableStock} - - - - - N/A - +
No stock data available.No stock data available.
+ + - \ No newline at end of file + diff --git a/stockMate/src/main/webapp/WEB-INF/views/stock/register.jsp b/stockMate/src/main/webapp/WEB-INF/views/stock/register.jsp index 1de6106..db57e1e 100644 --- a/stockMate/src/main/webapp/WEB-INF/views/stock/register.jsp +++ b/stockMate/src/main/webapp/WEB-INF/views/stock/register.jsp @@ -23,7 +23,6 @@ -

@@ -31,25 +30,21 @@
-
-
-
-