[Spring][쇼핑몰 프로젝트][20] 상품조회 기능 구현

https://kimvampa.tistory.com/205
https://kimvampa.tistory.com/204
https://kimvampa.tistory.com/203
This commit is contained in:
SeoJin Kim
2021-04-22 00:45:23 +09:00
parent df032170ba
commit 504401c43c
22 changed files with 1302 additions and 24 deletions

View File

@@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.vam.model.AuthorVO;
import com.vam.model.BookVO;
@@ -81,6 +82,25 @@ public class AdminController {
}
/* 상품 조회 페이지 */
@GetMapping("/goodsDetail")
public void goodsGetInfoGET(int bookId, Criteria cri, Model model) throws JsonProcessingException {
logger.info("goodsGetInfo()........." + bookId);
ObjectMapper mapper = new ObjectMapper();
/* 카테고리 리스트 데이터 */
model.addAttribute("cateList", mapper.writeValueAsString(adminService.cateList()));
/* 목록 페이지 조건 정보 */
model.addAttribute("cri", cri);
/* 조회 페이지 정보 */
model.addAttribute("goodsInfo", adminService.goodsGetDetail(bookId));
}
/* 작가 등록 페이지 접속 */
@RequestMapping(value = "authorEnroll", method = RequestMethod.GET)
public void authorEnrollGET() throws Exception{

View File

@@ -20,4 +20,7 @@ public interface AdminMapper {
/* 상품 총 개수 */
public int goodsGetTotal(Criteria cri);
/* 상품 조회 페이지 */
public BookVO goodsGetDetail(int bookId);
}

View File

@@ -20,4 +20,7 @@ public interface AdminService {
/* 상품 총 개수 */
public int goodsGetTotal(Criteria cri);
/* 상품 조회 페이지 */
public BookVO goodsGetDetail(int bookId);
}

View File

@@ -41,14 +41,27 @@ public class AdminServiceImpl implements AdminService {
/* 상품 리스트 */
@Override
public List<BookVO> goodsGetList(Criteria cri) {
log.info("goodsGetTotalList()..........");
return adminMapper.goodsGetList(cri);
}
/* 상품 총 갯수 */
public int goodsGetTotal(Criteria cri) {
log.info("goodsGetTotal().........");
return adminMapper.goodsGetTotal(cri);
}
/* 상품 조회 페이지 */
@Override
public BookVO goodsGetDetail(int bookId) {
log.info("(service)bookGetDetail......." + bookId);
return adminMapper.goodsGetDetail(bookId);
}
}

View File

@@ -57,4 +57,13 @@
</select>
<!-- 상품 조회 페이지 -->
<select id="goodsGetDetail" resultType="com.vam.model.BookVO">
select bookId, bookName, (select authorName from vam_author where authorId =vam_book.authorId) authorName,
authorId, publeYear, publisher, cateCode, bookStock, bookDiscount, bookIntro, bookContents, regDate, updateDate
from vam_book where bookId = #{bookId}
</select>
</mapper>

View File

@@ -0,0 +1,289 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="../resources/css/admin/goodsDetail.css">
<script
src="https://code.jquery.com/jquery-3.4.1.js"
integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU="
crossorigin="anonymous"></script>
<script src="https://cdn.ckeditor.com/ckeditor5/26.0.0/classic/ckeditor.js"></script>
</head>
<body>
<%@include file="../includes/admin/header.jsp" %>
<div class="admin_content_wrap">
<div class="admin_content_subject"><span>상품 상세</span></div>
<div class="admin_content_main">
<div class="form_section">
<div class="form_section_title">
<label>책 제목</label>
</div>
<div class="form_section_content">
<input name="bookName" value="<c:out value="${goodsInfo.bookName}"/>" disabled>
</div>
</div>
<div class="form_section">
<div class="form_section_title">
<label>등록 날짜</label>
</div>
<div class="form_section_content">
<input value="<fmt:formatDate value='${goodsInfo.regDate}' pattern='yyyy-MM-dd'/>" disabled>
</div>
</div>
<div class="form_section">
<div class="form_section_title">
<label>최근 수정 날짜</label>
</div>
<div class="form_section_content">
<input value="<fmt:formatDate value='${goodsInfo.updateDate}' pattern='yyyy-MM-dd'/>" disabled>
</div>
</div>
<div class="form_section">
<div class="form_section_title">
<label>작가</label>
</div>
<div class="form_section_content">
<input id="authorName_input" readonly="readonly" value="${goodsInfo.authorName }" disabled>
</div>
</div>
<div class="form_section">
<div class="form_section_title">
<label>출판일</label>
</div>
<div class="form_section_content">
<input name="publeYear" autocomplete="off" readonly="readonly" value="<c:out value="${goodsInfo.publeYear}"/>" disabled>
</div>
</div>
<div class="form_section">
<div class="form_section_title">
<label>출판사</label>
</div>
<div class="form_section_content">
<input name="publisher" value="<c:out value="${goodsInfo.publisher}"/>" disabled>
</div>
</div>
<div class="form_section">
<div class="form_section_title">
<label>책 카테고리</label>
</div>
<div class="form_section_content">
<div class="cate_wrap">
<span>대분류</span>
<select class="cate1" disabled>
<option value="none">선택</option>
</select>
</div>
<div class="cate_wrap">
<span>중분류</span>
<select class="cate2" disabled>
<option value="none">선택</option>
</select>
</div>
<div class="cate_wrap">
<span>소분류</span>
<select class="cate3" name="cateCode" disabled>
<option value="none">선택</option>
</select>
</div>
</div>
</div>
<div class="form_section">
<div class="form_section_title">
<label>상품 가격</label>
</div>
<div class="form_section_content">
<input name="bookPrice" value="<c:out value="${goodsInfo.bookPrice}"/>" disabled>
</div>
</div>
<div class="form_section">
<div class="form_section_title">
<label>상품 재고</label>
</div>
<div class="form_section_content">
<input name="bookStock" value="<c:out value="${goodsInfo.bookStock}"/>" disabled>
</div>
</div>
<div class="form_section">
<div class="form_section_title">
<label>상품 할인율</label>
</div>
<div class="form_section_content">
<input id="discount_interface" maxlength="2" disabled>
</div>
</div>
<div class="form_section">
<div class="form_section_title">
<label>책 소개</label>
</div>
<div class="form_section_content bit">
<textarea name="bookIntro" id="bookIntro_textarea" disabled>${goodsInfo.bookIntro}</textarea>
</div>
</div>
<div class="form_section">
<div class="form_section_title">
<label>책 목차</label>
</div>
<div class="form_section_content bct">
<textarea name="bookContents" id="bookContents_textarea" disabled>${goodsInfo.bookContents}</textarea>
</div>
</div>
<div class="btn_section">
<button id="cancelBtn" class="btn">상품 목록</button>
<button id="enrollBtn" class="btn enroll_btn">수정 </button>
</div>
</div>
<form id="moveForm" action="/admin/goodsManage" method="get" >
<input type="hidden" name="pageNum" value="${pageMaker.cri.pageNum}">
<input type="hidden" name="amount" value="${pageMaker.cri.amount}">
<input type="hidden" name="keyword" value="${pageMaker.cri.keyword}">
</form>
</div>
<%@include file="../includes/admin/footer.jsp" %>
<script>
$(document).ready(function(){
/* 할인율 값 삽입 */
let bookDiscount = '<c:out value="${goodsInfo.bookDiscount}"/>' * 100;
$("#discount_interface").attr("value", bookDiscount);
/* 출판일 값 가공 */
let publeYear = '${goodsInfo.publeYear}';
let length = publeYear.indexOf(" ");
publeYear = publeYear.substring(0, length);
$("input[name='publeYear']").attr("value", publeYear);
/* 책 소개 */
ClassicEditor
.create(document.querySelector('#bookIntro_textarea'))
.then(editor => {
console.log(editor);
editor.isReadOnly = true;
})
.catch(error=>{
console.error(error);
});
/* 책 목차 */
ClassicEditor
.create(document.querySelector('#bookContents_textarea'))
.then(editor => {
console.log(editor);
editor.isReadOnly = true;
})
.catch(error=>{
console.error(error);
});
/* 카테고리 */
let cateList = JSON.parse('${cateList}');
let cate1Array = new Array();
let cate2Array = new Array();
let cate3Array = new Array();
let cate1Obj = new Object();
let cate2Obj = new Object();
let cate3Obj = new Object();
let cateSelect1 = $(".cate1");
let cateSelect2 = $(".cate2");
let cateSelect3 = $(".cate3");
/* 카테고리 배열 초기화 메서드 */
function makeCateArray(obj,array,cateList, tier){
for(let i = 0; i < cateList.length; i++){
if(cateList[i].tier === tier){
obj = new Object();
obj.cateName = cateList[i].cateName;
obj.cateCode = cateList[i].cateCode;
obj.cateParent = cateList[i].cateParent;
array.push(obj);
}
}
}
/* 배열 초기화 */
makeCateArray(cate1Obj,cate1Array,cateList,1);
makeCateArray(cate2Obj,cate2Array,cateList,2);
makeCateArray(cate3Obj,cate3Array,cateList,3);
let targetCate2 = '';
let targetCate3 = '${goodsInfo.cateCode}';
for(let i = 0; i < cate3Array.length; i++){
if(targetCate3 === cate3Array[i].cateCode){
targetCate3 = cate3Array[i];
}
}// for
for(let i = 0; i < cate3Array.length; i++){
if(targetCate3.cateParent === cate3Array[i].cateParent){
cateSelect3.append("<option value='"+cate3Array[i].cateCode+"'>" + cate3Array[i].cateName + "</option>");
}
}
$(".cate3 option").each(function(i,obj){
if(targetCate3.cateCode === obj.value){
$(obj).attr("selected", "selected");
}
});
for(let i = 0; i < cate2Array.length; i++){
if(targetCate3.cateParent === cate2Array[i].cateCode){
targetCate2 = cate2Array[i];
}
}// for
for(let i = 0; i < cate2Array.length; i++){
if(targetCate2.cateParent === cate2Array[i].cateParent){
cateSelect2.append("<option value='"+cate2Array[i].cateCode+"'>" + cate2Array[i].cateName + "</option>");
}
}
$(".cate2 option").each(function(i,obj){
if(targetCate2.cateCode === obj.value){
$(obj).attr("selected", "selected");
}
});
for(let i = 0; i < cate1Array.length; i++){
cateSelect1.append("<option value='"+cate1Array[i].cateCode+"'>" + cate1Array[i].cateName + "</option>");
}
$(".cate1 option").each(function(i,obj){
if(targetCate2.cateParent === obj.value){
$(obj).attr("selected", "selected");
}
});
}); // $(document).ready
</script>
</body>
</html>

View File

@@ -38,7 +38,11 @@
<c:forEach items="${list}" var="list">
<tr>
<td><c:out value="${list.bookId}"></c:out></td>
<td><c:out value="${list.bookName}"></c:out></td>
<td>
<a class="move" href='<c:out value="${list.bookId}"/>'>
<c:out value="${list.bookName}"></c:out>
</a>
</td>
<td><c:out value="${list.authorName}"></c:out></td>
<td><c:out value="${list.cateName}"></c:out></td>
<td><c:out value="${list.bookStock}"></c:out></td>
@@ -155,6 +159,17 @@ $(".pageMaker_btn a").on("click", function(e){
});
/* 상품 조회 페이지 */
$(".move").on("click", function(e){
e.preventDefault();
moveForm.append("<input type='hidden' name='bookId' value='"+$(this).attr("href") + "'>");
moveForm.attr("action", "/admin/goodsDetail");
moveForm.submit();
});
</script>

View File

@@ -0,0 +1,268 @@
@charset "UTF-8";
*{
margin: 0;
padding:0;
}
a{
text-decoration: none;
}
ul{
list-style: none;
}
/* 화면 전체 렙 */
.wrapper{
width: 100%;
}
/* content 랩 */
.wrap{
width : 1080px;
margin: auto;
}
/* 홈페이지 기능 네비 */
.top_gnb_area{
width: 100%;
height: 50px;
background-color: #f0f0f1;
position:relative;
}
.top_gnb_area .list{
position: absolute;
top: 0px;
right: 0;
}
.top_gnb_area .list li{
list-style: none;
float : left;
padding: 13px 15px 0 10px;
font-weight: 900;
cursor: pointer;
}
/* 관리제 페이지 상단 현페이지 정보 */
.admin_top_wrap{
height:110px;
line-height: 110px;
background-color: #5080bd;
margin-bottom: 15px;
}
.admin_top_wrap>span{
margin-left: 30px;
display:inline-block;
color: white;
font-size: 50px;
font-weight: bolder;
}
/* 관리자 wrap(네비+컨텐츠) */
.admin_wrap{
}
/* 관리자페이지 네비 영역 */
.admin_navi_wrap{
width: 20%;
height: 300px;
float:left;
height: 100%;
}
.admin_navi_wrap li{
display: block;
height: 80px;
line-height: 80px;
text-align: center;
}
.admin_navi_wrap li a{
display: block;
height: 100%;
width: 95%;
margin: 0 auto;
cursor: pointer;
font-size: 30px;
font-weight: bolder;
}
.admin_navi_wrap li a:link {color: black;}
.admin_navi_wrap li a:visited {color: black;}
.admin_navi_wrap li a:active {color: black;}
.admin_navi_wrap li a:hover {color: black;}
.admin_list_02{
background-color: #c8c8c8;
}
/* 관리자페이지 컨텐츠 영역 */
.admin_content_wrap{
width: 80%;
float:left;
min-height: 700px;
}
.admin_content_subject{ /* 관리자 컨텐츠 제목 영역 */
font-size: 40px;
font-weight: bolder;
padding-left: 15px;
background-color: #6AAFE6;
height: 80px;
line-height: 80px;
color: white;
}
/* 관리자 컨텐츠 메인 영역 */
.form_section{
width: 95%;
margin-left: 2%;
margin-top: 20px;
border: 1px solid #dbdde2;
background-color: #efefef;
}
.form_section_title{
padding: 20px 35px;
}
.form_section_title label{
display: block;
font-size: 20px;
font-weight: 800;
}
.form_section_content{
padding: 20px 35px;
border-top: 1px solid #dbdde2;
}
.form_section_content input{
width: 98%;
height: 25px;
font-size: 20px;
padding: 5px 1%;
}
.ui-datepicker-trigger { /* 캘린더 css 설정 */
margin-left: 25px;
width: 14%;
height: 38px;
font-weight: 600;
background-color: #dfe8f5;
font-size: 15px;
cursor:pointer;
}
.authorId_btn { /* 작가 선택 css 설정 */
margin-left: 20px;
width: 14%;
height: 38px;
font-weight: 600;
background-color: #dfe8f5;
font-size: 15px;
cursor:pointer;
}
.ck-content { /* ckeditor 높이 */
height: 170px;
}
/* 버튼 영역 */
.btn_section{
text-align: center;
margin: 80px 0;
}
.btn{
min-width: 180px;
padding: 4px 30px;
font-size: 25px;
font-weight: 600;
line-height: 40px;
}
.enroll_btn{
background-color: #dbdde2;
margin-left:15px;
}
#enrollBtn:hover {
background-color: #c9cbd0;
}
.form_section_content select { /* 카테고리 css 설정 */
width: 92%;
height: 35px;
font-size: 20px;
text-align-last: center;
margin-left: 5px;
}
.cate_wrap span {
font-weight: 600;
}
.cate_wrap:not(:first-child) {
margin-top: 20px;
}
/* footer navai 영역 */
.footer_nav{
width:100%;
height:50px;
}
.footer_nav_container{
width: 100%;
height: 100%;
background-color:#8EC0E4;
}
.footer_nav_container>ul{
font-weight : bold;
float:left;
list-style:none;
position:relative;
padding-top:10px;
line-height: 27px;
font-family: dotum;
margin-left: 10px;
}
.footer_nav_container>ul>li{
display:inline;
width: 45px;
height: 19px;
padding: 10px 9px 0 10px;
}
.footer_nav_container>ul>span{
margin: 0 4px;
}
/* footer 영역 */
.footer{
width:100%;
height:130px;
background-color:#D4DFE6;
padding-bottom : 50px;
}
.footer_container{
width: 100%;
height: 100%;
margin: auto;
}
.footer_left>img {
width: 150%;
height: 130px;
margin-left: -20px;
margin-top: -12px;
}
.footer_left{
float :left;
width: 170px;
margin-left: 20px;
margin-top : 30px;
}
.footer_right{
float :left;
width: 680px;
margin-left: 70px;
margin-top : 30px;
}
/* float 속성 해제 */
.clearfix{
clear: both;
}

