diff --git a/VamPa/src/main/java/com/vam/controller/AdminController.java b/VamPa/src/main/java/com/vam/controller/AdminController.java index 786269c..0cfb6cf 100644 --- a/VamPa/src/main/java/com/vam/controller/AdminController.java +++ b/VamPa/src/main/java/com/vam/controller/AdminController.java @@ -2,9 +2,14 @@ package com.vam.controller; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.vam.model.AuthorVO; +import com.vam.service.AuthorService; @Controller @RequestMapping("/admin") @@ -12,6 +17,9 @@ public class AdminController { private static final Logger logger = LoggerFactory.getLogger(AdminController.class); + @Autowired + private AuthorService authorService; + /* 관리자 메인 페이지 이동 */ @RequestMapping(value="main", method = RequestMethod.GET) public void adminMainGET() throws Exception{ @@ -44,6 +52,19 @@ public class AdminController { logger.info("작가 관리 페이지 접속"); } - + /* 작가 등록 */ + @RequestMapping(value="authorEnroll.do", method = RequestMethod.POST) + public String authorEnrollPOST(AuthorVO author, RedirectAttributes rttr) throws Exception{ + + logger.info("authorEnroll :" + author); + + authorService.authorEnroll(author); // 작가 등록 쿼리 수행 + + rttr.addFlashAttribute("enroll_result", author.getAuthorName()); // 등록 성공 메시지(작가이름) + + return "redirect:/admin/authorManage"; + + } + } diff --git a/VamPa/src/main/webapp/WEB-INF/views/admin/authorEnroll.jsp b/VamPa/src/main/webapp/WEB-INF/views/admin/authorEnroll.jsp index c75cb45..cd3bc0e 100644 --- a/VamPa/src/main/webapp/WEB-INF/views/admin/authorEnroll.jsp +++ b/VamPa/src/main/webapp/WEB-INF/views/admin/authorEnroll.jsp @@ -54,6 +54,42 @@
작가 등록
+
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ + +
+
@@ -99,5 +135,19 @@ + + \ No newline at end of file diff --git a/VamPa/src/main/webapp/WEB-INF/views/admin/authorManage.jsp b/VamPa/src/main/webapp/WEB-INF/views/admin/authorManage.jsp index bbd48fd..21f6896 100644 --- a/VamPa/src/main/webapp/WEB-INF/views/admin/authorManage.jsp +++ b/VamPa/src/main/webapp/WEB-INF/views/admin/authorManage.jsp @@ -1,5 +1,6 @@ <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> @@ -99,5 +100,25 @@ + + \ No newline at end of file diff --git a/VamPa/src/test/java/com/vam/service/AuthorServiceTests.java b/VamPa/src/test/java/com/vam/service/AuthorServiceTests.java new file mode 100644 index 0000000..a52d5d1 --- /dev/null +++ b/VamPa/src/test/java/com/vam/service/AuthorServiceTests.java @@ -0,0 +1,32 @@ +package com.vam.service; + +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.AuthorVO; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration("file:src/main/webapp/WEB-INF/spring/root-context.xml") +public class AuthorServiceTests { + + /*AuthoreService 의존성 주입*/ + @Autowired + private AuthorService service; + + @Test + public void authorEnrollTest() throws Exception { + + AuthorVO author = new AuthorVO(); + + author.setNationId("01"); + author.setAuthorName("테스트"); + author.setAuthorIntro("테스트 소개"); + + service.authorEnroll(author); + + } + +} diff --git a/VamPa_MySQL/src/main/java/com/vam/controller/AdminController.java b/VamPa_MySQL/src/main/java/com/vam/controller/AdminController.java index a6453ce..ac9bca7 100644 --- a/VamPa_MySQL/src/main/java/com/vam/controller/AdminController.java +++ b/VamPa_MySQL/src/main/java/com/vam/controller/AdminController.java @@ -2,9 +2,14 @@ package com.vam.controller; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.vam.model.AuthorVO; +import com.vam.service.AuthorService; @Controller @RequestMapping("/admin") @@ -12,6 +17,10 @@ public class AdminController { private static final Logger logger = LoggerFactory.getLogger(AdminController.class); + @Autowired + private AuthorService authorService; + + /* 관리자 메인 페이지 이동 */ @RequestMapping(value="main", method = RequestMethod.GET) public void adminMainGET() throws Exception{ @@ -43,5 +52,20 @@ public class AdminController { public void authorManageGET() throws Exception{ logger.info("작가 관리 페이지 접속"); } + + /* 작가 등록 */ + @RequestMapping(value="authorEnroll.do", method = RequestMethod.POST) + public String authorEnrollPOST(AuthorVO author, RedirectAttributes rttr) throws Exception{ + logger.info("authorEnroll :" + author); + + authorService.authorEnroll(author); // 작가 등록 쿼리 수행 + + rttr.addFlashAttribute("enroll_result", author.getAuthorName()); // 등록 성공 메시지(작가이름) + + return "redirect:/admin/authorManage"; + + } + + } diff --git a/VamPa_MySQL/src/main/webapp/WEB-INF/views/admin/authorEnroll.jsp b/VamPa_MySQL/src/main/webapp/WEB-INF/views/admin/authorEnroll.jsp index c75cb45..cd3bc0e 100644 --- a/VamPa_MySQL/src/main/webapp/WEB-INF/views/admin/authorEnroll.jsp +++ b/VamPa_MySQL/src/main/webapp/WEB-INF/views/admin/authorEnroll.jsp @@ -54,6 +54,42 @@
작가 등록
+
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ + +
+
@@ -99,5 +135,19 @@ + + \ No newline at end of file diff --git a/VamPa_MySQL/src/main/webapp/WEB-INF/views/admin/authorManage.jsp b/VamPa_MySQL/src/main/webapp/WEB-INF/views/admin/authorManage.jsp index bbd48fd..21f6896 100644 --- a/VamPa_MySQL/src/main/webapp/WEB-INF/views/admin/authorManage.jsp +++ b/VamPa_MySQL/src/main/webapp/WEB-INF/views/admin/authorManage.jsp @@ -1,5 +1,6 @@ <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> @@ -99,5 +100,25 @@ + + \ No newline at end of file