mirror of
https://github.com/suhf/No1WMS.git
synced 2026-02-04 19:54:00 +09:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -40,11 +40,41 @@ public class CategoryController {
|
||||
|
||||
// 카테고리 리스트 출력
|
||||
@GetMapping("/category/list")
|
||||
public String list(@RequestParam(name = "p", defaultValue = "1") int p, Model m) {
|
||||
public String list(@RequestParam(name = "searchn", defaultValue = "4") int searchn,
|
||||
@RequestParam(name = "search", defaultValue = "") String search,
|
||||
@RequestParam(name = "p", defaultValue = "1") int page, Model m) {
|
||||
|
||||
// 서비스로 카테고리 목록 불러오는 메서드 작성
|
||||
List<CategoryDto> dto = categoryService.categoryList(p);
|
||||
int count = categoryService.count(searchn, search);
|
||||
|
||||
int perPage = 15; // 한 페이지에 보일 글의 개수
|
||||
int startRow = (page - 1) * perPage;
|
||||
|
||||
List<CategoryDto> dto = categoryService.categoryList2(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);
|
||||
|
||||
|
||||
// 서비스로 카테고리 목록 불러오는 메서드 작성
|
||||
//List<CategoryDto> dto = categoryService.categoryList(page);
|
||||
//m.addAttribute("list", dto);
|
||||
return "category/list";
|
||||
}
|
||||
|
||||
@@ -128,6 +158,36 @@ public class CategoryController {
|
||||
return checkkan;
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/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) {
|
||||
|
||||
int count = categoryService.count(searchn, search);
|
||||
|
||||
int perPage = 10; // 한 페이지에 보일 글의 개수
|
||||
int startRow = (page - 1) * perPage;
|
||||
|
||||
List<CategoryDto> dto = categoryService.categoryList2(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("begin", begin);
|
||||
m.addAttribute("end", end);
|
||||
m.addAttribute("pageNum", pageNum);
|
||||
m.addAttribute("totalPages", totalPages);
|
||||
m.addAttribute("p" , page);
|
||||
|
||||
return "modal/categorysearch";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface CategoryMapper {
|
||||
List<CategoryDto> categoryList(Map<String, Object> m);
|
||||
List<CategoryDto> categoryList(Map<String, Object> m);//검색기능 미포함
|
||||
CategoryDto selectByKanCode(String kan_code);
|
||||
int createProcess(CategoryDto dto);
|
||||
List<CategoryDto> selectAllCategory();
|
||||
@@ -15,4 +15,9 @@ public interface CategoryMapper {
|
||||
int deactivateByKanCode(String kan_code);
|
||||
int activateByKanCode(String kan_code);
|
||||
String kanCheck(String kan_code);
|
||||
|
||||
int count(Map<String, Object> m);//카운터
|
||||
List<CategoryDto> categoryList2(Map<String, Object> m);//검색기능까지 포함
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -56,5 +56,27 @@ public class CategoryService {
|
||||
return mapper.kanCheck(kan_code);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public List<CategoryDto> categoryList2(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.categoryList2(m);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -54,8 +54,39 @@
|
||||
<select id="kanCheck" parameterType="String" resultType="String">
|
||||
select kan_code from product_category where kan_code = #{kan_code}
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 네비게이션바 전용 카운터 -->
|
||||
<select id="count" parameterType="map" resultType="int">
|
||||
select count(*)
|
||||
|
||||
from product_category as p
|
||||
|
||||
<where>
|
||||
<choose>
|
||||
<when test="searchn == 0"> p.activation = 1 and p.kan_code like concat('%',#{search},'%')</when>
|
||||
<when test="searchn == 1"> p.activation = 1 and p.cls_nm_1 like concat('%',#{search},'%')</when>
|
||||
<when test="searchn == 2"> p.activation = 1 and p.cls_nm_2 like concat('%',#{search},'%')</when>
|
||||
<when test="searchn == 3"> p.activation = 1 and p.cls_nm_3 like concat('%',#{search},'%')</when>
|
||||
<when test="searchn == 4"> p.activation = 1 and p.cls_nm_4 like concat('%',#{search},'%')</when>
|
||||
</choose>
|
||||
</where>
|
||||
</select>
|
||||
<!-- 검색 -->
|
||||
<select id="categoryList2" parameterType="map" resultType="CategoryDto">
|
||||
select *
|
||||
|
||||
from product_category as p
|
||||
|
||||
<where>
|
||||
<choose>
|
||||
<when test="searchn == 0"> p.activation = 1 and p.kan_code like concat('%',#{search},'%')</when>
|
||||
<when test="searchn == 1"> p.activation = 1 and p.cls_nm_1 like concat('%',#{search},'%')</when>
|
||||
<when test="searchn == 2"> p.activation = 1 and p.cls_nm_2 like concat('%',#{search},'%')</when>
|
||||
<when test="searchn == 3"> p.activation = 1 and p.cls_nm_3 like concat('%',#{search},'%')</when>
|
||||
<when test="searchn == 4"> p.activation = 1 and p.cls_nm_4 like concat('%',#{search},'%')</when>
|
||||
</choose>
|
||||
</where>
|
||||
order by kan_code limit #{start} , #{perPage}
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -14,25 +14,30 @@
|
||||
<div class="body">
|
||||
<div class="container-fluid">
|
||||
<div class="col-12">
|
||||
<form action="categorySearch">
|
||||
<form>
|
||||
<div class="input-group mb-3 w-30 col-centered">
|
||||
<div class="w-25">
|
||||
<select class="form-select">
|
||||
<option selected="selected" value="cls_nm_4">세분류</option>
|
||||
<option value="cls_nm_1">대분류</option>
|
||||
<option value="cls_nm_2">중분류</option>
|
||||
<option value="cls_nm_3">세분류</option>
|
||||
<option value="kan_code">KAN코드</option>
|
||||
<select class="form-select" name="searchn" id="searchn">
|
||||
<option selected="selected" value="4">세분류</option>
|
||||
<option value="1">대분류</option>
|
||||
<option value="2">중분류</option>
|
||||
<option value="3">소분류</option>
|
||||
<option value="0">KAN코드</option>
|
||||
</select>
|
||||
</div>
|
||||
<input type="text" name="categorySearch" class="form-control" aria-label="Text input with dropdown button" placeholder="검색어를 입력하세요">
|
||||
<button class="btn btn-info" type="button" id="button-addon2 searchBtn">검색</button>
|
||||
<input type="text" id="search" name="search" class="form-control" aria-label="Text input with dropdown button" placeholder="검색어를 입력하세요">
|
||||
<button class="btn btn-info" type="button" id="searchBtn">검색</button>
|
||||
|
||||
<!-- 페이징작업용 -->
|
||||
<input type="hidden" id="searchn1" value="${searchn}">
|
||||
<input type="hidden" id="search1" value="${search}">
|
||||
<!-- 페이징작업용 -->
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-fluid">
|
||||
|
||||
<div class="row row-table">
|
||||
<div class="col-12">
|
||||
<table class="table">
|
||||
@@ -57,44 +62,35 @@
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-fluid">
|
||||
<div class="row row-buttons">
|
||||
<div class="col-3 text-start">
|
||||
<img alt="엑셀이미지" src="엑셀이미지">
|
||||
<!-- <img alt="엑셀이미지" src="엑셀이미지"> -->
|
||||
<button type="button" class="btn btn-success" id="uploadExcel">업로드</button>
|
||||
</div>
|
||||
<div class="col-6 d-flex justify-content-center">
|
||||
<nav>
|
||||
<ul class="pagination">
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#"><</a>
|
||||
</li>
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#">1</a>
|
||||
</li>
|
||||
<li class="page-item active">
|
||||
<a class="page-link" href="#">2</a>
|
||||
</li>
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#">3</a>
|
||||
</li>
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#">4</a>
|
||||
</li>
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#">5</a>
|
||||
</li>
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#">6</a>
|
||||
</li>
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#">></a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<c:if test="${begin > pageNum }">
|
||||
<li class="page-item">
|
||||
<a href="javascript:void(0);" class="page-link" onclick="pageingFunction(this.id)" id="${begin - 1 }"><</a>
|
||||
</li>
|
||||
</c:if>
|
||||
<c:forEach begin="${begin }" end="${end }" var="i">
|
||||
<li class="page-item <c:if test="${p == i}"> active </c:if>">
|
||||
<a href="javascript:void(0);" class="page-link " onclick="pageingFunction(this.id); return false;" id="${i }">${i }</a>
|
||||
</li>
|
||||
</c:forEach>
|
||||
<c:if test="${end < totalPages }">
|
||||
<li class="page-item">
|
||||
<a href="javascript:void(0);" class="page-link" onclick="pageingFunction(this.id)" id="${end + 1 }">></a>
|
||||
</li>
|
||||
</c:if>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
<div class="col-3 text-end">
|
||||
@@ -133,9 +129,74 @@
|
||||
form.appendChild(input);
|
||||
|
||||
form.submit();
|
||||
|
||||
});
|
||||
|
||||
|
||||
//검색기능
|
||||
$("#searchBtn").on("click",function(){
|
||||
|
||||
var searchn = $("#searchn").val();
|
||||
var search = $("#search").val();
|
||||
|
||||
var form = document.createElement("form");
|
||||
form.action = "/category/list";
|
||||
form.method = "get";
|
||||
|
||||
var input1 = document.createElement("input");
|
||||
input1.type = "hidden";
|
||||
input1.name = "searchn";
|
||||
input1.value = searchn;
|
||||
form.appendChild(input1);
|
||||
|
||||
var input2 = document.createElement("input");
|
||||
input2.type = "hidden";
|
||||
input2.name = "search";
|
||||
input2.value = search;
|
||||
form.appendChild(input2);
|
||||
|
||||
var input3 = document.createElement("input");
|
||||
input3.type = "hidden";
|
||||
input3.name = "p";
|
||||
input3.value = 1;
|
||||
form.appendChild(input3);
|
||||
|
||||
document.body.appendChild(form);
|
||||
form.submit();
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
});//ready
|
||||
function pageingFunction(clickedId){
|
||||
var searchn1 = $("#searchn1").val();
|
||||
var search1 = $("#search1").val();
|
||||
|
||||
var form = document.createElement("form");
|
||||
form.action = "/category/list";
|
||||
form.method = "get";
|
||||
|
||||
var input1 = document.createElement("input");
|
||||
input1.type = "hidden";
|
||||
input1.name = "searchn";
|
||||
input1.value = searchn1;
|
||||
form.appendChild(input1);
|
||||
|
||||
var input2 = document.createElement("input");
|
||||
input2.type = "hidden";
|
||||
input2.name = "search";
|
||||
input2.value = search1;
|
||||
form.appendChild(input2);
|
||||
|
||||
var input3 = document.createElement("input");
|
||||
input3.type = "hidden";
|
||||
input3.name = "p";
|
||||
input3.value = clickedId;
|
||||
form.appendChild(input3);
|
||||
|
||||
document.body.appendChild(form);
|
||||
form.submit();
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
114
src/main/webapp/WEB-INF/views/modal/categorysearch.jsp
Normal file
114
src/main/webapp/WEB-INF/views/modal/categorysearch.jsp
Normal file
@@ -0,0 +1,114 @@
|
||||
<%@ page contentType="text/html; charset=UTF-8"%>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Insert title here</title>
|
||||
<style>
|
||||
.modal-body {
|
||||
overflow-y: auto; /* 세로 스크롤이 생기면서 테이블이 잘리는 것을 방지 */
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="modal fade" id="searchKanModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered modal-xl" >
|
||||
<div class="modal-content" id="search_modal_content">
|
||||
|
||||
<div class="modal-header">
|
||||
<h1 class="modal-title fs-5" id="searchModalLabel">KAN 분류코드 검색</h1>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body" id="search_modal_body">
|
||||
<form action="list">
|
||||
<div class="input-group mb-3 w-30 col-centered">
|
||||
<div class="w-25">
|
||||
<select class="form-select" name="searchn">
|
||||
<option selected="selected" value="4">세분류</option>
|
||||
<option value="1">대분류</option>
|
||||
<option value="2">중분류</option>
|
||||
<option value="3">소분류</option>
|
||||
<option value="0">KAN코드</option>
|
||||
</select>
|
||||
</div>
|
||||
<input type="text" name="search" class="form-control" aria-label="Text input with dropdown button" placeholder="검색어를 입력하세요">
|
||||
<button class="btn btn-info" type="submit" id="button-addon2 searchBtn">검색</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="container-fluid modal-body">
|
||||
<div class="row row-table modal-body">
|
||||
<div class="col-12 modal-body">
|
||||
<table class="table modal-body">
|
||||
<thead class="table-dark">
|
||||
<tr>
|
||||
<th>대분류</th>
|
||||
<th>중분류</th>
|
||||
<th>소분류</th>
|
||||
<th>세분류</th>
|
||||
<th>KAN코드</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:forEach items="${list }" var="dto">
|
||||
<tr class="detailTr" data-kan_code="${dto.kan_code}" >
|
||||
<td>${dto.cls_nm_1 }</td>
|
||||
<td>${dto.cls_nm_2 }</td>
|
||||
<td>${dto.cls_nm_3 }</td>
|
||||
<td>${dto.cls_nm_4 }</td>
|
||||
<td>${dto.kan_code }</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-fluid">
|
||||
<div class="row row-buttons">
|
||||
<div class="col-3 text-start">
|
||||
</div>
|
||||
<div class="col-6 d-flex justify-content-center">
|
||||
<nav>
|
||||
<ul class="pagination">
|
||||
<c:if test="${begin > pageNum }">
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="list?p=${begin - 1 }"><</a>
|
||||
</li>
|
||||
</c:if>
|
||||
<c:forEach begin="${begin }" end="${end }" var="i">
|
||||
<li class="page-item <c:if test="${p == i}"> active </c:if>">
|
||||
<a class="page-link " href="list?p=${i }">${i }</a>
|
||||
</li>
|
||||
</c:forEach>
|
||||
<c:if test="${end < totalPages }">
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="list?p=${end + 1 }">></a>
|
||||
</li>
|
||||
</c:if>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
</div><!-- row row-buttons -->
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button id="modal_yes_button" type="button" class="modal_yes btn btn-primary">확인</button>
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">닫기</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script>
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user