View File

@@ -1,15 +1,13 @@
package com.vam.mapper;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.vam.model.Criteria;
import com.vam.model.BookVO;
@RunWith(SpringJUnit4ClassRunner.class)
@@ -52,7 +50,7 @@ public class AdminMapperTests {
*/
/* 상품 리스트 & 상품 총 개수*/
/**/
/*
@Test
public void goodsGetListTests() {
@@ -60,7 +58,7 @@ public class AdminMapperTests {
cri.setKeyword("test");
/* 상품 리스트 */
// 상품 리스트
List list = mapper.goodsGetList(cri);
for(int i = 0; i < 10; i++) {
System.out.println("result..........." +i + " : " + list.get(i) );
@@ -68,11 +66,25 @@ public class AdminMapperTests {
/* 상품 총 개수 */
/// 상품 총 개수
//int result = mapper.goodsGetTotal(cri);
//System.out.println("resout........." + result);
}
*/
/* 상품 조회 페이지 */
@Test
public void goodsGetDetailTest() {
int bookId = 150;
BookVO result = mapper.goodsGetDetail(bookId);
System.out.println("상품 조회 데이터 : " + result);
}
}

View File

@@ -57,4 +57,13 @@
</select>
<!-- 상품 조회 페이지 -->
<select id="goodsGetDetail" resultType="com.vam.model.BookVO">
select bookId, bookName, (select authorName from vam_author where authorId =vam_book.authorId) authorName,
authorId, publeYear, publisher, cateCode, bookStock, bookDiscount, bookIntro, bookContents, regDate, updateDate
from vam_book where bookId = #{bookId}
</select>
</mapper>

View File

@@ -1,5 +1,5 @@
#Generated by Maven Integration for Eclipse
#Tue Apr 13 13:59:44 KST 2021
#Mon Apr 19 22:02:04 KST 2021
m2e.projectLocation=C\:\\Users\\sjinj\\git\\Blog_Project\\VamPa
m2e.projectName=VamPa
groupId=com.vam

View File

@@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.vam.model.AuthorVO;
import com.vam.model.BookVO;
@@ -81,6 +82,25 @@ public class AdminController {
}
/* 상품 조회 페이지 */
@GetMapping("/goodsDetail")
public void goodsGetInfoGET(int bookId, Criteria cri, Model model) throws JsonProcessingException {
logger.info("goodsGetInfo()........." + bookId);
ObjectMapper mapper = new ObjectMapper();
/* 카테고리 리스트 데이터 */
model.addAttribute("cateList", mapper.writeValueAsString(adminService.cateList()));
/* 목록 페이지 조건 정보 */
model.addAttribute("cri", cri);
/* 조회 페이지 정보 */
model.addAttribute("goodsInfo", adminService.goodsGetDetail(bookId));
}
/* 작가 등록 페이지 접속 */
@RequestMapping(value = "authorEnroll", method = RequestMethod.GET)
public void authorEnrollGET() throws Exception{

View File

@@ -21,4 +21,7 @@ public interface AdminMapper {
/* 상품 총 개수 */
public int goodsGetTotal(Criteria cri);
/* 상품 조회 페이지 */
public BookVO goodsGetDetail(int bookId);
}

View File

@@ -20,4 +20,7 @@ public interface AdminService {
/* 상품 총 개수 */
public int goodsGetTotal(Criteria cri);
/* 상품 조회 페이지 */
public BookVO goodsGetDetail(int bookId);
}

View File

@@ -51,4 +51,13 @@ public class AdminServiceImpl implements AdminService {
return adminMapper.goodsGetTotal(cri);
}
/* 상품 조회 페이지 */
@Override
public BookVO goodsGetDetail(int bookId) {
log.info("(service)bookGetDetail......." + bookId);
return adminMapper.goodsGetDetail(bookId);
}
}

View File

@@ -47,6 +47,13 @@
</select>
<!-- 상품 조회 페이지 -->
<select id="goodsGetDetail" resultType="com.vam.model.BookVO">
select bookId, bookName, (select authorName from vam_author where authorId =vam_book.authorId) authorName,
authorId, publeYear, publisher, cateCode, bookStock, bookDiscount, bookIntro, bookContents, regDate, updateDate
from vam_book where bookId = #{bookId}
</select>
</mapper>

View File

@@ -0,0 +1,289 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="../resources/css/admin/goodsDetail.css">
<script
src="https://code.jquery.com/jquery-3.4.1.js"
integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU="
crossorigin="anonymous"></script>
<script src="https://cdn.ckeditor.com/ckeditor5/26.0.0/classic/ckeditor.js"></script>
</head>
<body>
<%@include file="../includes/admin/header.jsp" %>
<div class="admin_content_wrap">
<div class="admin_content_subject"><span>상품 상세</span></div>
<div class="admin_content_main">
<div class="form_section">
<div class="form_section_title">
<label>책 제목</label>
</div>
<div class="form_section_content">
<input name="bookName" value="<c:out value="${goodsInfo.bookName}"/>" disabled>
</div>
</div>
<div class="form_section">
<div class="form_section_title">
<label>등록 날짜</label>
</div>
<div class="form_section_content">
<input value="<fmt:formatDate value='${goodsInfo.regDate}' pattern='yyyy-MM-dd'/>" disabled>
</div>
</div>
<div class="form_section">
<div class="form_section_title">
<label>최근 수정 날짜</label>
</div>
<div class="form_section_content">
<input value="<fmt:formatDate value='${goodsInfo.updateDate}' pattern='yyyy-MM-dd'/>" disabled>
</div>
</div>
<div class="form_section">
<div class="form_section_title">
<label>작가</label>
</div>
<div class="form_section_content">
<input id="authorName_input" readonly="readonly" value="${goodsInfo.authorName }" disabled>
</div>
</div>
<div class="form_section">
<div class="form_section_title">
<label>출판일</label>
</div>
<div class="form_section_content">
<input name="publeYear" autocomplete="off" readonly="readonly" value="<c:out value="${goodsInfo.publeYear}"/>" disabled>
</div>
</div>
<div class="form_section">
<div class="form_section_title">
<label>출판사</label>
</div>
<div class="form_section_content">
<input name="publisher" value="<c:out value="${goodsInfo.publisher}"/>" disabled>
</div>
</div>
<div class="form_section">
<div class="form_section_title">
<label>책 카테고리</label>
</div>
<div class="form_section_content">
<div class="cate_wrap">
<span>대분류</span>
<select class="cate1" disabled>
<option value="none">선택</option>
</select>
</div>
<div class="cate_wrap">
<span>중분류</span>
<select class="cate2" disabled>
<option value="none">선택</option>
</select>
</div>
<div class="cate_wrap">
<span>소분류</span>
<select class="cate3" name="cateCode" disabled>
<option value="none">선택</option>
</select>
</div>
</div>
</div>
<div class="form_section">
<div class="form_section_title">
<label>상품 가격</label>
</div>
<div class="form_section_content">
<input name="bookPrice" value="<c:out value="${goodsInfo.bookPrice}"/>" disabled>
</div>
</div>
<div class="form_section">
<div class="form_section_title">
<label>상품 재고</label>
</div>
<div class="form_section_content">
<input name="bookStock" value="<c:out value="${goodsInfo.bookStock}"/>" disabled>
</div>
</div>
<div class="form_section">
<div class="form_section_title">
<label>상품 할인율</label>
</div>
<div class="form_section_content">
<input id="discount_interface" maxlength="2" disabled>
</div>
</div>
<div class="form_section">
<div class="form_section_title">
<label>책 소개</label>
</div>
<div class="form_section_content bit">
<textarea name="bookIntro" id="bookIntro_textarea" disabled>${goodsInfo.bookIntro}</textarea>
</div>
</div>
<div class="form_section">
<div class="form_section_title">
<label>책 목차</label>
</div>
<div class="form_section_content bct">
<textarea name="bookContents" id="bookContents_textarea" disabled>${goodsInfo.bookContents}</textarea>
</div>
</div>
<div class="btn_section">
<button id="cancelBtn" class="btn">상품 목록</button>
<button id="enrollBtn" class="btn enroll_btn">수정 </button>
</div>
</div>
<form id="moveForm" action="/admin/goodsManage" method="get" >
<input type="hidden" name="pageNum" value="${pageMaker.cri.pageNum}">
<input type="hidden" name="amount" value="${pageMaker.cri.amount}">
<input type="hidden" name="keyword" value="${pageMaker.cri.keyword}">
</form>
</div>
<%@include file="../includes/admin/footer.jsp" %>
<script>
$(document).ready(function(){
/* 할인율 값 삽입 */
let bookDiscount = '<c:out value="${goodsInfo.bookDiscount}"/>' * 100;
$("#discount_interface").attr("value", bookDiscount);
/* 출판일 값 가공 */
let publeYear = '${goodsInfo.publeYear}';
let length = publeYear.indexOf(" ");
publeYear = publeYear.substring(0, length);
$("input[name='publeYear']").attr("value", publeYear);
/* 책 소개 */
ClassicEditor
.create(document.querySelector('#bookIntro_textarea'))
.then(editor => {
console.log(editor);
editor.isReadOnly = true;
})
.catch(error=>{
console.error(error);
});
/* 책 목차 */
ClassicEditor
.create(document.querySelector('#bookContents_textarea'))
.then(editor => {
console.log(editor);
editor.isReadOnly = true;
})
.catch(error=>{
console.error(error);
});
/* 카테고리 */
let cateList = JSON.parse('${cateList}');
let cate1Array = new Array();
let cate2Array = new Array();
let cate3Array = new Array();
let cate1Obj = new Object();
let cate2Obj = new Object();
let cate3Obj = new Object();
let cateSelect1 = $(".cate1");
let cateSelect2 = $(".cate2");
let cateSelect3 = $(".cate3");
/* 카테고리 배열 초기화 메서드 */
function makeCateArray(obj,array,cateList, tier){
for(let i = 0; i < cateList.length; i++){
if(cateList[i].tier === tier){
obj = new Object();
obj.cateName = cateList[i].cateName;
obj.cateCode = cateList[i].cateCode;
obj.cateParent = cateList[i].cateParent;
array.push(obj);
}
}
}
/* 배열 초기화 */
makeCateArray(cate1Obj,cate1Array,cateList,1);
makeCateArray(cate2Obj,cate2Array,cateList,2);
makeCateArray(cate3Obj,cate3Array,cateList,3);
let targetCate2 = '';
let targetCate3 = '${goodsInfo.cateCode}';
for(let i = 0; i < cate3Array.length; i++){
if(targetCate3 === cate3Array[i].cateCode){
targetCate3 = cate3Array[i];
}
}// for
for(let i = 0; i < cate3Array.length; i++){
if(targetCate3.cateParent === cate3Array[i].cateParent){
cateSelect3.append("<option value='"+cate3Array[i].cateCode+"'>" + cate3Array[i].cateName + "</option>");
}
}
$(".cate3 option").each(function(i,obj){
if(targetCate3.cateCode === obj.value){
$(obj).attr("selected", "selected");
}
});
for(let i = 0; i < cate2Array.length; i++){
if(targetCate3.cateParent === cate2Array[i].cateCode){
targetCate2 = cate2Array[i];
}
}// for
for(let i = 0; i < cate2Array.length; i++){
if(targetCate2.cateParent === cate2Array[i].cateParent){
cateSelect2.append("<option value='"+cate2Array[i].cateCode+"'>" + cate2Array[i].cateName + "</option>");
}
}
$(".cate2 option").each(function(i,obj){
if(targetCate2.cateCode === obj.value){
$(obj).attr("selected", "selected");
}
});
for(let i = 0; i < cate1Array.length; i++){
cateSelect1.append("<option value='"+cate1Array[i].cateCode+"'>" + cate1Array[i].cateName + "</option>");
}
$(".cate1 option").each(function(i,obj){
if(targetCate2.cateParent === obj.value){
$(obj).attr("selected", "selected");
}
});
}); // $(document).ready
</script>
</body>
</html>

View File

@@ -38,7 +38,11 @@
<c:forEach items="${list}" var="list">
<tr>
<td><c:out value="${list.bookId}"></c:out></td>
<td><c:out value="${list.bookName}"></c:out></td>
<td>
<a class="move" href='<c:out value="${list.bookId}"/>'>
<c:out value="${list.bookName}"></c:out>
</a>
</td>
<td><c:out value="${list.authorName}"></c:out></td>
<td><c:out value="${list.cateName}"></c:out></td>
<td><c:out value="${list.bookStock}"></c:out></td>
@@ -155,6 +159,17 @@ $(".pageMaker_btn a").on("click", function(e){
});
/* 상품 조회 페이지 */
$(".move").on("click", function(e){
e.preventDefault();
moveForm.append("<input type='hidden' name='bookId' value='"+$(this).attr("href") + "'>");
moveForm.attr("action", "/admin/goodsDetail");
moveForm.submit();
});
</script>

View File

@@ -0,0 +1,268 @@
@charset "UTF-8";
*{
margin: 0;
padding:0;
}
a{
text-decoration: none;
}
ul{
list-style: none;
}
/* 화면 전체 렙 */
.wrapper{
width: 100%;
}
/* content 랩 */
.wrap{
width : 1080px;
margin: auto;
}
/* 홈페이지 기능 네비 */
.top_gnb_area{
width: 100%;
height: 50px;
background-color: #f0f0f1;
position:relative;
}
.top_gnb_area .list{
position: absolute;
top: 0px;
right: 0;
}
.top_gnb_area .list li{
list-style: none;
float : left;
padding: 13px 15px 0 10px;
font-weight: 900;
cursor: pointer;
}
/* 관리제 페이지 상단 현페이지 정보 */
.admin_top_wrap{
height:110px;
line-height: 110px;
background-color: #5080bd;
margin-bottom: 15px;
}
.admin_top_wrap>span{
margin-left: 30px;
display:inline-block;
color: white;
font-size: 50px;
font-weight: bolder;
}
/* 관리자 wrap(네비+컨텐츠) */
.admin_wrap{
}
/* 관리자페이지 네비 영역 */
.admin_navi_wrap{
width: 20%;
height: 300px;
float:left;
height: 100%;
}
.admin_navi_wrap li{
display: block;
height: 80px;
line-height: 80px;
text-align: center;
}
.admin_navi_wrap li a{
display: block;
height: 100%;
width: 95%;
margin: 0 auto;
cursor: pointer;
font-size: 30px;
font-weight: bolder;
}
.admin_navi_wrap li a:link {color: black;}
.admin_navi_wrap li a:visited {color: black;}
.admin_navi_wrap li a:active {color: black;}
.admin_navi_wrap li a:hover {color: black;}
.admin_list_02{
background-color: #c8c8c8;
}
/* 관리자페이지 컨텐츠 영역 */
.admin_content_wrap{
width: 80%;
float:left;
min-height: 700px;
}
.admin_content_subject{ /* 관리자 컨텐츠 제목 영역 */
font-size: 40px;
font-weight: bolder;
padding-left: 15px;
background-color: #6AAFE6;
height: 80px;
line-height: 80px;
color: white;
}
/* 관리자 컨텐츠 메인 영역 */
.form_section{
width: 95%;
margin-left: 2%;
margin-top: 20px;
border: 1px solid #dbdde2;
background-color: #efefef;
}
.form_section_title{
padding: 20px 35px;
}
.form_section_title label{
display: block;
font-size: 20px;
font-weight: 800;
}
.form_section_content{
padding: 20px 35px;
border-top: 1px solid #dbdde2;
}
.form_section_content input{
width: 98%;
height: 25px;
font-size: 20px;
padding: 5px 1%;
}
.ui-datepicker-trigger { /* 캘린더 css 설정 */
margin-left: 25px;
width: 14%;
height: 38px;
font-weight: 600;
background-color: #dfe8f5;
font-size: 15px;
cursor:pointer;
}
.authorId_btn { /* 작가 선택 css 설정 */
margin-left: 20px;
width: 14%;
height: 38px;
font-weight: 600;
background-color: #dfe8f5;
font-size: 15px;
cursor:pointer;
}
.ck-content { /* ckeditor 높이 */
height: 170px;
}
/* 버튼 영역 */
.btn_section{
text-align: center;
margin: 80px 0;
}
.btn{
min-width: 180px;
padding: 4px 30px;
font-size: 25px;
font-weight: 600;
line-height: 40px;
}
.enroll_btn{
background-color: #dbdde2;
margin-left:15px;
}
#enrollBtn:hover {
background-color: #c9cbd0;
}
.form_section_content select { /* 카테고리 css 설정 */
width: 92%;
height: 35px;
font-size: 20px;
text-align-last: center;
margin-left: 5px;
}
.cate_wrap span {
font-weight: 600;
}
.cate_wrap:not(:first-child) {
margin-top: 20px;
}
/* footer navai 영역 */
.footer_nav{
width:100%;
height:50px;
}
.footer_nav_container{
width: 100%;
height: 100%;
background-color:#8EC0E4;
}
.footer_nav_container>ul{
font-weight : bold;
float:left;
list-style:none;
position:relative;
padding-top:10px;
line-height: 27px;
font-family: dotum;
margin-left: 10px;
}
.footer_nav_container>ul>li{
display:inline;
width: 45px;
height: 19px;
padding: 10px 9px 0 10px;
}
.footer_nav_container>ul>span{
margin: 0 4px;
}
/* footer 영역 */
.footer{
width:100%;
height:130px;
background-color:#D4DFE6;
padding-bottom : 50px;
}
.footer_container{
width: 100%;
height: 100%;
margin: auto;
}
.footer_left>img {
width: 150%;
height: 130px;
margin-left: -20px;
margin-top: -12px;
}
.footer_left{
float :left;
width: 170px;
margin-left: 20px;
margin-top : 30px;
}
.footer_right{
float :left;
width: 680px;
margin-left: 70px;
margin-top : 30px;
}
/* float 속성 해제 */
.clearfix{
clear: both;
}

