[Spring][쇼핑몰 프로젝트][18] 상품 등록 - 등록 기본 구현
https://kimvampa.tistory.com/192
This commit is contained in:
@@ -14,8 +14,10 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import com.vam.model.AuthorVO;
|
||||
import com.vam.model.BookVO;
|
||||
import com.vam.model.Criteria;
|
||||
import com.vam.model.PageDTO;
|
||||
import com.vam.service.AdminService;
|
||||
import com.vam.service.AuthorService;
|
||||
|
||||
@Controller
|
||||
@@ -27,6 +29,9 @@ public class AdminController {
|
||||
@Autowired
|
||||
private AuthorService authorService;
|
||||
|
||||
@Autowired
|
||||
private AdminService adminService;
|
||||
|
||||
/* 관리자 메인 페이지 이동 */
|
||||
@RequestMapping(value="main", method = RequestMethod.GET)
|
||||
public void adminMainGET() throws Exception{
|
||||
@@ -115,5 +120,18 @@ public class AdminController {
|
||||
|
||||
}
|
||||
|
||||
/* 상품 등록 */
|
||||
@PostMapping("/goodsEnroll")
|
||||
public String goodsEnrollPOST(BookVO book, RedirectAttributes rttr) {
|
||||
|
||||
logger.info("goodsEnrollPOST......" + book);
|
||||
|
||||
adminService.bookEnroll(book);
|
||||
|
||||
rttr.addFlashAttribute("enroll_result", book.getBookName());
|
||||
|
||||
return "redirect:/admin/goodsManage";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
10
VamPa/src/main/java/com/vam/mapper/AdminMapper.java
Normal file
10
VamPa/src/main/java/com/vam/mapper/AdminMapper.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.vam.mapper;
|
||||
|
||||
import com.vam.model.BookVO;
|
||||
|
||||
public interface AdminMapper {
|
||||
|
||||
/* 상품 등록 */
|
||||
public void bookEnroll(BookVO book);
|
||||
|
||||
}
|
||||
183
VamPa/src/main/java/com/vam/model/BookVO.java
Normal file
183
VamPa/src/main/java/com/vam/model/BookVO.java
Normal file
@@ -0,0 +1,183 @@
|
||||
package com.vam.model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class BookVO {
|
||||
|
||||
/* 상품 id */
|
||||
private int bookId;
|
||||
|
||||
/* 상품 이름 */
|
||||
private String bookName;
|
||||
|
||||
/* 작가 id */
|
||||
private int authorId;
|
||||
|
||||
/* 작가 이름 */
|
||||
private String authorName;
|
||||
|
||||
/* 출판일 */
|
||||
private String publeYear;
|
||||
|
||||
/* 출판사 */
|
||||
private String publisher;
|
||||
|
||||
/* 카테고리 코드 */
|
||||
private String cateCode;
|
||||
|
||||
/* 카테고리 이름 */
|
||||
private String cateName;
|
||||
|
||||
/* 상품 가격 */
|
||||
private int bookPrice;
|
||||
|
||||
/* 상품 재고 */
|
||||
private int bookStock;
|
||||
|
||||
/* 상품 할인률(백분율) */
|
||||
private double bookDiscount;
|
||||
|
||||
/* 상품 소개 */
|
||||
private String bookIntro;
|
||||
|
||||
/* 상품 목차 */
|
||||
private String bookContents;
|
||||
|
||||
/* 등록 날짜 */
|
||||
private Date regDate;
|
||||
|
||||
/* 수정 날짜 */
|
||||
private Date updateDate;
|
||||
|
||||
public int getBookId() {
|
||||
return bookId;
|
||||
}
|
||||
|
||||
public void setBookId(int bookId) {
|
||||
this.bookId = bookId;
|
||||
}
|
||||
|
||||
public String getBookName() {
|
||||
return bookName;
|
||||
}
|
||||
|
||||
public void setBookName(String bookName) {
|
||||
this.bookName = bookName;
|
||||
}
|
||||
|
||||
public int getAuthorId() {
|
||||
return authorId;
|
||||
}
|
||||
|
||||
public void setAuthorId(int authorId) {
|
||||
this.authorId = authorId;
|
||||
}
|
||||
|
||||
public String getAuthorName() {
|
||||
return authorName;
|
||||
}
|
||||
|
||||
public void setAuthorName(String authorName) {
|
||||
this.authorName = authorName;
|
||||
}
|
||||
|
||||
public String getPubleYear() {
|
||||
return publeYear;
|
||||
}
|
||||
|
||||
public void setPubleYear(String publeYear) {
|
||||
this.publeYear = publeYear;
|
||||
}
|
||||
|
||||
public String getPublisher() {
|
||||
return publisher;
|
||||
}
|
||||
|
||||
public void setPublisher(String publisher) {
|
||||
this.publisher = publisher;
|
||||
}
|
||||
|
||||
public String getCateCode() {
|
||||
return cateCode;
|
||||
}
|
||||
|
||||
public void setCateCode(String cateCode) {
|
||||
this.cateCode = cateCode;
|
||||
}
|
||||
|
||||
public String getCateName() {
|
||||
return cateName;
|
||||
}
|
||||
|
||||
public void setCateName(String cateName) {
|
||||
this.cateName = cateName;
|
||||
}
|
||||
|
||||
public int getBookPrice() {
|
||||
return bookPrice;
|
||||
}
|
||||
|
||||
public void setBookPrice(int bookPrice) {
|
||||
this.bookPrice = bookPrice;
|
||||
}
|
||||
|
||||
public int getBookStock() {
|
||||
return bookStock;
|
||||
}
|
||||
|
||||
public void setBookStock(int bookStock) {
|
||||
this.bookStock = bookStock;
|
||||
}
|
||||
|
||||
public double getBookDiscount() {
|
||||
return bookDiscount;
|
||||
}
|
||||
|
||||
public void setBookDiscount(double bookDiscount) {
|
||||
this.bookDiscount = bookDiscount;
|
||||
}
|
||||
|
||||
public String getBookIntro() {
|
||||
return bookIntro;
|
||||
}
|
||||
|
||||
public void setBookIntro(String bookIntro) {
|
||||
this.bookIntro = bookIntro;
|
||||
}
|
||||
|
||||
public String getBookContents() {
|
||||
return bookContents;
|
||||
}
|
||||
|
||||
public void setBookContents(String bookContents) {
|
||||
this.bookContents = bookContents;
|
||||
}
|
||||
|
||||
public Date getRegDate() {
|
||||
return regDate;
|
||||
}
|
||||
|
||||
public void setRegDate(Date regDate) {
|
||||
this.regDate = regDate;
|
||||
}
|
||||
|
||||
public Date getUpdateDate() {
|
||||
return updateDate;
|
||||
}
|
||||
|
||||
public void setUpdateDate(Date updateDate) {
|
||||
this.updateDate = updateDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BookVO [bookId=" + bookId + ", bookName=" + bookName + ", authorId=" + authorId + ", authorName="
|
||||
+ authorName + ", publeYear=" + publeYear + ", publisher=" + publisher + ", cateCode=" + cateCode
|
||||
+ ", cateName=" + cateName + ", bookPrice=" + bookPrice + ", bookStock=" + bookStock + ", bookDiscount="
|
||||
+ bookDiscount + ", bookIntro=" + bookIntro + ", bookContents=" + bookContents + ", regDate=" + regDate
|
||||
+ ", updateDate=" + updateDate + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
10
VamPa/src/main/java/com/vam/service/AdminService.java
Normal file
10
VamPa/src/main/java/com/vam/service/AdminService.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.vam.service;
|
||||
|
||||
import com.vam.model.BookVO;
|
||||
|
||||
public interface AdminService {
|
||||
|
||||
/* 상품 등록 */
|
||||
public void bookEnroll(BookVO book);
|
||||
|
||||
}
|
||||
29
VamPa/src/main/java/com/vam/service/AdminServiceImpl.java
Normal file
29
VamPa/src/main/java/com/vam/service/AdminServiceImpl.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package com.vam.service;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.vam.mapper.AdminMapper;
|
||||
import com.vam.model.BookVO;
|
||||
|
||||
import lombok.extern.log4j.Log4j;
|
||||
|
||||
@Service
|
||||
@Log4j
|
||||
public class AdminServiceImpl implements AdminService {
|
||||
|
||||
@Autowired
|
||||
private AdminMapper adminMapper;
|
||||
|
||||
/* 상품 등록 */
|
||||
@Override
|
||||
public void bookEnroll(BookVO book) {
|
||||
|
||||
log.info("(srevice)bookEnroll........");
|
||||
|
||||
adminMapper.bookEnroll(book);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
15
VamPa/src/main/resources/com/vam/mapper/AdminMapper.xml
Normal file
15
VamPa/src/main/resources/com/vam/mapper/AdminMapper.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.vam.mapper.AdminMapper">
|
||||
|
||||
<!-- 작가 등록 -->
|
||||
<insert id="bookEnroll">
|
||||
|
||||
insert into vam_book(bookName, authorId, publeYear, publisher, cateCode, bookPrice, bookStock, bookDiscount, bookIntro, bookContents)
|
||||
values(#{bookName},#{authorId}, #{publeYear},#{publisher},#{cateCode},#{bookPrice},#{bookStock},#{bookDiscount},#{bookIntro},#{bookContents})
|
||||
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
@@ -19,9 +19,119 @@
|
||||
|
||||
<div class="admin_content_wrap">
|
||||
<div class="admin_content_subject"><span>상품 등록</span></div>
|
||||
<div class="admin_content_main">
|
||||
<form action="/admin/goodsEnroll" method="post" id="enrollForm">
|
||||
<div class="form_section">
|
||||
<div class="form_section_title">
|
||||
<label>책 제목</label>
|
||||
</div>
|
||||
<div class="form_section_content">
|
||||
<input name="bookName">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form_section">
|
||||
<div class="form_section_title">
|
||||
<label>작가</label>
|
||||
</div>
|
||||
<div class="form_section_content">
|
||||
<input name="authorId" value="0">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form_section">
|
||||
<div class="form_section_title">
|
||||
<label>출판일</label>
|
||||
</div>
|
||||
<div class="form_section_content">
|
||||
<input name="publeYear">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form_section">
|
||||
<div class="form_section_title">
|
||||
<label>출판사</label>
|
||||
</div>
|
||||
<div class="form_section_content">
|
||||
<input name="publisher">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form_section">
|
||||
<div class="form_section_title">
|
||||
<label>책 카테고리</label>
|
||||
</div>
|
||||
<div class="form_section_content">
|
||||
<input name="cateCode">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form_section">
|
||||
<div class="form_section_title">
|
||||
<label>상품 가격</label>
|
||||
</div>
|
||||
<div class="form_section_content">
|
||||
<input name="bookPrice" value="0">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form_section">
|
||||
<div class="form_section_title">
|
||||
<label>상품 재고</label>
|
||||
</div>
|
||||
<div class="form_section_content">
|
||||
<input name="bookStock" value="0">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form_section">
|
||||
<div class="form_section_title">
|
||||
<label>상품 할인율</label>
|
||||
</div>
|
||||
<div class="form_section_content">
|
||||
<input name="bookDiscount" value="0">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form_section">
|
||||
<div class="form_section_title">
|
||||
<label>책 소개</label>
|
||||
</div>
|
||||
<div class="form_section_content">
|
||||
<input name="bookIntro">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form_section">
|
||||
<div class="form_section_title">
|
||||
<label>책 목차</label>
|
||||
</div>
|
||||
<div class="form_section_content">
|
||||
<input name="bookContents">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="btn_section">
|
||||
<button id="cancelBtn" class="btn">취 소</button>
|
||||
<button id="enrollBtn" class="btn enroll_btn">등 록</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%@include file="../includes/admin/footer.jsp" %>
|
||||
|
||||
<script>
|
||||
|
||||
let enrollForm = $("#enrollForm")
|
||||
|
||||
/* 취소 버튼 */
|
||||
$("#cancelBtn").click(function(){
|
||||
|
||||
location.href="/admin/goodsManage"
|
||||
|
||||
});
|
||||
|
||||
/* 상품 등록 버튼 */
|
||||
$("#enrollBtn").on("click",function(e){
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
enrollForm.submit();
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,5 +1,7 @@
|
||||
<%@ 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>
|
||||
@@ -22,6 +24,25 @@
|
||||
</div>
|
||||
|
||||
<%@include file="../includes/admin/footer.jsp" %>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
|
||||
let eResult = '<c:out value="${enroll_result}"/>';
|
||||
|
||||
checkResult(eResult);
|
||||
|
||||
function checkResult(result){
|
||||
|
||||
if(result === ''){
|
||||
return;
|
||||
}
|
||||
|
||||
alert("상품'"+ eResult +"'을 등록하였습니다.");
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -106,6 +106,60 @@ ul{
|
||||
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%;
|
||||
}
|
||||
.form_section_content select{
|
||||
width: 98%;
|
||||
height: 35px;
|
||||
font-size: 20px;
|
||||
text-align-last: center;
|
||||
}
|
||||
|
||||
|
||||
/* 버튼 영역 */
|
||||
.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;
|
||||
}
|
||||
|
||||
|
||||
/* footer navai 영역 */
|
||||
.footer_nav{
|
||||
|
||||
40
VamPa/src/test/java/com/vam/mapper/AdminMapperTests.java
Normal file
40
VamPa/src/test/java/com/vam/mapper/AdminMapperTests.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package com.vam.mapper;
|
||||
|
||||
|
||||
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.BookVO;
|
||||
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("file:src/main/webapp/WEB-INF/spring/root-context.xml")
|
||||
public class AdminMapperTests {
|
||||
|
||||
@Autowired
|
||||
private AdminMapper mapper;
|
||||
|
||||
/* 상품 등록 */
|
||||
@Test
|
||||
public void bookEnrollTest() throws Exception{
|
||||
|
||||
BookVO book = new BookVO();
|
||||
|
||||
book.setBookName("mapper 테스트");
|
||||
book.setAuthorId(123);
|
||||
book.setPubleYear("2021-03-18");
|
||||
book.setPublisher("출판사");
|
||||
book.setCateCode("0231");
|
||||
book.setBookPrice(20000);
|
||||
book.setBookStock(300);
|
||||
book.setBookDiscount(0.23);
|
||||
book.setBookIntro("책 소개 ");
|
||||
book.setBookContents("책 목차 ");
|
||||
|
||||
mapper.bookEnroll(book);
|
||||
}
|
||||
|
||||
}
|
||||
15
VamPa/target/classes/com/vam/mapper/AdminMapper.xml
Normal file
15
VamPa/target/classes/com/vam/mapper/AdminMapper.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.vam.mapper.AdminMapper">
|
||||
|
||||
<!-- 작가 등록 -->
|
||||
<insert id="bookEnroll">
|
||||
|
||||
insert into vam_book(bookName, authorId, publeYear, publisher, cateCode, bookPrice, bookStock, bookDiscount, bookIntro, bookContents)
|
||||
values(#{bookName},#{authorId}, #{publeYear},#{publisher},#{cateCode},#{bookPrice},#{bookStock},#{bookDiscount},#{bookIntro},#{bookContents})
|
||||
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
@@ -1,5 +1,5 @@
|
||||
#Generated by Maven Integration for Eclipse
|
||||
#Tue Mar 16 03:54:17 KST 2021
|
||||
#Mon Mar 22 16:56:34 KST 2021
|
||||
m2e.projectLocation=C\:\\Users\\sjinj\\git\\Blog_Project\\VamPa
|
||||
m2e.projectName=VamPa
|
||||
groupId=com.vam
|
||||
|
||||
@@ -14,8 +14,10 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import com.vam.model.AuthorVO;
|
||||
import com.vam.model.BookVO;
|
||||
import com.vam.model.Criteria;
|
||||
import com.vam.model.PageDTO;
|
||||
import com.vam.service.AdminService;
|
||||
import com.vam.service.AuthorService;
|
||||
|
||||
@Controller
|
||||
@@ -27,6 +29,9 @@ public class AdminController {
|
||||
@Autowired
|
||||
private AuthorService authorService;
|
||||
|
||||
@Autowired
|
||||
private AdminService adminService;
|
||||
|
||||
/* 관리자 메인 페이지 이동 */
|
||||
@RequestMapping(value="main", method = RequestMethod.GET)
|
||||
public void adminMainGET() throws Exception{
|
||||
@@ -114,6 +119,19 @@ public class AdminController {
|
||||
return "redirect:/admin/authorManage";
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* 상품 등록 */
|
||||
@PostMapping("/goodsEnroll")
|
||||
public String goodsEnrollPOST(BookVO book, RedirectAttributes rttr) {
|
||||
|
||||
logger.info("goodsEnrollPOST......" + book);
|
||||
|
||||
adminService.bookEnroll(book);
|
||||
|
||||
rttr.addFlashAttribute("enroll_result", book.getBookName());
|
||||
|
||||
return "redirect:/admin/goodsManage";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
10
VamPa_MySQL/src/main/java/com/vam/mapper/AdminMapper.java
Normal file
10
VamPa_MySQL/src/main/java/com/vam/mapper/AdminMapper.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.vam.mapper;
|
||||
|
||||
import com.vam.model.BookVO;
|
||||
|
||||
public interface AdminMapper {
|
||||
|
||||
/* 상품 등록 */
|
||||
public void bookEnroll(BookVO book);
|
||||
|
||||
}
|
||||
180
VamPa_MySQL/src/main/java/com/vam/model/BookVO.java
Normal file
180
VamPa_MySQL/src/main/java/com/vam/model/BookVO.java
Normal file
@@ -0,0 +1,180 @@
|
||||
package com.vam.model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class BookVO {
|
||||
|
||||
/* 상품 id */
|
||||
private int bookId;
|
||||
|
||||
/* 상품 이름 */
|
||||
private String bookName;
|
||||
|
||||
/* 작가 id */
|
||||
private int authorId;
|
||||
|
||||
/* 작가 이름 */
|
||||
private String authorName;
|
||||
|
||||
/* 출판일 */
|
||||
private String publeYear;
|
||||
|
||||
/* 출판사 */
|
||||
private String publisher;
|
||||
|
||||
/* 카테고리 코드 */
|
||||
private String cateCode;
|
||||
|
||||
/* 카테고리 이름 */
|
||||
private String cateName;
|
||||
|
||||
/* 상품 가격 */
|
||||
private int bookPrice;
|
||||
|
||||
/* 상품 재고 */
|
||||
private int bookStock;
|
||||
|
||||
/* 상품 할인률(백분율) */
|
||||
private double bookDiscount;
|
||||
|
||||
/* 상품 소개 */
|
||||
private String bookIntro;
|
||||
|
||||
/* 상품 목차 */
|
||||
private String bookContents;
|
||||
|
||||
/* 등록 날짜 */
|
||||
private Date regDate;
|
||||
|
||||
/* 수정 날짜 */
|
||||
private Date updateDate;
|
||||
|
||||
public int getBookId() {
|
||||
return bookId;
|
||||
}
|
||||
|
||||
public void setBookId(int bookId) {
|
||||
this.bookId = bookId;
|
||||
}
|
||||
|
||||
public String getBookName() {
|
||||
return bookName;
|
||||
}
|
||||
|
||||
public void setBookName(String bookName) {
|
||||
this.bookName = bookName;
|
||||
}
|
||||
|
||||
public int getAuthorId() {
|
||||
return authorId;
|
||||
}
|
||||
|
||||
public void setAuthorId(int authorId) {
|
||||
this.authorId = authorId;
|
||||
}
|
||||
|
||||
public String getAuthorName() {
|
||||
return authorName;
|
||||
}
|
||||
|
||||
public void setAuthorName(String authorName) {
|
||||
this.authorName = authorName;
|
||||
}
|
||||
|
||||
public String getPubleYear() {
|
||||
return publeYear;
|
||||
}
|
||||
|
||||
public void setPubleYear(String publeYear) {
|
||||
this.publeYear = publeYear;
|
||||
}
|
||||
|
||||
public String getPublisher() {
|
||||
return publisher;
|
||||
}
|
||||
|
||||
public void setPublisher(String publisher) {
|
||||
this.publisher = publisher;
|
||||
}
|
||||
|
||||
public String getCateCode() {
|
||||
return cateCode;
|
||||
}
|
||||
|
||||
public void setCateCode(String cateCode) {
|
||||
this.cateCode = cateCode;
|
||||
}
|
||||
|
||||
public String getCateName() {
|
||||
return cateName;
|
||||
}
|
||||
|
||||
public void setCateName(String cateName) {
|
||||
this.cateName = cateName;
|
||||
}
|
||||
|
||||
public int getBookPrice() {
|
||||
return bookPrice;
|
||||
}
|
||||
|
||||
public void setBookPrice(int bookPrice) {
|
||||
this.bookPrice = bookPrice;
|
||||
}
|
||||
|
||||
public int getBookStock() {
|
||||
return bookStock;
|
||||
}
|
||||
|
||||
public void setBookStock(int bookStock) {
|
||||
this.bookStock = bookStock;
|
||||
}
|
||||
|
||||
public double getBookDiscount() {
|
||||
return bookDiscount;
|
||||
}
|
||||
|
||||
public void setBookDiscount(double bookDiscount) {
|
||||
this.bookDiscount = bookDiscount;
|
||||
}
|
||||
|
||||
public String getBookIntro() {
|
||||
return bookIntro;
|
||||
}
|
||||
|
||||
public void setBookIntro(String bookIntro) {
|
||||
this.bookIntro = bookIntro;
|
||||
}
|
||||
|
||||
public String getBookContents() {
|
||||
return bookContents;
|
||||
}
|
||||
|
||||
public void setBookContents(String bookContents) {
|
||||
this.bookContents = bookContents;
|
||||
}
|
||||
|
||||
public Date getRegDate() {
|
||||
return regDate;
|
||||
}
|
||||
|
||||
public void setRegDate(Date regDate) {
|
||||
this.regDate = regDate;
|
||||
}
|
||||
|
||||
public Date getUpdateDate() {
|
||||
return updateDate;
|
||||
}
|
||||
|
||||
public void setUpdateDate(Date updateDate) {
|
||||
this.updateDate = updateDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BookVO [bookId=" + bookId + ", bookName=" + bookName + ", authorId=" + authorId + ", authorName="
|
||||
+ authorName + ", publeYear=" + publeYear + ", publisher=" + publisher + ", cateCode=" + cateCode
|
||||
+ ", cateName=" + cateName + ", bookPrice=" + bookPrice + ", bookStock=" + bookStock + ", bookDiscount="
|
||||
+ bookDiscount + ", bookIntro=" + bookIntro + ", bookContents=" + bookContents + ", regDate=" + regDate
|
||||
+ ", updateDate=" + updateDate + "]";
|
||||
}
|
||||
}
|
||||
10
VamPa_MySQL/src/main/java/com/vam/service/AdminService.java
Normal file
10
VamPa_MySQL/src/main/java/com/vam/service/AdminService.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.vam.service;
|
||||
|
||||
import com.vam.model.BookVO;
|
||||
|
||||
public interface AdminService {
|
||||
|
||||
/* 상품 등록 */
|
||||
public void bookEnroll(BookVO book);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.vam.service;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.vam.mapper.AdminMapper;
|
||||
import com.vam.model.BookVO;
|
||||
|
||||
import lombok.extern.log4j.Log4j;
|
||||
|
||||
@Service
|
||||
@Log4j
|
||||
public class AdminServiceImpl implements AdminService {
|
||||
|
||||
@Autowired
|
||||
private AdminMapper adminMapper;
|
||||
|
||||
/* 상품 등록 */
|
||||
@Override
|
||||
public void bookEnroll(BookVO book) {
|
||||
|
||||
log.info("(srevice)bookEnroll........");
|
||||
|
||||
adminMapper.bookEnroll(book);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.vam.mapper.AdminMapper">
|
||||
|
||||
<!-- 작가 등록 -->
|
||||
<insert id="bookEnroll">
|
||||
|
||||
insert into vam_book(bookName, authorId, publeYear, publisher, cateCode, bookPrice, bookStock, bookDiscount, bookIntro, bookContents)
|
||||
values(#{bookName},#{authorId}, #{publeYear},#{publisher},#{cateCode},#{bookPrice},#{bookStock},#{bookDiscount},#{bookIntro},#{bookContents})
|
||||
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
@@ -19,9 +19,119 @@
|
||||
|
||||
<div class="admin_content_wrap">
|
||||
<div class="admin_content_subject"><span>상품 등록</span></div>
|
||||
<div class="admin_content_main">
|
||||
<form action="/admin/goodsEnroll" method="post" id="enrollForm">
|
||||
<div class="form_section">
|
||||
<div class="form_section_title">
|
||||
<label>책 제목</label>
|
||||
</div>
|
||||
<div class="form_section_content">
|
||||
<input name="bookName">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form_section">
|
||||
<div class="form_section_title">
|
||||
<label>작가</label>
|
||||
</div>
|
||||
<div class="form_section_content">
|
||||
<input name="authorId" value="0">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form_section">
|
||||
<div class="form_section_title">
|
||||
<label>출판일</label>
|
||||
</div>
|
||||
<div class="form_section_content">
|
||||
<input name="publeYear">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form_section">
|
||||
<div class="form_section_title">
|
||||
<label>출판사</label>
|
||||
</div>
|
||||
<div class="form_section_content">
|
||||
<input name="publisher">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form_section">
|
||||
<div class="form_section_title">
|
||||
<label>책 카테고리</label>
|
||||
</div>
|
||||
<div class="form_section_content">
|
||||
<input name="cateCode">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form_section">
|
||||
<div class="form_section_title">
|
||||
<label>상품 가격</label>
|
||||
</div>
|
||||
<div class="form_section_content">
|
||||
<input name="bookPrice" value="0">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form_section">
|
||||
<div class="form_section_title">
|
||||
<label>상품 재고</label>
|
||||
</div>
|
||||
<div class="form_section_content">
|
||||
<input name="bookStock" value="0">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form_section">
|
||||
<div class="form_section_title">
|
||||
<label>상품 할인율</label>
|
||||
</div>
|
||||
<div class="form_section_content">
|
||||
<input name="bookDiscount" value="0">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form_section">
|
||||
<div class="form_section_title">
|
||||
<label>책 소개</label>
|
||||
</div>
|
||||
<div class="form_section_content">
|
||||
<input name="bookIntro">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form_section">
|
||||
<div class="form_section_title">
|
||||
<label>책 목차</label>
|
||||
</div>
|
||||
<div class="form_section_content">
|
||||
<input name="bookContents">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="btn_section">
|
||||
<button id="cancelBtn" class="btn">취 소</button>
|
||||
<button id="enrollBtn" class="btn enroll_btn">등 록</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%@include file="../includes/admin/footer.jsp" %>
|
||||
|
||||
<script>
|
||||
|
||||
let enrollForm = $("#enrollForm")
|
||||
|
||||
/* 취소 버튼 */
|
||||
$("#cancelBtn").click(function(){
|
||||
|
||||
location.href="/admin/goodsManage"
|
||||
|
||||
});
|
||||
|
||||
/* 상품 등록 버튼 */
|
||||
$("#enrollBtn").on("click",function(e){
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
enrollForm.submit();
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,5 +1,7 @@
|
||||
<%@ 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>
|
||||
@@ -22,6 +24,25 @@
|
||||
</div>
|
||||
|
||||
<%@include file="../includes/admin/footer.jsp" %>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
|
||||
let eResult = '<c:out value="${enroll_result}"/>';
|
||||
|
||||
checkResult(eResult);
|
||||
|
||||
function checkResult(result){
|
||||
|
||||
if(result === ''){
|
||||
return;
|
||||
}
|
||||
|
||||
alert("상품'"+ eResult +"'을 등록하였습니다.");
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -106,6 +106,60 @@ ul{
|
||||
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%;
|
||||
}
|
||||
.form_section_content select{
|
||||
width: 98%;
|
||||
height: 35px;
|
||||
font-size: 20px;
|
||||
text-align-last: center;
|
||||
}
|
||||
|
||||
|
||||
/* 버튼 영역 */
|
||||
.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;
|
||||
}
|
||||
|
||||
|
||||
/* footer navai 영역 */
|
||||
.footer_nav{
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.vam.mapper;
|
||||
|
||||
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.BookVO;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("file:src/main/webapp/WEB-INF/spring/root-context.xml")
|
||||
public class AdminMapperTests {
|
||||
|
||||
@Autowired
|
||||
private AdminMapper mapper;
|
||||
|
||||
/* 상품 등록 */
|
||||
@Test
|
||||
public void bookEnrollTest() throws Exception{
|
||||
|
||||
BookVO book = new BookVO();
|
||||
|
||||
book.setBookName("mapper 테스트");
|
||||
book.setAuthorId(123);
|
||||
book.setPubleYear("2021-03-18");
|
||||
book.setPublisher("출판사");
|
||||
book.setCateCode("0231");
|
||||
book.setBookPrice(20000);
|
||||
book.setBookStock(300);
|
||||
book.setBookDiscount(0.23);
|
||||
book.setBookIntro("책 소개 ");
|
||||
book.setBookContents("책 목차 ");
|
||||
|
||||
mapper.bookEnroll(book);
|
||||
}
|
||||
|
||||
}
|
||||
15
VamPa_MySQL/target/classes/com/vam/mapper/AdminMapper.xml
Normal file
15
VamPa_MySQL/target/classes/com/vam/mapper/AdminMapper.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.vam.mapper.AdminMapper">
|
||||
|
||||
<!-- 작가 등록 -->
|
||||
<insert id="bookEnroll">
|
||||
|
||||
insert into vam_book(bookName, authorId, publeYear, publisher, cateCode, bookPrice, bookStock, bookDiscount, bookIntro, bookContents)
|
||||
values(#{bookName},#{authorId}, #{publeYear},#{publisher},#{cateCode},#{bookPrice},#{bookStock},#{bookDiscount},#{bookIntro},#{bookContents})
|
||||
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
@@ -1,5 +1,5 @@
|
||||
#Generated by Maven Integration for Eclipse
|
||||
#Tue Mar 16 03:54:19 KST 2021
|
||||
#Mon Mar 22 16:56:35 KST 2021
|
||||
m2e.projectLocation=C\:\\Users\\sjinj\\git\\Blog_Project\\VamPa_MySQL
|
||||
m2e.projectName=VamPa_MySQL
|
||||
groupId=com.vam
|
||||
|
||||
Reference in New Issue
Block a user