This commit is contained in:
Kana
2024-01-24 12:06:30 +09:00
4 changed files with 34 additions and 10 deletions

View File

@@ -33,10 +33,9 @@ public class PlanInController {
@GetMapping("/list") @GetMapping("/list")
public ModelAndView list(ModelAndView mav,@RequestParam(defaultValue = "0") int searchn, @RequestParam(defaultValue = "") String search, @RequestParam(defaultValue = "1") int page){ public ModelAndView list(ModelAndView mav,@RequestParam(defaultValue = "0") int searchn, @RequestParam(defaultValue = "") String search, @RequestParam(defaultValue = "1") int page){
int perPage = 15; int perPage = 10;
int startRow = (page - 1) * perPage; int startRow = (page - 1) * perPage;
int count = planinservice.count(searchn, search); int count = planinservice.count(searchn, search, startRow, perPage);
int pageNum = 4;//보여질 페이지 번호 수 int pageNum = 4;//보여질 페이지 번호 수

View File

@@ -20,11 +20,13 @@ public class PlanInService {
return mapper.selectAll(map); return mapper.selectAll(map);
} }
int count(int searchn, String search, int start, int perPage){
int count(int searchn, String search){ System.out.printf("searchn : %d, search : %s, start : %d, perpage : %d", searchn, search, start, perPage);
HashMap<String, Object> m = new HashMap<>(); HashMap<String, Object> m = new HashMap<>();
m.put("searchn", searchn); m.put("searchn", searchn);
m.put("search", search); m.put("search", search);
m.put("start", start);
m.put("perPage", perPage);
return mapper.count(m); return mapper.count(m);
} }
@@ -47,7 +49,4 @@ public class PlanInService {
return mapper.selectByQRHash(qrHash); return mapper.selectByQRHash(qrHash);
} }
} }

View File

@@ -128,8 +128,9 @@
select count(*) from ( SELECT 1 from plan_In i join product p select count(*) from ( SELECT 1 from plan_In i join product p
<where> <where>
<choose> <choose>
<when test="searchn == 0"> i.product_id = p.id and i.activation = 1 and i.view_group_number like concat('%',#{search},'%') </when>
<when test="searchn == 1"> i.product_id = p.id and i.activation = 1 and p.name like concat('%',#{search},'%')</when> <when test="searchn == 1"> i.product_id = p.id and i.activation = 1 and p.name like concat('%',#{search},'%')</when>
<when test="searchn == 0"> i.product_id = p.id and i.activation = 1 and i.group_number like concat('%',#{search},'%') </when> <when test="searchn == 2"> i.product_id = p.id and i.activation = 1 and i.quantity like concat(#{search})</when>
</choose> </choose>
</where> </where>
) t ) t

View File

@@ -32,6 +32,14 @@
} }
function onPaging(target){
const p = $(target).data("p");
$("#pPage").val(p);
const $form = $("#search_form");
$form.attr("action", "/plan_in/list");
$form.trigger("submit");
}
</script> </script>
<div class="container"> <div class="container">
<div class="row"> <div class="row">
@@ -77,6 +85,23 @@
</table> </table>
</div> </div>
</div> </div>
<div class="row">
<div class="col-12">
<div id="page">
<ul class="pagination justify-content-center">
<c:if test="${begin > pageNum }">
<li class="page-item"><a class="page-link" data-p='${begin-1 }' href="#" onclick="onPaging(this)">[<]</a></li>
</c:if>
<c:forEach begin="${begin }" end="${end}" var="i" varStatus="status">
<li class="page-item <c:if test="${page eq status.count}">active</c:if> "><a class="page-link" data-p='${i}' href="#" onclick="onPaging(this)" >${i}</a></li>
</c:forEach>
<c:if test="${end < totalPages }">
<li class="page-item"><a class="page-link" data-p='${end+1}' href="#" onclick="onPaging(this)">[>]</a></li>
</c:if>
</ul>
</div>
</div>
</div>
</div> </div>
<form id="form" action='/plan_in/read' method="post"> <form id="form" action='/plan_in/read' method="post">
<input name="groupNumber" id="groupId" hidden> <input name="groupNumber" id="groupId" hidden>