[Spring][쇼핑몰 프로젝트][14] 작가등록 기능 구현 -2

https://kimvampa.tistory.com/156
This commit is contained in:
SeoJin Kim
2021-02-09 18:41:41 +09:00
parent b0e5639227
commit f6dfa4058e
7 changed files with 220 additions and 1 deletions

View File

@@ -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";
}
}