Merge remote-tracking branch 'origin/master'

This commit is contained in:
Suh
2024-01-15 10:28:05 +09:00
19 changed files with 1122 additions and 172 deletions

View File

@@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.no1.wms.excel.ExcelUtils;
@@ -193,4 +194,8 @@ public class CategoryController {
return "modal/categorysearch";
}
}

View File

@@ -5,13 +5,18 @@ 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;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.no1.wms.category.CategoryDto;
import com.no1.wms.product.ProductDto;
import com.no1.wms.product.ProductService;
@@ -21,18 +26,21 @@ public class PriceController {
@Autowired
PriceService priceService;
@Autowired
ProductService productService;
@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 count = priceService.count2(searchn, search);
int perPage = 15; // 한 페이지에 보일 글의 개수
int startRow = (page - 1) * perPage;
List<PriceDto> dto = priceService.priceList2(searchn, search, startRow ,perPage);
List<PriceDto> dto = priceService.priceList3(searchn, search, startRow ,perPage);
m.addAttribute("list", dto);
m.addAttribute("start", startRow + 1);
@@ -62,30 +70,100 @@ public class PriceController {
// 생성 - 폼
@PostMapping("/create")
public String create() {
return "price/create";
}
@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;
}
// 생성 - Ajax
@PostMapping("/create_process")
@ResponseBody
public boolean createProcess(PriceDto dto) {
int i = priceService.createProcess(dto);
if (i == 1) {
return true;
} else {
return false;
}
}
// 상세페이지
@PostMapping("/read")
public String read(String id, Model m) {
// 선택한 id를 바탕으로 원하는 상세정보 출력하는 메서드 작성
PriceDto dto = priceService.selectById(id);
m.addAttribute("dto", dto);
return "price/read";
}
// 수정 폼
@PostMapping("/update")
public String update(String id, Model m) {
PriceDto dto = priceService.selectById(id);
m.addAttribute("dto", dto);
return "price/update";
}
// 수정 - Ajax
@PutMapping("/update_process")
@ResponseBody
public boolean update_process(PriceDto dto) {
int i = priceService.updateById(dto);
if (i == 1) {
return true;
} else {
return false;
}
}
// 삭제
@DeleteMapping("/delete")
@ResponseBody
public boolean delete(String id) {
int i = priceService.deactivateById(id);
if(i == 1) {
return true;
}else {
return false;
}
}
//모달화면
@PostMapping("/show_modal")
public ModelAndView categoryShowModal(@RequestParam(name = "searchn", defaultValue = "0") int searchn,
@RequestParam(name = "search", defaultValue = "") String search,
@RequestParam(name = "p", defaultValue = "1") int page, ModelAndView m, String name) {
int count = productService.count(searchn, search);
int perPage = 10; // 한 페이지에 보일 글의 개수
int startRow = (page - 1) * perPage;
List<ProductDto> dto = productService.productList(searchn, search, startRow ,perPage);
m.addObject("list", dto);
m.addObject("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.addObject("searchn",searchn);
m.addObject("search",search);
m.addObject("begin", begin);
m.addObject("end", end);
m.addObject("pageNum", pageNum);
m.addObject("totalPages", totalPages);
m.addObject("p" , page);
m.setViewName(name);
return m;
}
}

View File

@@ -14,4 +14,12 @@ public interface PriceMapper {
int count(Map<String, Object> m);//카운터
List<PriceDto> priceList2(Map<String, Object> m);//검색기능까지 포함
int createProcess(PriceDto dto);
List<PriceDto> priceList3(Map<String, Object> m);
int count2(Map<String, Object> m);//카운터
PriceDto selectById(String id);
int updateById(PriceDto dto);
int deactivateById(String id);
}

View File

@@ -48,9 +48,42 @@ public class PriceService {
return mapper.priceList2(m);
}
public List<PriceDto> priceList3(int searchn, String search, int start, int perPage){
Map<String, Object> m = new HashMap<String, Object>();
m.put("searchn",searchn);
m.put("search", search);
m.put("start", start);
m.put("perPage", perPage);
return mapper.priceList3(m);
}
public int createProcess(PriceDto dto) {
return mapper.createProcess(dto);
}
public int count2(int searchn, String search) {
Map<String,Object> m = new HashMap<String, Object>();
m.put("searchn",searchn);
m.put("search", search);
return mapper.count2(m);
};//카운터
public PriceDto selectById(String id) {
return mapper.selectById(id);
}
public int updateById(PriceDto dto) {
return mapper.updateById(dto);
}
public int deactivateById(String id) {
return mapper.deactivateById(id);
}
}

View File

@@ -12,9 +12,11 @@ import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.no1.wms.category.CategoryDto;
import com.no1.wms.category.CategoryService;
import com.no1.wms.price.PriceDto;
@Controller
@RequestMapping("/product")
@@ -22,8 +24,10 @@ public class ProductController {
@Autowired
ProductService productService;
@Autowired
CategoryService categoryService;
/*
@GetMapping("list")
public String list(@RequestParam(name = "p", defaultValue = "1") int p, Model m) {
@@ -32,6 +36,44 @@ public class ProductController {
m.addAttribute("list", dto);
return "/product/list";
}
*/
@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 = productService.count(searchn, search);
int perPage = 15; // 한 페이지에 보일 글의 개수
int startRow = (page - 1) * perPage;
List<ProductDto> dto = productService.productList(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 "/product/list";
}
// 생성 - 폼
@PostMapping("/create")
@@ -92,8 +134,39 @@ public class ProductController {
}
//모달화면
@PostMapping("/show_modal")
public ModelAndView categoryShowModal(@RequestParam(name = "searchn", defaultValue = "4") int searchn,
@RequestParam(name = "search", defaultValue = "") String search,
@RequestParam(name = "p", defaultValue = "1") int page, ModelAndView m, String name) {
int count = categoryService.count(searchn, search);
int perPage = 10; // 한 페이지에 보일 글의 개수
int startRow = (page - 1) * perPage;
List<CategoryDto> dto = categoryService.categoryList2(searchn, search, startRow ,perPage);
m.addObject("list", dto);
m.addObject("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.addObject("searchn",searchn);
m.addObject("search",search);
m.addObject("begin", begin);
m.addObject("end", end);
m.addObject("pageNum", pageNum);
m.addObject("totalPages", totalPages);
m.addObject("p" , page);
m.setViewName(name);
return m;
}

View File

@@ -8,10 +8,10 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ProductMapper {
List<ProductDto> productList(Map<String, Object> m);
List<ProductDto> productList(Map<String, Object> m);//페이징 검색 적용 리스트
int createProcess(ProductDto dto);
ProductDto selectById(String id);
int updateById(ProductDto dto);
int deactivateById(String id);
int count(Map<String, Object> m);//카운터
}

View File

@@ -7,22 +7,20 @@ import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class ProductService {
@Autowired
ProductMapper mapper;
public List<ProductDto> productList(int p){
//페이징 완료되면 수정해야함.
int start = 0;
int count = 10;
Map m = new HashMap<String, Object>();
public List<ProductDto> productList(int searchn, String search, int start, int perPage){
Map<String, Object> m = new HashMap<String, Object>();
m.put("searchn",searchn);
m.put("search", search);
m.put("start", start);
m.put("count", count);
m.put("perPage", perPage);
return mapper.productList(m);
}
@@ -42,4 +40,11 @@ public class ProductService {
return mapper.deactivateById(id);
}
public int count(int searchn, String search) {
Map<String,Object> m = new HashMap<String, Object>();
m.put("searchn",searchn);
m.put("search", search);
return mapper.count(m);
};//카운터
}