diff --git a/src/main/java/com/no1/wms/category/CategoryController.java b/src/main/java/com/no1/wms/category/CategoryController.java index f4a82d8..e0bf66d 100644 --- a/src/main/java/com/no1/wms/category/CategoryController.java +++ b/src/main/java/com/no1/wms/category/CategoryController.java @@ -158,7 +158,8 @@ public class CategoryController { return checkkan; } - @PostMapping("/category/categorysearch") + //카테고리 검색 모달 + @GetMapping("/category/categorysearch") public String categorySearch(@RequestParam(name = "searchn", defaultValue = "4") int searchn, @RequestParam(name = "search", defaultValue = "") String search, @RequestParam(name = "p", defaultValue = "1") int page, Model m) { @@ -181,6 +182,8 @@ public class CategoryController { if (end > totalPages) { end = totalPages; } + m.addAttribute("searchn",searchn); + m.addAttribute("search",search); m.addAttribute("begin", begin); m.addAttribute("end", end); m.addAttribute("pageNum", pageNum); diff --git a/src/main/java/com/no1/wms/price/PriceController.java b/src/main/java/com/no1/wms/price/PriceController.java new file mode 100644 index 0000000..c2fbb7c --- /dev/null +++ b/src/main/java/com/no1/wms/price/PriceController.java @@ -0,0 +1,91 @@ +package com.no1.wms.price; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; + +import com.no1.wms.category.CategoryDto; + + + +@Controller +@RequestMapping("/price") +public class PriceController { + + @Autowired + PriceService priceService; + + @GetMapping("/list") + public String list(@RequestParam(name = "searchn", defaultValue = "0") int searchn, + @RequestParam(name = "search", defaultValue = "") String search, + @RequestParam(name = "p", defaultValue = "1") int page, Model m) { + + int count = priceService.count(searchn, search); + + int perPage = 15; // 한 페이지에 보일 글의 개수 + int startRow = (page - 1) * perPage; + + List dto = priceService.priceList2(searchn, search, startRow ,perPage); + + m.addAttribute("list", dto); + m.addAttribute("start", startRow + 1); + + int pageNum = 5;//보여질 페이지 번호 수 + int totalPages = count / perPage + (count % perPage > 0 ? 1 : 0); // 전체 페이지 수 + + int begin = (page - 1) / pageNum * pageNum + 1; + int end = begin + pageNum - 1; + if (end > totalPages) { + end = totalPages; + } + + m.addAttribute("searchn",searchn); + m.addAttribute("search",search); + m.addAttribute("begin", begin); + m.addAttribute("end", end); + m.addAttribute("pageNum", pageNum); + m.addAttribute("totalPages", totalPages); + m.addAttribute("p" , page); + + + + return "/price/list"; + + } + + + // 생성 - 폼 + @PostMapping("/create") + public String create() { + return "price/create"; + } + + + // 생성 - Ajax + @PostMapping("/price/create_process") + @ResponseBody + public boolean createProcess(PriceDto dto) { + int i = priceService.createProcess(dto); + if (i == 1) { + return true; + } else { + return false; + } + } + + + + + + + + + +} diff --git a/src/main/java/com/no1/wms/price/PriceDto.java b/src/main/java/com/no1/wms/price/PriceDto.java new file mode 100644 index 0000000..b8e88cf --- /dev/null +++ b/src/main/java/com/no1/wms/price/PriceDto.java @@ -0,0 +1,32 @@ +package com.no1.wms.price; + +import java.util.Date; + +import org.apache.ibatis.type.Alias; + +import com.no1.wms.account.AccountDto; +import com.no1.wms.product.ProductDto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@Alias("PriceDto") +public class PriceDto { + + private String id;//id + private String price;//가격 + private Date registration_date;//등록날짜 + private String manager_id;//담당자 + private String product_id; //제품 아이디 + private boolean activation;//활성화 + + private ProductDto productDto; + private AccountDto accountDto; + +} diff --git a/src/main/java/com/no1/wms/price/PriceMapper.java b/src/main/java/com/no1/wms/price/PriceMapper.java new file mode 100644 index 0000000..cc89535 --- /dev/null +++ b/src/main/java/com/no1/wms/price/PriceMapper.java @@ -0,0 +1,17 @@ +package com.no1.wms.price; + +import java.util.List; +import java.util.Map; + +import org.apache.ibatis.annotations.Mapper; + +import com.no1.wms.category.CategoryDto; + +@Mapper +public interface PriceMapper { + + List priceList(Map m); + int count(Map m);//카운터 + List priceList2(Map m);//검색기능까지 포함 + int createProcess(PriceDto dto); +} diff --git a/src/main/java/com/no1/wms/price/PriceService.java b/src/main/java/com/no1/wms/price/PriceService.java new file mode 100644 index 0000000..9189284 --- /dev/null +++ b/src/main/java/com/no1/wms/price/PriceService.java @@ -0,0 +1,56 @@ +package com.no1.wms.price; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.no1.wms.category.CategoryDto; +import com.no1.wms.product.ProductDto; + +@Service +public class PriceService { + + @Autowired + PriceMapper mapper; + + public List priceList(int p){ + + int start = 0; + int count = 10; + + Map m = new HashMap(); + m.put("start", start); + m.put("count", count); + + return mapper.priceList(m); + } + + //페이징 카운터 + public int count(int searchn, String search) { + + Map m = new HashMap(); + m.put("searchn",searchn); + m.put("search", search); + return mapper.count(m); + } + + public List priceList2(int searchn, String search, int start, int perPage){ + + Map m = new HashMap(); + m.put("searchn",searchn); + m.put("search", search); + m.put("start", start); + m.put("perPage", perPage); + + return mapper.priceList2(m); + } + + public int createProcess(PriceDto dto) { + return mapper.createProcess(dto); + } + + +} diff --git a/src/main/java/com/no1/wms/product/ProductController.java b/src/main/java/com/no1/wms/product/ProductController.java index bc78202..973c57c 100644 --- a/src/main/java/com/no1/wms/product/ProductController.java +++ b/src/main/java/com/no1/wms/product/ProductController.java @@ -5,6 +5,7 @@ import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; @@ -12,18 +13,22 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; +import com.no1.wms.category.CategoryDto; +import com.no1.wms.category.CategoryService; + @Controller @RequestMapping("/product") public class ProductController { @Autowired - ProductService productservice; + ProductService productService; + @GetMapping("list") public String list(@RequestParam(name = "p", defaultValue = "1") int p, Model m) { // 서비스로 카테고리 목록 불러오는 메서드 작성 - List dto = productservice.productList(p); + List dto = productService.productList(p); m.addAttribute("list", dto); return "/product/list"; } @@ -38,7 +43,7 @@ public class ProductController { @PostMapping("/create_process") @ResponseBody public boolean createProcess(ProductDto dto) { - int i = productservice.createProcess(dto); + int i = productService.createProcess(dto); if (i == 1) { return true; } else { @@ -49,25 +54,23 @@ public class ProductController { // 상세페이지 @PostMapping("/read") public String read(String id, Model m) { - ProductDto dto = productservice.selectById(id); + ProductDto dto = productService.selectById(id); m.addAttribute("dto", dto); return "product/read"; } - + // 수정 폼 @PostMapping("/update") public String update(String id, Model m) { - ProductDto dto = productservice.selectById(id); + ProductDto dto = productService.selectById(id); m.addAttribute("dto", dto); return "product/update"; } // 수정 - Ajax - @PutMapping("update_process") + @PutMapping("/update_process") @ResponseBody public boolean update_process(ProductDto dto) { - System.out.println(dto.getId()); - - int i = productservice.updateById(dto); + int i = productService.updateById(dto); if (i == 1) { return true; } else { @@ -76,5 +79,33 @@ public class ProductController { } + // 삭제 + @DeleteMapping("/delete") + @ResponseBody + public boolean delete(String id) { + int i = productService.deactivateById(id); + if(i == 1) { + return true; + }else { + return false; + } + } + + + + + + + + + + + + + + + + + } diff --git a/src/main/java/com/no1/wms/product/ProductMapper.java b/src/main/java/com/no1/wms/product/ProductMapper.java index 7116e49..b34f763 100644 --- a/src/main/java/com/no1/wms/product/ProductMapper.java +++ b/src/main/java/com/no1/wms/product/ProductMapper.java @@ -12,4 +12,6 @@ public interface ProductMapper { int createProcess(ProductDto dto); ProductDto selectById(String id); int updateById(ProductDto dto); + int deactivateById(String id); + } diff --git a/src/main/java/com/no1/wms/product/ProductService.java b/src/main/java/com/no1/wms/product/ProductService.java index 5fdfc8c..4922f5b 100644 --- a/src/main/java/com/no1/wms/product/ProductService.java +++ b/src/main/java/com/no1/wms/product/ProductService.java @@ -38,4 +38,8 @@ public class ProductService { return mapper.updateById(dto); } + public int deactivateById(String id) { + return mapper.deactivateById(id); + } + } diff --git a/src/main/resources/mappers/PriceMapper.xml b/src/main/resources/mappers/PriceMapper.xml new file mode 100644 index 0000000..04265f0 --- /dev/null +++ b/src/main/resources/mappers/PriceMapper.xml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + INSERT INTO prices (id, price, registration_date, manager_id, product_id, activation) + VALUES (UUID(), #{price}, curdate(), #{manager_id}, #{product_id}, 1) + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mappers/ProductMapper.xml b/src/main/resources/mappers/ProductMapper.xml index 0b42ad7..8839021 100644 --- a/src/main/resources/mappers/ProductMapper.xml +++ b/src/main/resources/mappers/ProductMapper.xml @@ -48,6 +48,12 @@ WHERE id = #{id} + + UPDATE product + SET activation = 0 + WHERE id = #{id} + + diff --git a/src/main/webapp/WEB-INF/views/category/list.jsp b/src/main/webapp/WEB-INF/views/category/list.jsp index f6e6be1..7e1b41c 100644 --- a/src/main/webapp/WEB-INF/views/category/list.jsp +++ b/src/main/webapp/WEB-INF/views/category/list.jsp @@ -77,17 +77,17 @@
  • - < + <
  • active "> - ${i } + ${i }
  • - > + >
  • @@ -168,7 +168,7 @@ });//ready - function pageingFunction(clickedId){ + function pagingFunction(clickedId){ var searchn1 = $("#searchn1").val(); var search1 = $("#search1").val(); diff --git a/src/main/webapp/WEB-INF/views/modal/categorysearch.jsp b/src/main/webapp/WEB-INF/views/modal/categorysearch.jsp index 3610c13..3236246 100644 --- a/src/main/webapp/WEB-INF/views/modal/categorysearch.jsp +++ b/src/main/webapp/WEB-INF/views/modal/categorysearch.jsp @@ -21,10 +21,10 @@ @@ -73,22 +79,23 @@
    @@ -102,13 +109,96 @@ - - \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/price/create.jsp b/src/main/webapp/WEB-INF/views/price/create.jsp new file mode 100644 index 0000000..6dde325 --- /dev/null +++ b/src/main/webapp/WEB-INF/views/price/create.jsp @@ -0,0 +1,90 @@ +<%@ page contentType="text/html; charset=UTF-8"%> + + + + +제품 가격 생성 + + + + + +
    +

    제품 가격 생성

    +
    +
    +
    +
    +
    +
    +
    +
    + 제품명 + + + + +
    + +
    + 중분류 + +
    +
    + 소분류 + +
    +
    + 세분류 + +
    +
    + KAN 분류코드 + + + +
    +
    +
    +
    +
    +
    +
    + + + +
    +
    +
    +
    + + + + + + + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/price/list.jsp b/src/main/webapp/WEB-INF/views/price/list.jsp new file mode 100644 index 0000000..d19014a --- /dev/null +++ b/src/main/webapp/WEB-INF/views/price/list.jsp @@ -0,0 +1,116 @@ +<%@ page contentType="text/html; charset=UTF-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> + + + + +제품 가격 + + +
    +

    제품 가격 관리

    +
    +
    +
    +
    +
    +
    +
    +
    + +
    + + + + + + + + +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    번호제품명가격등록날짜담당자
    ${status.count }${dto.productDto.name }${dto.price }${dto.accountDto.name }
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    + +
    +
    +
    +
    + + + + + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/product/create.jsp b/src/main/webapp/WEB-INF/views/product/create.jsp index 7638525..8db8f03 100644 --- a/src/main/webapp/WEB-INF/views/product/create.jsp +++ b/src/main/webapp/WEB-INF/views/product/create.jsp @@ -84,86 +84,11 @@ - - - - - diff --git a/src/main/webapp/WEB-INF/views/product/read.jsp b/src/main/webapp/WEB-INF/views/product/read.jsp index ccc731f..f40ec90 100644 --- a/src/main/webapp/WEB-INF/views/product/read.jsp +++ b/src/main/webapp/WEB-INF/views/product/read.jsp @@ -101,9 +101,34 @@ })//modifyBtn click - + yesNoModal.yesFunction = deleteProductFunction; });//ready - + + + function deleteProductFunction(){ + var id = $("#id").val(); + $.ajax({ + url: "/product/delete", + type: "delete", + data: { + "id": id + }, + datatype:"json" + }).done(function(data) { + if (data == true) { + alert("삭제되었습니다."); + $(location).attr("href", "/product/list"); + } else { + alert("정상적으로 삭제되지 않았습니다.."); + } + }).fail(function() { + alert("오류가 발생했습니다."); + }).always(function() { + // + }); + + }//deleteCategoryFunction + \ No newline at end of file