mirror of
https://github.com/suhf/No1WMS.git
synced 2026-02-05 04:03:45 +09:00
add product dto, mapper, mapper.xml, controller, service,
product.list.jsp, vendorDto, change category controller, mapper.xml, read.jsp
This commit is contained in:
@@ -98,16 +98,14 @@ public class CategoryController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 삭제
|
// 삭제
|
||||||
@DeleteMapping("/category/delete/{kan_code}")
|
@DeleteMapping("/category/delete")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public int delete(@PathVariable String kan_code) {
|
public boolean delete(String kan_code) {
|
||||||
int i = categoryService.deactivateByKanCode(kan_code);
|
int i = categoryService.deactivateByKanCode(kan_code);
|
||||||
if (i == 1) {
|
if (i == 1) {
|
||||||
return i;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// ajax테스트후 결정
|
return false;
|
||||||
// m.addAttribute("dto", dto);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
28
src/main/java/com/no1/wms/product/ProductController.java
Normal file
28
src/main/java/com/no1/wms/product/ProductController.java
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
package com.no1.wms.product;
|
||||||
|
|
||||||
|
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.RequestParam;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class ProductController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ProductService productservice;
|
||||||
|
|
||||||
|
@GetMapping("/product/list")
|
||||||
|
public String list(@RequestParam(name = "p", defaultValue = "1") int p, Model m) {
|
||||||
|
|
||||||
|
// 서비스로 카테고리 목록 불러오는 메서드 작성
|
||||||
|
List<ProductDto> dto = productservice.productList(p);
|
||||||
|
m.addAttribute("list", dto);
|
||||||
|
return "product/list";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
30
src/main/java/com/no1/wms/product/ProductDto.java
Normal file
30
src/main/java/com/no1/wms/product/ProductDto.java
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
package com.no1.wms.product;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.apache.ibatis.type.Alias;
|
||||||
|
|
||||||
|
import com.no1.wms.category.CategoryDto;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Alias("ProductDto")
|
||||||
|
public class ProductDto {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
private String name;
|
||||||
|
private String company_name;
|
||||||
|
private String kan_code;
|
||||||
|
private String vendor_id;
|
||||||
|
private Date registration_date;
|
||||||
|
private String manager_id;
|
||||||
|
private boolean activation;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
15
src/main/java/com/no1/wms/product/ProductMapper.java
Normal file
15
src/main/java/com/no1/wms/product/ProductMapper.java
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package com.no1.wms.product;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface ProductMapper {
|
||||||
|
|
||||||
|
List<ProductDto> productList(Map<String, Object> m);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
29
src/main/java/com/no1/wms/product/ProductService.java
Normal file
29
src/main/java/com/no1/wms/product/ProductService.java
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
package com.no1.wms.product;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
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>();
|
||||||
|
m.put("start", start);
|
||||||
|
m.put("count", count);
|
||||||
|
|
||||||
|
return mapper.productList(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
25
src/main/java/com/no1/wms/vendor/VendorDto.java
vendored
Normal file
25
src/main/java/com/no1/wms/vendor/VendorDto.java
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
package com.no1.wms.vendor;
|
||||||
|
|
||||||
|
import org.apache.ibatis.type.Alias;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Alias("VendorDto")
|
||||||
|
public class VendorDto {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
private String name;
|
||||||
|
private String president_name;
|
||||||
|
private String address;
|
||||||
|
private String registration_number;
|
||||||
|
private String email;
|
||||||
|
private String president_telephone;
|
||||||
|
private String vendor_manager;
|
||||||
|
private String vendor_manager_telephone;
|
||||||
|
private String main_product;
|
||||||
|
private String manager_id;
|
||||||
|
private boolean activation;
|
||||||
|
}
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<select id="categoryList" parameterType="map" resultType="CategoryDto">
|
<select id="categoryList" parameterType="map" resultType="CategoryDto">
|
||||||
select * from product_category
|
select * from product_category where activation != 0
|
||||||
order by kan_code limit #{start} , #{count}
|
order by kan_code limit #{start} , #{count}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|||||||
64
src/main/resources/mappers/ProductMapper.xml
Normal file
64
src/main/resources/mappers/ProductMapper.xml
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTO Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
|
||||||
|
<mapper namespace="com.no1.wms.product.ProductMapper">
|
||||||
|
<resultMap id="authorityResultMap" type="AuthorityDto">
|
||||||
|
<id column="id" property="id"/>
|
||||||
|
<result column="name" property="name"/>
|
||||||
|
<result column="company_name" property="company_name"/>
|
||||||
|
<result column="kan_code" property="kan_code"/>
|
||||||
|
<result column="vendor_id" property="vendor_id"/>
|
||||||
|
<result column="registration_date" property="registration_date"/>
|
||||||
|
<result column="manager_id" property="manager_id"/>
|
||||||
|
<result column="activation" property="activation"/>
|
||||||
|
<association property="vendorDto" javaType="AccountDto">
|
||||||
|
<id column="personal_authority_id" property="personalAuthorityId" />
|
||||||
|
|
||||||
|
</association>
|
||||||
|
<association property="accountDto" javaType="AccountDto">
|
||||||
|
<id column="personal_authority_id" property="personalAuthorityId" />
|
||||||
|
|
||||||
|
</association>
|
||||||
|
<association property="accountDto" javaType="AccountDto">
|
||||||
|
<id column="personal_authority_id" property="personalAuthorityId" />
|
||||||
|
|
||||||
|
</association>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- insert -->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- update -->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- delete -->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- select -->
|
||||||
|
<select id="productList" parameterType="map" resultType="CategoryDto">
|
||||||
|
select * from product where activation != 0
|
||||||
|
order by registration_date limit #{start} , #{count}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -8,7 +8,13 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="mt-5 mb-5 text-center">
|
<div class="mt-5 mb-5 text-center">
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
<h1>제품 카테고리 상세페이지</h1>
|
<h1>제품 카테고리 상세페이지</h1>
|
||||||
|
<div class="col-10" style="text-align: right;">
|
||||||
|
<button type="button" class="btn btn-danger" id="yes_no_modal_show_button">삭제</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
@@ -86,10 +92,41 @@
|
|||||||
|
|
||||||
})//modifyBtn click
|
})//modifyBtn click
|
||||||
|
|
||||||
|
yesNoModal.yesFunction = deleteCategoryFunction;
|
||||||
|
|
||||||
});//ready
|
});//ready
|
||||||
</script>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function deleteCategoryFunction(){
|
||||||
|
var kan_code = $("#kan_code").val();
|
||||||
|
$.ajax({
|
||||||
|
url: "/category/delete",
|
||||||
|
type: "delete",
|
||||||
|
data: {
|
||||||
|
"kan_code": kan_code
|
||||||
|
},
|
||||||
|
datatype:"json"
|
||||||
|
}).done(function(data) {
|
||||||
|
if (data == true) {
|
||||||
|
alert("삭제되었습니다.");
|
||||||
|
$(location).attr("href", "/category/list");
|
||||||
|
} else {
|
||||||
|
alert("정상적으로 삭제되지 않았습니다..");
|
||||||
|
}
|
||||||
|
}).fail(function() {
|
||||||
|
alert("오류가 발생했습니다.");
|
||||||
|
}).always(function() {
|
||||||
|
//
|
||||||
|
});
|
||||||
|
|
||||||
|
}//deleteCategoryFunction
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
110
src/main/webapp/WEB-INF/views/product/list.jsp
Normal file
110
src/main/webapp/WEB-INF/views/product/list.jsp
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
<%@ page contentType="text/html; charset=UTF-8"%>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>제품 목록</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="mt-5 mb-5 text-center">
|
||||||
|
<h1>제품 관리</h1>
|
||||||
|
</div>
|
||||||
|
<hr>
|
||||||
|
<div class="body">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="col-12">
|
||||||
|
<form action="productSearch">
|
||||||
|
<div class="input-group mb-3 w-30 col-centered">
|
||||||
|
<div class="w-25">
|
||||||
|
<select class="form-select">
|
||||||
|
<option selected="selected" value="name">제품명</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>
|
||||||
|
</div>
|
||||||
|
<input type="text" name="productSearch" class="form-control" aria-label="Text input with dropdown button" placeholder="검색어를 입력하세요">
|
||||||
|
<button class="btn btn-info" type="button" id="button-addon2 searchBtn">검색</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="container-fluid">
|
||||||
|
|
||||||
|
<div class="row row-table">
|
||||||
|
<div class="col-12">
|
||||||
|
<table class="table">
|
||||||
|
<thead class="table-dark">
|
||||||
|
<tr>
|
||||||
|
<th>제품명</th>
|
||||||
|
<th>회사명</th>
|
||||||
|
<th>소분류</th>
|
||||||
|
<th>거래처</th>
|
||||||
|
<th>등록날짜</th>
|
||||||
|
<th>담당자</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">
|
||||||
|
<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>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
<div class="col-3 text-end">
|
||||||
|
<button type="button" class="btn btn-primary" id="createButton">생성</button>
|
||||||
|
</div>
|
||||||
|
</div><!-- row row-buttons -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user