mirror of
https://github.com/suhf/No1WMS.git
synced 2026-02-04 19:54:00 +09:00
update Categorys and Products and add Prices
This commit is contained in:
@@ -158,7 +158,8 @@ public class CategoryController {
|
||||
return checkkan;
|
||||
}
|
||||
|
||||
@PostMapping("/category/categorysearch")
|
||||
//카테고리 검색 모달
|
||||
@GetMapping("/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) {
|
||||
@@ -181,6 +182,8 @@ public class CategoryController {
|
||||
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);
|
||||
|
||||
91
src/main/java/com/no1/wms/price/PriceController.java
Normal file
91
src/main/java/com/no1/wms/price/PriceController.java
Normal file
@@ -0,0 +1,91 @@
|
||||
package com.no1.wms.price;
|
||||
|
||||
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.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.no1.wms.category.CategoryDto;
|
||||
|
||||
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/price")
|
||||
public class PriceController {
|
||||
|
||||
@Autowired
|
||||
PriceService priceService;
|
||||
|
||||
@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 perPage = 15; // 한 페이지에 보일 글의 개수
|
||||
int startRow = (page - 1) * perPage;
|
||||
|
||||
List<PriceDto> dto = priceService.priceList2(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 "/price/list";
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 생성 - 폼
|
||||
@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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
32
src/main/java/com/no1/wms/price/PriceDto.java
Normal file
32
src/main/java/com/no1/wms/price/PriceDto.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package com.no1.wms.price;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.ibatis.type.Alias;
|
||||
|
||||
import com.no1.wms.account.AccountDto;
|
||||
import com.no1.wms.product.ProductDto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Alias("PriceDto")
|
||||
public class PriceDto {
|
||||
|
||||
private String id;//id
|
||||
private String price;//가격
|
||||
private Date registration_date;//등록날짜
|
||||
private String manager_id;//담당자
|
||||
private String product_id; //제품 아이디
|
||||
private boolean activation;//활성화
|
||||
|
||||
private ProductDto productDto;
|
||||
private AccountDto accountDto;
|
||||
|
||||
}
|
||||
17
src/main/java/com/no1/wms/price/PriceMapper.java
Normal file
17
src/main/java/com/no1/wms/price/PriceMapper.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.no1.wms.price;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import com.no1.wms.category.CategoryDto;
|
||||
|
||||
@Mapper
|
||||
public interface PriceMapper {
|
||||
|
||||
List<PriceDto> priceList(Map<String, Object> m);
|
||||
int count(Map<String, Object> m);//카운터
|
||||
List<PriceDto> priceList2(Map<String, Object> m);//검색기능까지 포함
|
||||
int createProcess(PriceDto dto);
|
||||
}
|
||||
56
src/main/java/com/no1/wms/price/PriceService.java
Normal file
56
src/main/java/com/no1/wms/price/PriceService.java
Normal file
@@ -0,0 +1,56 @@
|
||||
package com.no1.wms.price;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.no1.wms.category.CategoryDto;
|
||||
import com.no1.wms.product.ProductDto;
|
||||
|
||||
@Service
|
||||
public class PriceService {
|
||||
|
||||
@Autowired
|
||||
PriceMapper mapper;
|
||||
|
||||
public List<PriceDto> priceList(int p){
|
||||
|
||||
int start = 0;
|
||||
int count = 10;
|
||||
|
||||
Map m = new HashMap<String, Object>();
|
||||
m.put("start", start);
|
||||
m.put("count", count);
|
||||
|
||||
return mapper.priceList(m);
|
||||
}
|
||||
|
||||
//페이징 카운터
|
||||
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<PriceDto> priceList2(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.priceList2(m);
|
||||
}
|
||||
|
||||
public int createProcess(PriceDto dto) {
|
||||
return mapper.createProcess(dto);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -5,6 +5,7 @@ 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;
|
||||
@@ -12,18 +13,22 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.no1.wms.category.CategoryDto;
|
||||
import com.no1.wms.category.CategoryService;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/product")
|
||||
public class ProductController {
|
||||
|
||||
@Autowired
|
||||
ProductService productservice;
|
||||
ProductService productService;
|
||||
|
||||
|
||||
@GetMapping("list")
|
||||
public String list(@RequestParam(name = "p", defaultValue = "1") int p, Model m) {
|
||||
|
||||
// 서비스로 카테고리 목록 불러오는 메서드 작성
|
||||
List<ProductDto> dto = productservice.productList(p);
|
||||
List<ProductDto> dto = productService.productList(p);
|
||||
m.addAttribute("list", dto);
|
||||
return "/product/list";
|
||||
}
|
||||
@@ -38,7 +43,7 @@ public class ProductController {
|
||||
@PostMapping("/create_process")
|
||||
@ResponseBody
|
||||
public boolean createProcess(ProductDto dto) {
|
||||
int i = productservice.createProcess(dto);
|
||||
int i = productService.createProcess(dto);
|
||||
if (i == 1) {
|
||||
return true;
|
||||
} else {
|
||||
@@ -49,25 +54,23 @@ public class ProductController {
|
||||
// 상세페이지
|
||||
@PostMapping("/read")
|
||||
public String read(String id, Model m) {
|
||||
ProductDto dto = productservice.selectById(id);
|
||||
ProductDto dto = productService.selectById(id);
|
||||
m.addAttribute("dto", dto);
|
||||
return "product/read";
|
||||
}
|
||||
|
||||
// 수정 폼
|
||||
@PostMapping("/update")
|
||||
public String update(String id, Model m) {
|
||||
ProductDto dto = productservice.selectById(id);
|
||||
ProductDto dto = productService.selectById(id);
|
||||
m.addAttribute("dto", dto);
|
||||
return "product/update";
|
||||
}
|
||||
|
||||
// 수정 - Ajax
|
||||
@PutMapping("update_process")
|
||||
@PutMapping("/update_process")
|
||||
@ResponseBody
|
||||
public boolean update_process(ProductDto dto) {
|
||||
System.out.println(dto.getId());
|
||||
|
||||
int i = productservice.updateById(dto);
|
||||
int i = productService.updateById(dto);
|
||||
if (i == 1) {
|
||||
return true;
|
||||
} else {
|
||||
@@ -76,5 +79,33 @@ public class ProductController {
|
||||
}
|
||||
|
||||
|
||||
// 삭제
|
||||
@DeleteMapping("/delete")
|
||||
@ResponseBody
|
||||
public boolean delete(String id) {
|
||||
int i = productService.deactivateById(id);
|
||||
if(i == 1) {
|
||||
return true;
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -12,4 +12,6 @@ public interface ProductMapper {
|
||||
int createProcess(ProductDto dto);
|
||||
ProductDto selectById(String id);
|
||||
int updateById(ProductDto dto);
|
||||
int deactivateById(String id);
|
||||
|
||||
}
|
||||
|
||||
@@ -38,4 +38,8 @@ public class ProductService {
|
||||
return mapper.updateById(dto);
|
||||
}
|
||||
|
||||
public int deactivateById(String id) {
|
||||
return mapper.deactivateById(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
95
src/main/resources/mappers/PriceMapper.xml
Normal file
95
src/main/resources/mappers/PriceMapper.xml
Normal file
@@ -0,0 +1,95 @@
|
||||
<?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.price.PriceMapper">
|
||||
<resultMap id="priceResultMap" type="PriceDto">
|
||||
<id column="id" property="id" />
|
||||
<result column="price" property="price" />
|
||||
<result column="registration_date" property="registration_date" />
|
||||
<result column="manager_id" property="manager_id" />
|
||||
<result column="product_id" property="product_id" />
|
||||
<result column="activation" property="activation" />
|
||||
<association property="productDto" javaType="ProductDto">
|
||||
<id column="id" property="id" />
|
||||
<result column="product_name" property="name" />
|
||||
</association>
|
||||
<association property="accountDto" javaType="AccountDto">
|
||||
<id column="id" property="id" />
|
||||
<result column="account_name" property="name" />
|
||||
</association>
|
||||
|
||||
</resultMap>
|
||||
|
||||
<!-- insert -->
|
||||
<insert id="createProcess" parameterType="priceDto">
|
||||
INSERT INTO prices (id, price, registration_date, manager_id, product_id, activation)
|
||||
VALUES (UUID(), #{price}, curdate(), #{manager_id}, #{product_id}, 1)
|
||||
</insert>
|
||||
|
||||
<!-- update -->
|
||||
|
||||
|
||||
<!-- delete -->
|
||||
|
||||
|
||||
<!-- select -->
|
||||
<select id="priceList" resultMap="priceResultMap" parameterType="map" >
|
||||
SELECT
|
||||
p.id, p.price, p.registration_date, p.manager_id, p.product_id, p.activation,
|
||||
p.manager_id, p.activation,
|
||||
pro.name as product_name,
|
||||
a.name as account_name
|
||||
FROM prices as p
|
||||
left join product as pro on p.product_id = pro.id
|
||||
left join account as a on p.manager_id = a.id
|
||||
WHERE p.activation != 0
|
||||
ORDER BY p.registration_date limit #{start} , #{count};
|
||||
</select>
|
||||
|
||||
<!-- 네비게이션바 전용 카운터 -->
|
||||
<select id="count" parameterType="map" resultType="int">
|
||||
select count(*)
|
||||
|
||||
FROM prices as p
|
||||
left join product as pro on p.product_id = pro.id
|
||||
left join account as a on p.manager_id = a.id
|
||||
|
||||
<where>
|
||||
<choose>
|
||||
<when test="searchn == 0"> p.activation = 1 and pro.name like concat('%',#{search},'%')</when>
|
||||
<when test="searchn == 1"> p.activation = 1 and p.price like concat('%',#{search},'%')</when>
|
||||
<when test="searchn == 2"> p.activation = 1 and p.registration_date like concat('%',#{search},'%')</when>
|
||||
</choose>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!-- 검색 -->
|
||||
<select id="priceList2" parameterType="map" resultMap="priceResultMap">
|
||||
SELECT
|
||||
p.id, p.price, p.registration_date, p.manager_id, p.product_id, p.activation,
|
||||
p.manager_id, p.activation,
|
||||
pro.name as product_name,
|
||||
a.name as account_name
|
||||
|
||||
FROM prices as p
|
||||
left join product as pro on p.product_id = pro.id
|
||||
left join account as a on p.manager_id = a.id
|
||||
|
||||
<where>
|
||||
<choose>
|
||||
<when test="searchn == 0"> p.activation = 1 and pro.name like concat('%',#{search},'%')</when>
|
||||
<when test="searchn == 1"> p.activation = 1 and p.price like concat('%',#{search},'%')</when>
|
||||
<when test="searchn == 2"> p.activation = 1 and p.registration_date like concat('%',#{search},'%')</when>
|
||||
</choose>
|
||||
</where>
|
||||
order by p.registration_date limit #{start} , #{perPage}
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -48,6 +48,12 @@
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="deactivateById" parameterType="String">
|
||||
UPDATE product
|
||||
SET activation = 0
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<!-- delete -->
|
||||
|
||||
|
||||
|
||||
@@ -77,17 +77,17 @@
|
||||
|
||||
<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>
|
||||
<a href="javascript:void(0);" class="page-link" onclick="pagingFunction(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>
|
||||
<a href="javascript:void(0);" class="page-link " onclick="pagingFunction(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>
|
||||
<a href="javascript:void(0);" class="page-link" onclick="pagingFunction(this.id)" id="${end + 1 }">></a>
|
||||
</li>
|
||||
</c:if>
|
||||
</ul>
|
||||
@@ -168,7 +168,7 @@
|
||||
|
||||
|
||||
});//ready
|
||||
function pageingFunction(clickedId){
|
||||
function pagingFunction(clickedId){
|
||||
var searchn1 = $("#searchn1").val();
|
||||
var search1 = $("#search1").val();
|
||||
|
||||
|
||||
@@ -21,10 +21,10 @@
|
||||
<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">
|
||||
<form>
|
||||
<div class="input-group mb-3 w-30 col-centered">
|
||||
<div class="w-25">
|
||||
<select class="form-select" name="searchn">
|
||||
<select class="form-select" name="searchn" id="searchn">
|
||||
<option selected="selected" value="4">세분류</option>
|
||||
<option value="1">대분류</option>
|
||||
<option value="2">중분류</option>
|
||||
@@ -32,8 +32,14 @@
|
||||
<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>
|
||||
<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>
|
||||
@@ -73,22 +79,23 @@
|
||||
<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>
|
||||
|
||||
<c:if test="${begin > pageNum }">
|
||||
<li class="page-item">
|
||||
<a href="javascript:void(0);" class="page-link" onclick="pagingFunction(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="pagingFunction(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="pagingFunction(this.id)" id="${end + 1 }">></a>
|
||||
</li>
|
||||
</c:if>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
</div><!-- row row-buttons -->
|
||||
@@ -102,13 +109,96 @@
|
||||
</div>
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
//검색기능
|
||||
$("#searchBtn").on("click",function(){
|
||||
|
||||
var searchn = $("#searchn").val();
|
||||
var search = $("#search").val();
|
||||
var existingModal = $("#searchKanModal");
|
||||
|
||||
if (existingModal.length === 0) {
|
||||
$.ajax({
|
||||
url:"/category/categorysearch",
|
||||
type:"get",
|
||||
data: {
|
||||
"searchn": searchn,
|
||||
"search": search,
|
||||
"p": 1,
|
||||
},
|
||||
datatype:"html"
|
||||
}).done(function(data){
|
||||
$("body").append(data);
|
||||
$("#searchKanModal").modal("show");
|
||||
}).fail(function() {
|
||||
alert("오류가 발생했습니다.");
|
||||
}).always(function() {
|
||||
//alert("항상뜨는 창입니다.");
|
||||
}); } else {
|
||||
// 이미 생성된 모달이 있을 경우 기존 모달을 열기
|
||||
existingModal.modal("show");
|
||||
}
|
||||
/*
|
||||
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 pagingFunction(clickedId){
|
||||
var searchn1 = $("#searchn1").val();
|
||||
var search1 = $("#search1").val();
|
||||
|
||||
var form = document.createElement("form");
|
||||
form.action = "/category/categorysearch";
|
||||
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>
|
||||
90
src/main/webapp/WEB-INF/views/price/create.jsp
Normal file
90
src/main/webapp/WEB-INF/views/price/create.jsp
Normal file
@@ -0,0 +1,90 @@
|
||||
<%@ page contentType="text/html; charset=UTF-8"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>제품 가격 생성</title>
|
||||
|
||||
<style>
|
||||
.col-centered{
|
||||
margin: 0 auto;
|
||||
float: none;
|
||||
}
|
||||
.col-margin-left-32{
|
||||
margin-left: 32%;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div class="mt-5 mb-5 text-center">
|
||||
<h1>제품 가격 생성</h1>
|
||||
</div>
|
||||
<hr>
|
||||
<div style="text-align: center">
|
||||
<form id="createForm">
|
||||
<div class="ulTag">
|
||||
<div class="row">
|
||||
<div class="col-12" style="text-align: center;">
|
||||
<div class="input-group mb-3 w-40 col-centered">
|
||||
<span class="input-group-text" id="basic-addon1">제품명</span>
|
||||
<input type="text" name="productDto.name" id="productDto.name" class="form-control"
|
||||
placeholder="제품명을 검색하세요" aria-label="제품명" value="${dto.productDto.name }"
|
||||
aria-describedby="basic-addon1">
|
||||
<button class="btn btn-outline-secondary rounded-end" id="searchProductName"
|
||||
style="background-color:#FF5E5E;" type="button" >검색</button>
|
||||
<input type='hidden' id='searchProductName' value='0'>
|
||||
|
||||
</div>
|
||||
<!-- 설명만 있는 입력 -->
|
||||
<div class="input-group mb-3 w-40 col-centered">
|
||||
<span class="input-group-text" id="basic-addon2">중분류</span>
|
||||
<input type="text" name="cls_nm_2" id="cls_nm_2" class="form-control"
|
||||
placeholder="중분류를 입력하세요" aria-label="중분류" value="${dto.cls_nm_2 }"
|
||||
aria-describedby="basic-addon1">
|
||||
</div>
|
||||
<div class="input-group mb-3 w-40 col-centered">
|
||||
<span class="input-group-text" id="basic-addon3">소분류</span>
|
||||
<input type="text" name="cls_nm_3" id="cls_nm_3" class="form-control"
|
||||
placeholder="소분류를 입력하세요" aria-label="소분류" value="${dto.cls_nm_3 }"
|
||||
aria-describedby="basic-addon1">
|
||||
</div>
|
||||
<div class="input-group mb-3 w-40 col-centered">
|
||||
<span class="input-group-text" id="basic-addon4">세분류</span>
|
||||
<input type="text" name="cls_nm_4" id="cls_nm_4" class="form-control"
|
||||
placeholder="세분류를 입력하세요" aria-label="세분류" value="${dto.cls_nm_4 }"
|
||||
aria-describedby="basic-addon1">
|
||||
</div>
|
||||
<div class="input-group mb-3 w-40 col-centered">
|
||||
<span class="input-group-text" id="basic-addon5">KAN 분류코드</span>
|
||||
<input type="number" min="1" name="kan_code" id="kan_code" class="form-control"
|
||||
placeholder="KAN 분류코드를 입력하세요" aria-label="KAN 분류코드" value="${dto.kan_code }"
|
||||
aria-describedby="button-addon2">
|
||||
<button class="btn btn-outline-secondary rounded-end" id="checkKan"
|
||||
style="background-color:#FF5E5E;" type="button" >중복확인</button>
|
||||
<input type='hidden' id='kan_chack' value='0'>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12 ">
|
||||
<div class="w-40 col-centered" style="text-align: right">
|
||||
<button type="button" class="btn btn-success" id="submitBtn">생성</button>
|
||||
<button type="button" class="btn btn-secondary" id="cancelBtn">취소</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script>
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
116
src/main/webapp/WEB-INF/views/price/list.jsp
Normal file
116
src/main/webapp/WEB-INF/views/price/list.jsp
Normal file
@@ -0,0 +1,116 @@
|
||||
<%@ page contentType="text/html; charset=UTF-8"%>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
|
||||
<!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>
|
||||
<div class="input-group mb-3 w-30 col-centered">
|
||||
<div class="w-25">
|
||||
<select class="form-select" name="searchn" id="searchn">
|
||||
<option selected="selected" value="0">제품명</option>
|
||||
<option value="1">가격</option>
|
||||
<option value="2">등록날짜</option>
|
||||
</select>
|
||||
</div>
|
||||
<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">
|
||||
<thead class="table-dark">
|
||||
<tr>
|
||||
<th>번호</th>
|
||||
<th>제품명</th>
|
||||
<th>가격</th>
|
||||
<th>등록날짜</th>
|
||||
<th>담당자</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:forEach items="${list }" var="dto" varStatus="status">
|
||||
<tr class="detailTr" data-id="${dto.id }" >
|
||||
<td>${status.count }</td>
|
||||
<td>${dto.productDto.name }</td>
|
||||
<td>${dto.price }</td>
|
||||
<td><fmt:formatDate value="${dto.registration_date }"
|
||||
dateStyle="short" /></td>
|
||||
<td>${dto.accountDto.name }</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 href="javascript:void(0);" class="page-link" onclick="pagingFunction(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="pagingFunction(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="pagingFunction(this.id)" id="${end + 1 }">></a>
|
||||
</li>
|
||||
</c:if>
|
||||
</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>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
//POST방식으로 create폼화면 출력
|
||||
$("#createButton").on("click",function(){
|
||||
var form = document.createElement("form");
|
||||
form.action = "/price/create";
|
||||
form.method = "POST";
|
||||
document.body.appendChild(form);
|
||||
form.submit();
|
||||
});//createButton
|
||||
});//ready
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -84,86 +84,11 @@
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
<!-- 모달화면 -->
|
||||
<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="categorySearch">
|
||||
<div class="input-group mb-3 w-50 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>
|
||||
</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>
|
||||
</div>
|
||||
</form>
|
||||
</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>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="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>
|
||||
$(document).ready(function() {
|
||||
|
||||
const searchKanModalBootStrap = new bootstrap.Modal("#searchKanModal");
|
||||
$("#searchKan").on("click", function(){
|
||||
searchKanModalBootStrap.show();
|
||||
});//searchKan
|
||||
|
||||
$("#searchVendor").on("click", function(){
|
||||
searchModalBootStrap.show();
|
||||
});//searcVendor
|
||||
|
||||
$("#submitBtn").on("click", function(){
|
||||
var name = $("#name").val();
|
||||
var company_name = $("#company_name").val();
|
||||
@@ -240,19 +165,34 @@
|
||||
})
|
||||
|
||||
|
||||
$("#searchKan").on("click", function(){
|
||||
searchKanCode();
|
||||
});//searchKan
|
||||
|
||||
$("#searchVendor").on("click", function(){
|
||||
searchModalBootStrap.show();
|
||||
});//searcVendor
|
||||
|
||||
|
||||
|
||||
|
||||
});//ready
|
||||
function searchKanCode(){
|
||||
|
||||
}
|
||||
function searchKanCode(){
|
||||
$.ajax({
|
||||
url:"/category/categorysearch",
|
||||
type:"get",
|
||||
datatype:"html"
|
||||
}).done(function(data){
|
||||
$("body").append(data);
|
||||
$("#searchKanModal").modal("show");
|
||||
}).fail(function() {
|
||||
alert("오류가 발생했습니다.");
|
||||
}).always(function() {
|
||||
//alert("항상뜨는 창입니다.");
|
||||
});
|
||||
}
|
||||
|
||||
function searchVendor(){
|
||||
|
||||
}
|
||||
|
||||
});//ready
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@@ -101,9 +101,34 @@
|
||||
|
||||
})//modifyBtn click
|
||||
|
||||
|
||||
yesNoModal.yesFunction = deleteProductFunction;
|
||||
});//ready
|
||||
|
||||
|
||||
function deleteProductFunction(){
|
||||
var id = $("#id").val();
|
||||
$.ajax({
|
||||
url: "/product/delete",
|
||||
type: "delete",
|
||||
data: {
|
||||
"id": id
|
||||
},
|
||||
datatype:"json"
|
||||
}).done(function(data) {
|
||||
if (data == true) {
|
||||
alert("삭제되었습니다.");
|
||||
$(location).attr("href", "/product/list");
|
||||
} else {
|
||||
alert("정상적으로 삭제되지 않았습니다..");
|
||||
}
|
||||
}).fail(function() {
|
||||
alert("오류가 발생했습니다.");
|
||||
}).always(function() {
|
||||
//
|
||||
});
|
||||
|
||||
}//deleteCategoryFunction
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user