plainin list와 read기본

This commit is contained in:
Suh
2024-01-17 17:42:17 +09:00
parent feab8f173c
commit 2a63f0dfc8
6 changed files with 51 additions and 6 deletions

View File

@@ -5,6 +5,7 @@ import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping; 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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
@@ -49,5 +50,18 @@ public class PlanInController {
mav.setViewName("planin/list"); mav.setViewName("planin/list");
return mav; return mav;
} }
@PostMapping("/read")
public ModelAndView read(ModelAndView mav, PlanInDto dto){
System.out.println(dto);
List<PlanInDto> list = planinservice.selectById(dto);
System.out.println(list.get(0).toString());
mav.addObject("list", list);
mav.setViewName("planin/read");
return mav;
}
} }

View File

@@ -13,4 +13,6 @@ public interface PlanInMapper {
List<PlanInDto> selectAll(Map<String, Object> m); List<PlanInDto> selectAll(Map<String, Object> m);
int count(Map<String, Object> m); int count(Map<String, Object> m);
List<PlanInDto> selectById(PlanInDto dto);
} }

View File

@@ -32,4 +32,8 @@ public class PlanInService {
m.put("perPage", perPage); m.put("perPage", perPage);
return mapper.count(m); return mapper.count(m);
} }
List<PlanInDto> selectById(PlanInDto dto){
return mapper.selectById(dto);
}
} }

View File

@@ -42,7 +42,7 @@
from plan_In plan join account acc join vendor join warehouse join product from plan_In plan join account acc join vendor join warehouse join product
on plan.product_id = product.id and plan.vendor_id = vendor.id and plan.manager_id = acc.id on plan.product_id = product.id and plan.vendor_id = vendor.id and plan.manager_id = acc.id
and plan.warehouse_id = warehouse.id and plan.warehouse_id = warehouse.id
where plan.group_number = #{groupNumber} and plan.product_id = #{productId} where plan.group_number = #{groupNumber}
</select> </select>
<select id="selectAll" resultMap="planInResultMap" parameterType="map"> <select id="selectAll" resultMap="planInResultMap" parameterType="map">
SELECT SELECT

View File

@@ -3,7 +3,27 @@
<!-- 이 안에 내용 복사해서 jsp에 붙여넣기 --> <!-- 이 안에 내용 복사해서 jsp에 붙여넣기 -->
<link rel="stylesheet" href="/resources/static/css/account.css"> <link rel="stylesheet" href="/resources/static/css/account.css">
<script> <script>
$(function(){
const $trs = $(".group_tr");
$trs.on("click", function(event){
const $tr = $(event.currentTarget);
const groupNumber = $tr.data("groupn");
const productId = $tr.data('productid');
goRead(groupNumber, productId);
});
});
function goRead(groupNumber, productId){
const $form = $("#form");
$("#productId").val(productId);
$("#groupId").val(groupNumber);
$form.trigger("submit");
}
</script> </script>
<div class="container"> <div class="container">
<div class="row"> <div class="row">
@@ -28,7 +48,6 @@
<input id="pPage" hidden type="text" name="page"> <input id="pPage" hidden type="text" name="page">
</form> </form>
<button style="float: right;" class="btn btn-primary" type="submit" id="btn_create" onclick="goCreate() ">생성</button> <button style="float: right;" class="btn btn-primary" type="submit" id="btn_create" onclick="goCreate() ">생성</button>
</div> </div>
<div class="row p-0 m-0"> <div class="row p-0 m-0">
<div class="col-12 m-0"> <div class="col-12 m-0">
@@ -38,7 +57,7 @@
</thead> </thead>
<tbody> <tbody>
<c:forEach items="${list }" var="dto" varStatus="status"> <c:forEach items="${list }" var="dto" varStatus="status">
<tr class="group_tr" data-mingu = "111" data-tid="${dto.groupNumber}"> <tr class="group_tr" data-groupn="${dto.groupNumber}" data-productid="${dto.productId}">
<td>${dto.viewGroupNumber}</td> <td>${dto.viewGroupNumber}</td>
<td>${dto.productDto.name}</td> <td>${dto.productDto.name}</td>
<td>${dto.quantity}</td> <td>${dto.quantity}</td>
@@ -69,6 +88,7 @@
</div> </div>
</div> </div>
</div> </div>
<form id="form" method="post"> <form id="form" action='/plan_in/read' method="post">
<input name="id" id="formInput" hidden> <input name="groupNumber" id="groupId" hidden>
<input name="productId" id="productId" hidden>
</form> </form>

View File

@@ -0,0 +1,5 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:forEach items="${list }" var="dto" varStatus="status">
${dto.productDto.name}<br>
</c:forEach>