View File

@@ -8,6 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.vam.model.BookVO;
import com.vam.model.Criteria;
@RunWith(SpringJUnit4ClassRunner.class)
@@ -50,24 +51,39 @@ public class AdminMapperTests {
*/
/* 상품 리스트 & 상품 총 갯수 */
/* 상품 리스트 & 상품 총 개수*/
/*
@Test
public void goodsGetListTest() {
public void goodsGetListTests() {
Criteria cri = new Criteria();
/* 검색조건 */
//cri.setKeyword("테스트");
cri.setKeyword("test");
/* 검색 리스트 */
/*List list = mapper.goodsGetList(cri);
for(int i = 0; i < list.size(); i++) {
System.out.println("result......." + i + " : " + list.get(i));
}*/
// 상품 리스트
List list = mapper.goodsGetList(cri);
for(int i = 0; i < 10; i++) {
System.out.println("result..........." +i + " : " + list.get(i) );
}
/* 상품 총 갯수 */
int result = mapper.goodsGetTotal(cri);
System.out.println("resutl.........." + result);
/// 상품 총 개수
//int result = mapper.goodsGetTotal(cri);
//System.out.println("resout........." + result);
}
*/
/* 상품 조회 페이지 */
@Test
public void goodsGetDetailTest() {
int bookId = 150;
BookVO result = mapper.goodsGetDetail(bookId);
System.out.println("상품 조회 데이터 : " + result);
}

View File

@@ -47,6 +47,13 @@
</select>
<!-- 상품 조회 페이지 -->
<select id="goodsGetDetail" resultType="com.vam.model.BookVO">
select bookId, bookName, (select authorName from vam_author where authorId =vam_book.authorId) authorName,
authorId, publeYear, publisher, cateCode, bookStock, bookDiscount, bookIntro, bookContents, regDate, updateDate
from vam_book where bookId = #{bookId}
</select>
</mapper>

View File

@@ -1,5 +1,5 @@
#Generated by Maven Integration for Eclipse
#Tue Apr 13 14:07:29 KST 2021
#Mon Apr 19 22:02:05 KST 2021
m2e.projectLocation=C\:\\Users\\sjinj\\git\\Blog_Project\\VamPa_MySQL
m2e.projectName=VamPa_MySQL
groupId=com.vam