diff --git a/.classpath b/.classpath
index c41c43a..2f1d300 100644
--- a/.classpath
+++ b/.classpath
@@ -28,7 +28,7 @@
-
+
diff --git a/.gitignore b/.gitignore
index f2587e4..2555fe8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,6 @@
pom.properties
+
*.class
+
+MANIFEST
+/target/
diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs
index 4e863b4..8cbce54 100644
--- a/.settings/org.eclipse.core.resources.prefs
+++ b/.settings/org.eclipse.core.resources.prefs
@@ -1,7 +1,6 @@
eclipse.preferences.version=1
-encoding//src/main/webapp/WEB-INF/views/user/authError.jsp=UTF-8
-encoding//src/main/webapp/WEB-INF/views/user/authSuccess.jsp=UTF-8
-encoding//src/main/webapp/WEB-INF/views/user/base.jsp=UTF-8
-encoding//src/main/webapp/WEB-INF/views/user/joinSuccess.jsp=UTF-8
-encoding//src/main/webapp/WEB-INF/views/user/login.jsp=UTF-8
-encoding//src/main/webapp/WEB-INF/views/user/register.jsp=UTF-8
+encoding//src/main/java=UTF-8
+encoding//src/main/java/com/ustyle/controller/AdminController.java=UTF-8
+encoding//src/main/java/com/ustyle/controller/CheckoutController.java=UTF-8
+encoding//src/main/webapp/WEB-INF/views/user/deleteForm.jsp=UTF-8
+encoding//src/test/java=UTF-8
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
index 107056a..13b3428 100644
--- a/.settings/org.eclipse.jdt.core.prefs
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -1,12 +1,13 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
-org.eclipse.jdt.core.compiler.source=1.6
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component
index c71a0df..10736e1 100644
--- a/.settings/org.eclipse.wst.common.component
+++ b/.settings/org.eclipse.wst.common.component
@@ -4,7 +4,6 @@
-
diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml
index 43b1e0c..2091c7f 100644
--- a/.settings/org.eclipse.wst.common.project.facet.core.xml
+++ b/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -3,5 +3,5 @@
-
+
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..03afa38
--- /dev/null
+++ b/README.md
@@ -0,0 +1,38 @@
+# uStyle
+ uStyle은 여성을 대상으로 한 쇼핑몰입니다.
+ 다양한 카테고리의 상품을 확인해볼 수 있으며, 상품의 색상, 사이즈를 선택하여 구매할 수 있습니다.
+ 원하는 상품을 pin으로 등록하고, 등록된 상품을 다른 사용자에게 보여줌으로써,
+ 그 상품의 구매를 유도할 수 있는 PinBoard 기능을 구현하였습니다.
+
+- 통합개발환경(IDE)
+ - Language : Java 1.8
+ - Application Framework : Spring 4.1.7, Spring Security 4.0.4
+ - Build tool : Apache Maven 3.3.9
+ - DBMS : MySQL 5.7
+ - WAS : Apache Tomcat 8.0
+ - else : jQuery 1.11.3, Handlebars.js 3.0.1, Log4j 1.2.17, Tiles 3.0.5, MyBatis 3.2.8 ...
+
+- Backend
+ - github를 통한 소스공유(sourcetree 이용)
+ - AWS EC2 이용 http://52.78.142.52:8080 : 본 uStyle 홈페이지 주소
+ - docker 를 이용해 mysql DB 와 tomcat 를 각각 컨테이너로 세팅
+ - jenkins 를 통해 CI/CD 구현. 빌드 및 배포 자동화. 지속적인 유지보수관리 가능.
+ - github hook service와 jenkins내 플러그인 이용 소스 자동업데이트
+ - locust 를 통해 서버 부하테스트
+
+- Frontend
+ - RESTful API 문서화 도구 Swagger 사용
+ - 로그인이 필요한 페이지를 판별하기 위해 Interceptor 클래스 활용
+ - tiles 를 이용한 template framework
+ - Ajax 를 이용하여 아이디 중복체크, 파일 업로드, 장바구니, 상품리뷰 작성 구현
+ - Java mailsender를 이용하여 회원가입 이메일 인증, 비밀번호찾기 기능 구현
+ - Spring Security를 통해 csrf token 적용
+ - BCryptPasswordEncoder 를 통해 password 암호화
+ - 만들어진 CSS template 이용(themeforest, AdminLTE)
+ - bootstrap modal을 이용하여 pinboard 기능 구현
+ - 반응형 웹페이지 적용
+
+
+
+
+### more details, https://graybat21.github.io/uStyle/uStyle_Project.pdf
diff --git a/pom.xml b/pom.xml
index 8c1948d..a3c1ee9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,290 +1,328 @@
-
-
- 4.0.0
- com.ustyle
- controller
- uStyle
- war
- 1.0.0-BUILD-SNAPSHOT
-
- 1.8
- 4.1.7.RELEASE
- 1.6.10
- 1.6.6
-
-
-
-
- org.springframework
- spring-context
- ${org.springframework-version}
-
-
-
- commons-logging
- commons-logging
-
-
-
-
- org.springframework
- spring-webmvc
- ${org.springframework-version}
-
-
-
- com.mchange
- c3p0
- 0.9.5
-
-
- mysql
- mysql-connector-java
- 5.1.38
-
-
-
-
- org.aspectj
- aspectjrt
- ${org.aspectj-version}
-
-
-
- org.aspectj
- aspectjweaver
- ${org.aspectj-version}
-
-
-
-
- org.slf4j
- slf4j-api
- ${org.slf4j-version}
-
-
- org.slf4j
- jcl-over-slf4j
- ${org.slf4j-version}
- runtime
-
-
- org.slf4j
- slf4j-log4j12
- ${org.slf4j-version}
- runtime
-
-
- log4j
- log4j
- 1.2.17
-
-
- javax.mail
- mail
-
-
- javax.jms
- jms
-
-
- com.sun.jdmk
- jmxtools
-
-
- com.sun.jmx
- jmxri
-
-
- runtime
-
-
-
-
- javax.inject
- javax.inject
- 1
-
-
-
-
- org.apache.tiles
- tiles-extras
- 3.0.5
-
-
-
-
-
-
-
- javax.servlet
- javax.servlet-api
- 3.0.1
-
-
-
- javax.servlet.jsp
- jsp-api
- 2.1
- provided
-
-
- javax.servlet
- jstl
- 1.2
-
-
-
-
- javax.validation
- validation-api
- 1.1.0.Final
-
-
-
-
- org.springframework
- spring-context-support
- ${org.springframework-version}
-
-
- javax.mail
- mail
- 1.4.7
-
-
-
-
- junit
- junit
- 4.12
- test
-
-
-
-
- org.mybatis
- mybatis-spring
- 1.2.2
-
-
-
- org.mybatis
- mybatis
- 3.2.8
-
-
-
- org.springframework
- spring-jdbc
- ${org.springframework-version}
-
-
-
- org.springframework
- spring-test
- ${org.springframework-version}
-
-
-
- org.springframework
- spring-tx
- ${org.springframework-version}
-
-
-
- org.springframework
- spring-aop
- ${org.springframework-version}
-
-
-
- com.fasterxml.jackson.core
- jackson-databind
- 2.5.4
-
-
-
- org.bgee.log4jdbc-log4j2
- log4jdbc-log4j2-jdbc4
- 1.16
-
-
-
- commons-fileupload
- commons-fileupload
- 1.3.1
-
-
-
- org.imgscalr
- imgscalr-lib
- 4.2
-
-
-
-
- org.springframework.security
- spring-security-web
- 4.0.4.RELEASE
-
-
- org.springframework.security
- spring-security-core
- 4.0.4.RELEASE
-
-
- org.springframework.security
- spring-security-config
- 4.0.4.RELEASE
-
-
-
-
-
-
-
-
- maven-eclipse-plugin
- 2.9
-
-
- org.springframework.ide.eclipse.core.springnature
-
-
- org.springframework.ide.eclipse.core.springbuilder
-
- true
- true
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 2.5.1
-
- 1.6
- 1.6
- -Xlint:all
- true
- true
-
-
-
- org.codehaus.mojo
- exec-maven-plugin
- 1.2.1
-
- org.test.int1.Main
-
-
-
-
-
+
+
+ 4.0.0
+ com.ustyle
+ controller
+ uStyle
+ war
+ 1.0.0-BUILD-SNAPSHOT
+
+ 1.8
+ 4.1.7.RELEASE
+ 1.6.10
+ 1.6.6
+
+
+
+
+ org.springframework
+ spring-context
+ ${org.springframework-version}
+
+
+
+ commons-logging
+ commons-logging
+
+
+
+
+ org.springframework
+ spring-webmvc
+ ${org.springframework-version}
+
+
+
+ com.mchange
+ c3p0
+ 0.9.5
+
+
+ mysql
+ mysql-connector-java
+ 5.1.38
+
+
+
+
+ org.aspectj
+ aspectjrt
+ ${org.aspectj-version}
+
+
+
+ org.aspectj
+ aspectjweaver
+ ${org.aspectj-version}
+
+
+
+
+ org.slf4j
+ slf4j-api
+ ${org.slf4j-version}
+
+
+ org.slf4j
+ jcl-over-slf4j
+ ${org.slf4j-version}
+ runtime
+
+
+ org.slf4j
+ slf4j-log4j12
+ ${org.slf4j-version}
+ runtime
+
+
+ log4j
+ log4j
+ 1.2.17
+
+
+ javax.mail
+ mail
+
+
+ javax.jms
+ jms
+
+
+ com.sun.jdmk
+ jmxtools
+
+
+ com.sun.jmx
+ jmxri
+
+
+ runtime
+
+
+
+
+ javax.inject
+ javax.inject
+ 1
+
+
+
+
+ org.apache.tiles
+ tiles-extras
+ 3.0.5
+
+
+
+
+
+
+
+ javax.servlet
+ javax.servlet-api
+ 3.0.1
+
+
+
+ javax.servlet.jsp
+ jsp-api
+ 2.1
+ provided
+
+
+ javax.servlet
+ jstl
+ 1.2
+
+
+
+
+ javax.validation
+ validation-api
+ 1.1.0.Final
+
+
+
+
+ org.springframework
+ spring-context-support
+ ${org.springframework-version}
+
+
+ javax.mail
+ mail
+ 1.4.7
+
+
+
+
+ io.springfox
+ springfox-swagger2
+ 2.7.0
+
+
+ io.springfox
+ springfox-swagger-ui
+ 2.7.0
+
+
+ com.google.guava
+ guava
+ 18.0
+
+
+
+
+ junit
+ junit
+ 4.12
+ test
+
+
+
+
+ org.mybatis
+ mybatis-spring
+ 1.2.2
+
+
+
+ org.mybatis
+ mybatis
+ 3.2.8
+
+
+
+ org.springframework
+ spring-jdbc
+ ${org.springframework-version}
+
+
+
+ org.springframework
+ spring-test
+ ${org.springframework-version}
+
+
+
+ org.springframework
+ spring-tx
+ ${org.springframework-version}
+
+
+
+ org.springframework
+ spring-aop
+ ${org.springframework-version}
+
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ 2.5.4
+
+
+
+ org.bgee.log4jdbc-log4j2
+ log4jdbc-log4j2-jdbc4
+ 1.16
+
+
+
+ commons-fileupload
+ commons-fileupload
+ 1.3.1
+
+
+
+ org.imgscalr
+ imgscalr-lib
+ 4.2
+
+
+
+
+ org.springframework.security
+ spring-security-web
+ 4.0.4.RELEASE
+
+
+ org.springframework.security
+ spring-security-core
+ 4.0.4.RELEASE
+
+
+ org.springframework.security
+ spring-security-config
+ 4.0.4.RELEASE
+
+
+
+
+
+
+ ROOT
+
+
+ maven-eclipse-plugin
+ 2.9
+
+
+ org.springframework.ide.eclipse.core.springnature
+
+
+ org.springframework.ide.eclipse.core.springbuilder
+
+ true
+ true
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 2.5.1
+
+ 1.6
+ 1.6
+ -Xlint:all
+ true
+ true
+ UTF-8
+
+
+
+ org.codehaus.mojo
+ exec-maven-plugin
+ 1.2.1
+
+ org.test.int1.Main
+
+
+
+ org.apache.tomcat.maven
+ tomcat7-maven-plugin
+ 2.2
+
+ http://localhost:8081
+ /
+
+
+
+
+
+
+
+ org.codehaus.mojo
+ sonar-maven-plugin
+
+
+
+
+
+
diff --git a/src/main/java/com/ustyle/controller/AdminController.java b/src/main/java/com/ustyle/controller/AdminController.java
new file mode 100644
index 0000000..6eaef6c
--- /dev/null
+++ b/src/main/java/com/ustyle/controller/AdminController.java
@@ -0,0 +1,352 @@
+package com.ustyle.controller;
+
+import java.sql.Timestamp;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.inject.Inject;
+import javax.validation.Valid;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+
+import com.ustyle.domain.Grade;
+import com.ustyle.domain.PinBoard;
+import com.ustyle.domain.User;
+import com.ustyle.service.GradeService;
+import com.ustyle.service.PinService;
+import com.ustyle.service.SalesService;
+import com.ustyle.service.UserService;
+import com.ustyle.utils.PageMaker;
+
+@Controller
+@RequestMapping("/admin/*")
+public class AdminController {
+ private static final Logger logger = LoggerFactory.getLogger(AdminController.class);
+
+ @Inject
+ private UserService userService;
+ @Inject
+ private GradeService gradeService;
+ @Inject
+ private SalesService salesService;
+ @Inject
+ private PinService pinService;
+
+ @RequestMapping(value = "main.do", method = RequestMethod.GET)
+ public String mainForm() {
+ return "main/base";
+ }
+
+ @RequestMapping(value = "login", method = RequestMethod.GET)
+ public String loginForm() {
+ return "login/loginAdmin";
+ }
+
+ @RequestMapping(value = "logout.do", method = RequestMethod.GET)
+ public String logout() {
+ return "login/logoutAdmin";
+ }
+
+ @RequestMapping("userList.do")
+ public ModelAndView userList(PageMaker pagemaker, @RequestParam(value = "o", required = false) String searchOption,
+ @RequestParam(value = "k", required = false) String searchKeyword) throws Exception {
+ ModelAndView mav = new ModelAndView();
+ HashMap map = new HashMap();
+ int page = pagemaker.getPage() != null ? pagemaker.getPage() : 1;
+ pagemaker.setPage(page);
+ map.put("searchOption", searchOption);
+ map.put("searchKeyword", searchKeyword);
+ int totalCnt = userService.selectListCnt(map); // DB�뿰�룞_ 珥� 媛��닔
+ // 援ы빐�삤湲�
+ int countPerPage = 3;
+ int countPerPaging = 3;
+
+ int first = ((pagemaker.getPage() - 1) * countPerPage) + 1;
+ int last = first + countPerPage - 1;
+ map.put("first", first);
+ map.put("last", last);
+
+ List list = userService.userList(map);
+ pagemaker.setCount(totalCnt, countPerPage, countPerPaging);
+ mav.addObject("userList", list);
+ mav.addObject("pageMaker", pagemaker);
+ mav.setViewName("user/userList");
+ mav.addObject("searchOption", searchOption);
+ mav.addObject("searchKeyword", searchKeyword);
+ logger.info(list.toString());
+ return mav;
+ }
+
+ @ResponseBody
+ @RequestMapping(value = "initializePoint.do", method = RequestMethod.POST)
+ public ResponseEntity initializePoint(@RequestBody User user) throws Exception {
+
+ ResponseEntity entity = null;
+
+ try
+ {
+ user.setPoint(0);
+ logger.info("INITIALIZE POINT TO USERNAME = " + user.getUsername());
+ userService.updatePoint(user);
+ entity = new ResponseEntity("SUCCESS", HttpStatus.OK);
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ entity = new ResponseEntity(e.getMessage(), HttpStatus.BAD_REQUEST);
+ }
+
+ return entity;
+ }
+
+ @ResponseBody
+ @RequestMapping(value = "userDelete.do", method = RequestMethod.POST)
+ public ResponseEntity userDelete(@RequestBody User user) throws Exception {
+
+ ResponseEntity entity = null;
+
+ try
+ {
+ String username = user.getUsername();
+ logger.info("DELETE TO USERNAME = " + username);
+ userService.delete(username);
+ entity = new ResponseEntity("SUCCESS", HttpStatus.OK);
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ entity = new ResponseEntity(e.getMessage(), HttpStatus.BAD_REQUEST);
+ }
+
+ return entity;
+ }
+
+ @RequestMapping(value = "grade.do", method = RequestMethod.GET)
+ public String gradeList(Model model) throws Exception {
+ List gradeList = gradeService.selectList();
+ model.addAttribute(gradeList);
+ return "grade/gradeList";
+ }
+
+ @RequestMapping(value = "grade.do", method = RequestMethod.POST)
+ public String gradeInsert(@ModelAttribute @Valid Grade grade) throws Exception {
+ gradeService.insert(grade);
+ return "redirect:/admin/grade.do";
+ }
+
+ @RequestMapping(value = "gradeUpdate.do", method = RequestMethod.POST)
+ public String gradeUpdate(@ModelAttribute @Valid Grade grade) throws Exception {
+ gradeService.update(grade);
+ logger.info("grade has been successfully updated!! - " + grade.toString());
+ return "redirect:/admin/grade.do";
+ }
+
+ @RequestMapping(value = "modifyAllUsersGrade.do")
+ public String modifyAllUsersGrade() throws Exception {
+ userService.modifyAllUsersGradeInitialize();
+ Grade grade = new Grade();
+ List gradeList = gradeService.selectList();
+ for (int i = 0; i < gradeList.size(); i++) {
+ grade = gradeList.get(i);
+ userService.modifyAllUsersGrade(grade);
+ logger.info("\n***Grade idx" + grade.getIdx() + ", " + grade.getGrade()
+ + " users \nwho bought whole purchase price between " + grade.getMin() + " and " + grade.getMax()
+ + " last " + grade.getBuy_term() + " months \nhave been successfully updated!");
+ }
+ return "redirect:/admin/grade.do";
+ }
+
+ @RequestMapping("deleteGrade.do")
+ public String gradeDelete(@RequestParam int idx) throws Exception {
+ gradeService.delete(idx);
+ return "redirect:/admin/grade.do";
+ }
+
+ @RequestMapping(value = "salesList.do", method = RequestMethod.GET)
+ public ModelAndView salesList(@RequestParam(value = "startDate", required = false) String startDate,
+ @RequestParam(value = "endDate", required = false) String endDate, Integer pageCount) throws Exception {
+ ModelAndView mav = new ModelAndView("sales/salesList");
+
+ PageMaker pagemaker = new PageMaker();
+
+ mav.addObject("startDate", startDate);
+ mav.addObject("endDate", endDate);
+
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
+
+ Timestamp firstTimestamp = new Timestamp(0);
+ String firstDate = sdf.format(firstTimestamp); // 19700101
+
+ if ( startDate == null || endDate == null )
+ return mav;
+ else if ( Integer.parseInt(startDate) > Integer.parseInt(endDate)
+ || Integer.parseInt(startDate) < Integer.parseInt(firstDate) ) {
+ mav.setViewName("sales/salesListFail");
+ return mav;
+ }
+
+ Date formattedStartDate = sdf.parse(startDate);
+ Date formattedEndDate = sdf.parse(endDate);
+ formattedEndDate = getEndOfDay(formattedEndDate); // yyyymmdd 형식으로 입력된 날짜의 마지막 시간을 구함
+
+ Timestamp startTimestamp = new Timestamp(formattedStartDate.getTime());
+ Timestamp endTimestamp = new Timestamp(formattedEndDate.getTime());
+
+ HashMap dateMap = new HashMap();
+ dateMap.put("start", startTimestamp);
+ dateMap.put("end", endTimestamp);
+
+ logger.info(startTimestamp.toString());
+ logger.info(endTimestamp.toString());
+
+ HashMap totalMapForDaterange = salesService.selectSalesForDaterange(dateMap);
+
+ int totalCnt = Integer.parseInt(String.valueOf(totalMapForDaterange.get("totalcnt")));
+ long totalSalesPrice = Long.parseLong(String.valueOf(totalMapForDaterange.get("totalsalesprice")));
+ int totalUsedPoint = Integer.parseInt(String.valueOf(totalMapForDaterange.get("totalusedpoint")));
+
+ int page = ( pageCount != null ) ? pageCount.intValue() : 1;
+ pagemaker.setPage(page);
+ int countPerPaging = 10;
+ int pageCnt = 10;
+
+ pagemaker.setCount(totalCnt, pageCnt, countPerPaging);
+
+ int first = ( (page - 1) * pageCnt);
+ dateMap.put("firstrow", first);
+ dateMap.put("pagecnt", pageCnt);
+
+ List> salesList = salesService.selectSalesForDaterangeAndPagination(dateMap);
+
+ for ( HashMap sales : salesList )
+ {
+ Iterator iterator = sales.keySet().iterator();
+ while (iterator.hasNext()) {
+ String key = String.valueOf(iterator.next());
+ logger.info("key = " + key);
+ logger.info(" value = " + sales.get(key));
+ }
+ }
+
+ logger.info("START DATE = " + startTimestamp);
+ logger.info("END DATE = " + endTimestamp);
+ logger.info("TOTAL COUNT = " + totalCnt);
+ logger.info("PAGE = " + page);
+
+ mav.addObject("salesList", salesList);
+ mav.addObject("totalSalesPrice", totalSalesPrice);
+ mav.addObject("totalUsedPoint", totalUsedPoint);
+ mav.addObject("pageMaker", pagemaker);
+
+ return mav;
+ }
+
+ private Date getEndOfDay(Date day) {
+ return getEndOfDay(day, Calendar.getInstance());
+ }
+
+ private Date getEndOfDay(Date day, Calendar cal) {
+ if (day == null)
+ day = new Date();
+
+ cal.setTime(day);
+ cal.set(Calendar.HOUR_OF_DAY, cal.getMaximum(Calendar.HOUR_OF_DAY));
+ cal.set(Calendar.MINUTE, cal.getMaximum(Calendar.MINUTE));
+ cal.set(Calendar.SECOND, cal.getMaximum(Calendar.SECOND));
+ cal.set(Calendar.MILLISECOND, cal.getMaximum(Calendar.MILLISECOND));
+ return cal.getTime();
+ }
+
+ @RequestMapping(value = "salesDetail.do", method = RequestMethod.GET)
+ public ModelAndView salesDetail(Timestamp purchasedate, String username) throws Exception {
+ ModelAndView mav = new ModelAndView("sales/salesDetail");
+
+ HashMap userMap = new HashMap();
+ userMap.put("purchasedate", purchasedate);
+ userMap.put("username", username);
+
+ HashMap userDetailMap = salesService.selectSalesForDate(userMap);
+ // userDetailMap이 null일 때, 400 Error 예외페이지 처리
+
+ Integer purchaseid = Integer.valueOf(String.valueOf(userDetailMap.get("purchaseid")));
+
+ List> salesDetailList = salesService.selectSalesDetail(purchaseid);
+
+ mav.addObject("userMap", userMap);
+ mav.addObject("userDetailMap", userDetailMap);
+ mav.addObject("salesDetailList", salesDetailList);
+
+ return mav;
+ }
+
+ // =============================== pin =============================== //
+
+ @RequestMapping("pinBoardList.do")
+ public ModelAndView pinBoardList(PageMaker pageMaker,
+ @RequestParam(value = "o", required = false) String searchOption,
+ @RequestParam(value = "k", required = false) String searchKeyword) throws Exception {
+ ModelAndView mav = new ModelAndView();
+ HashMap map = new HashMap();
+
+ int page = pageMaker.getPage() != null ? pageMaker.getPage() : 1;
+ pageMaker.setPage(page);
+ map.put("searchOption", searchOption);
+ map.put("searchKeyword", searchKeyword);
+ int totalCnt = pinService.selectListCnt(map);
+ int countPerPage = 10;
+ int countPerPaging = 10;
+
+ int first = ((pageMaker.getPage() - 1) * countPerPage) + 1;
+ int last = first + countPerPage - 1;
+ map.put("first", first);
+ map.put("last", last);
+
+ List list = pinService.selectPinBoardList(map);
+ pageMaker.setCount(totalCnt, countPerPage, countPerPaging);
+ mav.addObject("pinBoardList", list);
+ mav.addObject("pageMaker", pageMaker);
+ mav.setViewName("pin/pinBoardList");
+ mav.addObject("searchOption", searchOption);
+ mav.addObject("searchKeyword", searchKeyword);
+ logger.info(list.toString());
+ return mav;
+ }
+
+ @ResponseBody
+ @RequestMapping(value = "pinBoardDelete.do", method = RequestMethod.POST)
+ public ResponseEntity pinBoardDelete(@RequestBody PinBoard pinBoard) throws Exception {
+
+ ResponseEntity entity = null;
+
+ try
+ {
+ int pinBoardno = pinBoard.getPinboardno();
+ logger.info("DELETE TO PINBOARD = " + pinBoard.toString());
+ pinService.deletePinBoard(pinBoardno);
+ entity = new ResponseEntity("SUCCESS", HttpStatus.OK);
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ entity = new ResponseEntity(e.getMessage(), HttpStatus.BAD_REQUEST);
+ }
+
+ return entity;
+ }
+}
diff --git a/src/main/java/com/ustyle/controller/BoardAdminController.java b/src/main/java/com/ustyle/controller/BoardAdminController.java
new file mode 100644
index 0000000..5eaff6f
--- /dev/null
+++ b/src/main/java/com/ustyle/controller/BoardAdminController.java
@@ -0,0 +1,309 @@
+package com.ustyle.controller;
+
+import java.util.HashMap;
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+
+import com.ustyle.domain.Faq;
+import com.ustyle.domain.Notice;
+import com.ustyle.domain.Qna;
+import com.ustyle.service.FaqService;
+import com.ustyle.service.NoticeService;
+import com.ustyle.service.QnaService;
+import com.ustyle.utils.PageMaker;
+
+@Controller
+@RequestMapping("/admin/board/*")
+public class BoardAdminController {
+
+ private static final Logger logger = LoggerFactory.getLogger(BoardAdminController.class);
+
+ @Inject
+ private NoticeService noticeService;
+
+ @Inject
+ private FaqService faqService;
+
+ @Inject
+ private QnaService qnaService;
+
+/* ============================== Notice ================================= */
+
+ @RequestMapping(value = "notice.do", method = RequestMethod.GET)
+ public ModelAndView noticeList(PageMaker pageMaker,
+ @RequestParam(value = "o", required = false) String searchOption,
+ @RequestParam(value = "k", required = false) String searchKeyword) throws Exception {
+ ModelAndView mav = new ModelAndView();
+
+ HashMap map = new HashMap();
+ map.put("searchOption", searchOption);
+ map.put("searchKeyword", searchKeyword);
+
+ int totalCnt = noticeService.selectListCnt(map); // DB연동_ 총 갯수 구해오기
+ int page = ( pageMaker.getPage() != null ) ? pageMaker.getPage() : 1;
+ pageMaker.setPage(page);
+ int countPerPage = 10;
+ int countPerPaging = 3;
+
+ int first = ((pageMaker.getPage() - 1) * countPerPage) + 1;
+ int last = first + countPerPage - 1;
+ map.put("first", first);
+ map.put("last", last);
+
+ List list = noticeService.noticeList(map);
+ logger.info(list.toString());
+ pageMaker.setCount(totalCnt, countPerPage, countPerPaging);
+
+ mav.addObject("noticeList", list);
+ mav.addObject("pageMaker", pageMaker);
+ mav.setViewName("board/board_notice");
+ mav.addObject("searchOption", searchOption);
+ mav.addObject("searchKeyword", searchKeyword);
+
+ return mav;
+ }
+
+ @RequestMapping(value = "noticeWrite.do", method = RequestMethod.GET)
+ public String noticeWriteForm() {
+ return "board/noticeWrite";
+ }
+
+ @RequestMapping(value = "noticeWrite.do", method = RequestMethod.POST)
+ public String noticeWrite(Notice notice) throws Exception {
+ noticeService.noticeWrite(notice);
+ logger.info("WRITTEN NOTICE CONTENTS = ", notice.toString());
+ return "redirect:/admin/board/notice.do";
+ }
+
+ @RequestMapping("noticeView.do")
+ public ModelAndView noticeView(@RequestParam(value = "bno") int bno, int page) throws Exception {
+ ModelAndView mav = new ModelAndView();
+
+ Notice notice = noticeService.noticeViewFromAdmin(bno);
+ mav.addObject("notice", notice);
+ mav.addObject("page", page);
+ mav.setViewName("board/noticeDetail");
+ return mav;
+ }
+
+ @RequestMapping(value = "noticeModify.do", method = RequestMethod.GET)
+ public String noticeModifyForm(@RequestParam(value = "bno") int bno, Model model) throws Exception {
+ Notice notice = noticeService.noticeViewFromAdmin(bno);
+ model.addAttribute("notice", notice);
+ return "board/noticeWrite";
+ }
+
+ @RequestMapping(value = "noticeModify.do", method = RequestMethod.POST)
+ public String noticeModify(Notice notice) throws Exception {
+ noticeService.noticeModify(notice);
+ return "redirect:/admin/board/notice.do";
+ }
+
+ @ResponseBody
+ @RequestMapping(value = "noticeDelete.do", method = RequestMethod.POST)
+ public ResponseEntity noticeDelete(@RequestBody Notice notice) throws Exception {
+
+ ResponseEntity entity = null;
+
+ try
+ {
+ int deleteBno = notice.getBno();
+ logger.info("NOTICE TO DELETE = " + deleteBno);
+ noticeService.noticeDelete(deleteBno);
+ entity = new ResponseEntity("SUCCESS", HttpStatus.OK);
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ entity = new ResponseEntity(e.getMessage(), HttpStatus.BAD_REQUEST);
+ }
+
+ return entity;
+ }
+
+/* ============================== FAQ ================================= */
+
+ @RequestMapping(value = "faq.do", method = RequestMethod.GET)
+ public ModelAndView faqList(PageMaker pageMaker, @RequestParam(value = "o", required = false) String searchOption,
+ @RequestParam(value = "k", required = false) String searchKeyword) throws Exception {
+ ModelAndView mav = new ModelAndView();
+
+ HashMap map = new HashMap();
+ map.put("searchOption", searchOption);
+ map.put("searchKeyword", searchKeyword);
+
+ int totalCnt = faqService.selectListCnt(map);
+ int page = ( pageMaker.getPage() != null ) ? pageMaker.getPage() : 1;
+ pageMaker.setPage(page);
+ int countPerPage = 10;
+ int countPerPaging = 5;
+
+ int first = ((pageMaker.getPage() - 1) * countPerPage) + 1;
+ int last = first + countPerPage - 1;
+ map.put("first", first);
+ map.put("last", last);
+
+ List list = faqService.faqList(map);
+ logger.info(list.toString());
+ pageMaker.setCount(totalCnt, countPerPage, countPerPaging);
+
+ mav.addObject("faqList", list);
+ mav.addObject("pageMaker", pageMaker);
+ mav.setViewName("board/board_faq");
+ mav.addObject("searchOption", searchOption);
+ mav.addObject("searchKeyword", searchKeyword);
+
+ return mav;
+ }
+
+ @RequestMapping(value = "faqWrite.do", method = RequestMethod.GET)
+ public String faqWriteForm() {
+ return "board/faqWrite";
+ }
+
+ @RequestMapping(value = "faqWrite.do", method = RequestMethod.POST)
+ public String faqWrite(Faq faq) throws Exception {
+ faqService.faqWrite(faq);
+ logger.info(faq.toString());
+ return "redirect:/admin/board/faq.do";
+ }
+
+ @RequestMapping(value = "faqModify.do", method = RequestMethod.GET)
+ public String faqModifyForm(@RequestParam(value = "bno") int bno,Model model) throws Exception {
+ Faq faq = faqService.faqViewFromAdmin(bno);
+ model.addAttribute("faq",faq);
+ return "board/faqWrite";
+ }
+
+ @RequestMapping(value = "faqModify.do", method = RequestMethod.POST)
+ public String faqModify(Faq faq) throws Exception {
+ System.out.println(faq.getBno() + "번 글 수정");
+ faqService.faqModify(faq);
+ return "redirect:/admin/board/faq.do";
+ }
+
+ @ResponseBody
+ @RequestMapping(value = "faqDelete.do", method = RequestMethod.POST)
+ public ResponseEntity faqDelete(@RequestBody Faq faq) throws Exception {
+
+ ResponseEntity entity = null;
+
+ try
+ {
+ int deleteBno = faq.getBno();
+ logger.info("FAQ TO DELETE = " + deleteBno);
+ faqService.faqDelete(deleteBno);
+ entity = new ResponseEntity("SUCCESS", HttpStatus.OK);
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ entity = new ResponseEntity(e.getMessage(), HttpStatus.BAD_REQUEST);
+ }
+
+ return entity;
+ }
+
+
+/* ============================== Q&A ================================= */
+
+ @RequestMapping(value = "qna.do", method = RequestMethod.GET)
+ public ModelAndView qnaList(PageMaker pageMaker, @RequestParam(value = "o", required = false) String searchOption,
+ @RequestParam(value = "k", required = false) String searchKeyword) throws Exception {
+ ModelAndView mav = new ModelAndView();
+
+ HashMap map = new HashMap();
+ map.put("searchOption", searchOption);
+ map.put("searchKeyword", searchKeyword);
+
+ int totalCnt = qnaService.selectListCnt(map);
+ int page = ( pageMaker.getPage() != null ) ? pageMaker.getPage() : 1;
+ pageMaker.setPage(page);
+
+ int countPerPage = 10;
+ int countPerPaging = 5;
+
+ int first = ((pageMaker.getPage() - 1) * countPerPage) + 1;
+ int last = first + countPerPage - 1;
+ map.put("first", first);
+ map.put("last", last);
+
+ List list = qnaService.qnaList(map);
+ logger.info(list.toString());
+ pageMaker.setCount(totalCnt, countPerPage, countPerPaging);
+
+ mav.addObject("qnaList", list);
+ mav.addObject("pageMaker", pageMaker);
+ mav.setViewName("board/board_qna");
+ mav.addObject("searchOption", searchOption);
+ mav.addObject("searchKeyword", searchKeyword);
+ return mav;
+ }
+
+ @RequestMapping("qnaView.do")
+ public ModelAndView qnaView(@RequestParam(value = "bno") int bno, int page) throws Exception {
+ ModelAndView mav = new ModelAndView();
+
+ Qna qna = qnaService.qnaViewFromAdmin(bno);
+ mav.addObject("qna", qna);
+ mav.addObject("page", page);
+ mav.setViewName("board/qnaDetail");
+ return mav;
+ }
+
+ @ResponseBody
+ @RequestMapping(value = "qnaDelete.do", method = RequestMethod.POST)
+ public ResponseEntity qnaDelete(@RequestBody Qna qna) throws Exception {
+
+ ResponseEntity entity = null;
+
+ try
+ {
+ int deleteBno = qna.getBno();
+ logger.info("Q&A TO DELETE = " + deleteBno);
+ qnaService.qnaDelete(deleteBno);
+ entity = new ResponseEntity("SUCCESS", HttpStatus.OK);
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ entity = new ResponseEntity(e.getMessage(), HttpStatus.BAD_REQUEST);
+ }
+
+ return entity;
+ }
+
+ @RequestMapping(value = "qnaReply.do", method = RequestMethod.GET)
+ public String qnaReplyForm(@RequestParam(value = "parent") int parent, Model model) throws Exception {
+ Qna qna = qnaService.qnaViewFromAdmin(parent);
+ model.addAttribute("qna",qna);
+ return "board/qnaWrite";
+ }
+
+ @RequestMapping(value = "qnaReply.do", method = RequestMethod.POST)
+ public String qnaReply(Qna qna) throws Exception {
+ qna.setUsername("administrator");
+ qna.setParent(qna.getBno());
+ qna.setDepth(1);
+ qna.setIndent(1);
+
+ qnaService.qnaWrite(qna);
+ logger.info(qna.toString());
+ return "redirect:/admin/board/qna.do";
+ }
+
+}
diff --git a/src/main/java/com/ustyle/controller/BoardController.java b/src/main/java/com/ustyle/controller/BoardController.java
new file mode 100644
index 0000000..fc8519a
--- /dev/null
+++ b/src/main/java/com/ustyle/controller/BoardController.java
@@ -0,0 +1,339 @@
+package com.ustyle.controller;
+
+import java.net.URLEncoder;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.inject.Inject;
+import javax.servlet.http.HttpSession;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+
+import com.ustyle.domain.Faq;
+import com.ustyle.domain.Notice;
+import com.ustyle.domain.Qna;
+import com.ustyle.domain.User;
+import com.ustyle.service.FaqService;
+import com.ustyle.service.NoticeService;
+import com.ustyle.service.QnaService;
+import com.ustyle.utils.PageMaker;
+
+@Controller
+@RequestMapping("/board/*")
+public class BoardController {
+
+ private static final Logger logger = LoggerFactory.getLogger(BoardController.class);
+
+ @Inject
+ private NoticeService noticeService;
+
+ @Inject
+ private FaqService faqService;
+
+ @Inject
+ private QnaService qnaService;
+
+/* ============================== Notice ================================= */
+
+ @RequestMapping(value = "notice.do", method = RequestMethod.GET)
+ public ModelAndView noticeList(PageMaker pageMaker,
+ @RequestParam(value = "o", required = false) String searchOption,
+ @RequestParam(value = "k", required = false) String searchKeyword) throws Exception {
+
+ ModelAndView mav = new ModelAndView("board/board_notice/Notice");
+
+ if ( searchKeyword != null )
+ searchKeyword = searchKeyword.trim();
+
+ HashMap map = new HashMap();
+ map.put("searchOption", searchOption);
+ map.put("searchKeyword", searchKeyword);
+
+ int totalCnt = noticeService.selectListCnt(map); // DB연동_ 총 갯수 구해오기
+
+ int page = ( pageMaker.getPage() != null ) ? pageMaker.getPage() : 1;
+ pageMaker.setPage(page);
+ int countPerPage = 10;
+ int countPerPaging = 3;
+
+ int first = ((pageMaker.getPage() - 1) * countPerPage) + 1;
+ int last = first + countPerPage - 1;
+ map.put("first", first);
+ map.put("last", last);
+
+ List list = noticeService.noticeList(map);
+ logger.info(list.toString());
+ pageMaker.setCount(totalCnt, countPerPage, countPerPaging);
+
+ mav.addObject("noticeList", list);
+ mav.addObject("pageMaker", pageMaker);
+ mav.setViewName("board/board_notice/공지사항");
+ mav.addObject("searchOption", searchOption);
+ mav.addObject("searchKeyword", searchKeyword);
+
+ return mav;
+ }
+
+ @RequestMapping("noticeView.do")
+ public ModelAndView noticeView(@RequestParam(value = "bno") int bno) throws Exception {
+ ModelAndView mav = new ModelAndView();
+
+ Notice notice = noticeService.noticeView(bno);
+ logger.info(notice.toString());
+
+ mav.addObject("notice", notice);
+ mav.setViewName("board/noticeDetail/공지사항 상세보기");
+
+ return mav;
+ }
+
+/* ============================== FAQ ================================= */
+
+ @RequestMapping(value = "faq.do", method = RequestMethod.GET)
+ public ModelAndView faqList(PageMaker pageMaker, @RequestParam(value = "o", required = false) String searchOption,
+ @RequestParam(value = "k", required = false) String searchKeyword) throws Exception {
+ ModelAndView mav = new ModelAndView();
+ HashMap map = new HashMap();
+
+ map.put("searchOption", searchOption);
+ map.put("searchKeyword", searchKeyword);
+
+ int totalCnt = faqService.selectListCnt(map);
+ int page = pageMaker.getPage() != null ? pageMaker.getPage() : 1;
+ pageMaker.setPage(page);
+ int countPerPage = 10;
+ int countPerPaging = 5;
+
+ int first = ((pageMaker.getPage() - 1) * countPerPage) + 1;
+ int last = first + countPerPage - 1;
+ map.put("first", first);
+ map.put("last", last);
+
+ List list = faqService.faqList(map);
+ logger.info(list.toString());
+ pageMaker.setCount(totalCnt, countPerPage, countPerPaging);
+
+ mav.addObject("faqList", list);
+ mav.addObject("pageMaker", pageMaker);
+ mav.setViewName("board/board_faq/FAQ");
+ mav.addObject("searchOption", searchOption);
+ mav.addObject("searchKeyword", searchKeyword);
+
+ return mav;
+ }
+
+/* ============================== Q&A ================================= */
+
+ @RequestMapping(value = "qna.do", method = RequestMethod.GET)
+ public ModelAndView qnaList(PageMaker pageMaker, @RequestParam(value = "o", required = false) String searchOption,
+ @RequestParam(value = "k", required = false) String searchKeyword) throws Exception {
+ ModelAndView mav = new ModelAndView();
+
+ HashMap map = new HashMap();
+
+ if ( searchKeyword != null )
+ searchKeyword = searchKeyword.trim();
+
+ map.put("searchOption", searchOption);
+ map.put("searchKeyword", searchKeyword);
+
+ int totalCnt = qnaService.selectListCnt(map);
+
+ logger.info("aaa = " + totalCnt);
+
+ int page = ( pageMaker.getPage() != null ) ? pageMaker.getPage() : 1;
+ pageMaker.setPage(page);
+ int countPerPage = 10;
+ int countPerPaging = 5;
+
+ int first = ((pageMaker.getPage() - 1) * countPerPage) + 1;
+ int last = first + countPerPage - 1;
+ map.put("first", first);
+ map.put("last", last);
+
+ List list = qnaService.qnaList(map);
+ logger.info(list.toString());
+
+ pageMaker.setCount(totalCnt, countPerPage, countPerPaging);
+ mav.addObject("qnaList", list);
+ mav.addObject("pageMaker", pageMaker);
+ mav.setViewName("board/board_qna/Q&A");
+ mav.addObject("searchOption", searchOption);
+ mav.addObject("searchKeyword", searchKeyword);
+
+ return mav;
+ }
+
+ @RequestMapping(value = "qnaWrite.do", method = RequestMethod.GET)
+ public ModelAndView qnaWriteForm(@RequestParam(value = "page") int page, HttpSession session) {
+ ModelAndView mav = new ModelAndView("board/qnaWrite/Q&A 글쓰기");
+
+ mav.addObject("page", page);
+ return mav;
+ }
+
+ @RequestMapping(value = "qnaWrite.do", method = RequestMethod.POST)
+ public String qnaWrite(Qna qna, HttpSession session) throws Exception {
+
+ User user = (User) session.getAttribute("session_user");
+ qna.setUsername(user.getUsername());
+
+ logger.info(qna.toString());
+ qnaService.qnaWrite(qna);
+
+ return "redirect:/board/myQnaList.do";
+ }
+
+ @RequestMapping("qnaView.do")
+ public ModelAndView qnaView(@RequestParam(value = "bno") int bno, int page) throws Exception {
+ ModelAndView mav = new ModelAndView();
+
+ Qna qna = qnaService.qnaView(bno);
+
+ mav.addObject("qna", qna);
+ mav.addObject("page", page);
+ mav.setViewName("board/qnaDetail/Q&A 상세보기");
+ return mav;
+ }
+
+ @ResponseBody
+ @RequestMapping(value = "qnaDelete.do", method = RequestMethod.POST)
+ public ResponseEntity qnaDelete(@RequestBody Qna qna) throws Exception {
+
+ ResponseEntity entity = null;
+
+ try
+ {
+ int deleteBno = qna.getBno();
+ logger.info("Q&A TO DELETE = " + deleteBno);
+ qnaService.qnaDelete(deleteBno);
+ entity = new ResponseEntity("SUCCESS", HttpStatus.OK);
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ entity = new ResponseEntity(e.getMessage(), HttpStatus.BAD_REQUEST);
+ }
+
+ return entity;
+ }
+
+ @RequestMapping(value = "myQnaList.do", method = RequestMethod.GET)
+ public ModelAndView myQnaList(HttpSession session, PageMaker pageMaker, @RequestParam(value = "o", required = false) String searchOption,
+ @RequestParam(value = "k", required = false) String searchKeyword) throws Exception {
+
+ ModelAndView mav = new ModelAndView();
+
+ if ( searchKeyword != null )
+ searchKeyword = searchKeyword.trim();
+
+ HashMap map = new HashMap();
+ User user = (User) session.getAttribute("session_user");
+
+ map.put("username", user.getUsername());
+ map.put("searchOption", searchOption);
+ map.put("searchKeyword", searchKeyword);
+ int totalCnt = qnaService.selectMyListCnt(map);
+
+ int page = ( pageMaker.getPage() != null ) ? pageMaker.getPage() : 1;
+ pageMaker.setPage(page);
+ int countPerPage = 10;
+ int countPerPaging = 5;
+
+ int first = ((pageMaker.getPage() - 1) * countPerPage) + 1;
+ int last = first + countPerPage - 1;
+ map.put("first", first);
+ map.put("last", last);
+
+ List list = qnaService.myQnaList(map);
+
+ pageMaker.setCount(totalCnt, countPerPage, countPerPaging);
+ mav.addObject("pageMaker", pageMaker);
+ mav.addObject("searchOption", searchOption);
+ mav.addObject("searchKeyword", searchKeyword);
+
+ mav.addObject("myQnaList", list);
+ mav.setViewName("board/myQnaList/My Q&A");
+ return mav;
+ }
+
+ @RequestMapping("myQnaView.do")
+ public ModelAndView myQnaView(@RequestParam(value = "bno") int bno, int page, HttpSession session) throws Exception {
+ ModelAndView mav = new ModelAndView();
+
+ Qna qna = qnaService.qnaView(bno);
+
+ User user = (User) session.getAttribute("session_user");
+ String username = user.getUsername();
+ String qnaUsername = qna.getUsername();
+
+ if ( !(username.equals(qnaUsername)) ) {
+ mav.setViewName("board/myQnaDetailError/Error");
+ return mav;
+ }
+
+ mav.addObject("qna", qna);
+ mav.addObject("page", page);
+ mav.setViewName("board/myQnaDetail/나의 Q&A 상세보기");
+ return mav;
+ }
+
+ @RequestMapping(value = "qnaModify.do", method = RequestMethod.GET)
+ public ModelAndView qnaModifyForm(@RequestParam(value = "bno") int bno,
+ @RequestParam(value = "page") int page, HttpSession session, @RequestParam(value = "o", required = false) String searchOption,
+ @RequestParam(value = "k", required = false) String searchKeyword) throws Exception {
+
+ ModelAndView mav = new ModelAndView();
+
+ User user = (User) session.getAttribute("session_user");
+ Qna qna = qnaService.qnaView(bno);
+
+ if ( !qna.getUsername().equals(user.getUsername()) ) {
+ if ( searchKeyword != null ) {
+ searchKeyword = URLEncoder.encode(searchKeyword, "UTF-8"); // 한글이 깨져나오지 않게 하기 위한 처리
+ mav.setViewName("redirect:/board/myQnaView.do?page=" + page + "&o=" + searchOption + "&k=" + searchKeyword);
+ }
+ else
+ mav.setViewName("redirect:/board/myQnaView.do?page=" + page);
+
+ return mav;
+ }
+
+ mav.setViewName("board/qnaModify/Q&A 수정하기");
+ mav.addObject(qna);
+ mav.addObject("page", page);
+
+ return mav;
+ }
+
+ @RequestMapping(value = "qnaModify.do", method = RequestMethod.POST)
+ public ModelAndView qnaModify(Qna qna, int page,
+ String searchOption, String searchKeyword) throws Exception {
+
+ ModelAndView mav = new ModelAndView();
+
+ qnaService.qnaModify(qna);
+ mav.addObject(qna);
+
+ int bno = qna.getBno();
+
+ if ( searchKeyword != null ) {
+ searchKeyword = URLEncoder.encode(searchKeyword, "UTF-8"); // 한글이 깨져나오지 않게 하기 위한 처리
+ mav.setViewName("redirect:/board/myQnaView.do?bno=" + bno +"&page=" + page + "&o=" + searchOption + "&k=" + searchKeyword);
+ }
+ else
+ mav.setViewName("redirect:/board/myQnaView.do?bno=" + bno + "&page=" + page);
+
+ return mav;
+ }
+}
diff --git a/src/main/java/com/ustyle/controller/CartController.java b/src/main/java/com/ustyle/controller/CartController.java
new file mode 100644
index 0000000..4c10950
--- /dev/null
+++ b/src/main/java/com/ustyle/controller/CartController.java
@@ -0,0 +1,171 @@
+package com.ustyle.controller;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.inject.Inject;
+import javax.servlet.http.HttpSession;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+
+import com.ustyle.domain.Cart;
+import com.ustyle.domain.User;
+import com.ustyle.service.CartService;
+
+@Controller
+@RequestMapping("/cart/*")
+public class CartController {
+
+ private static final Logger logger = LoggerFactory.getLogger(CartController.class);
+
+ @Inject
+ private CartService cartService;
+
+ /**
+ * 상품의 상세페이지에서 옵션을 선택한 후 장바구니 추가 버튼을 눌렀을 때 호출되며, 호출 후 장바구니 페이지로 리다이렉션됨.
+ *
+ * @param cart
+ * @param session
+ * @return mav
+ * @throws Exception
+ */
+
+ @RequestMapping(value = "addCart.do", method = RequestMethod.POST)
+ public ModelAndView productToCart(@ModelAttribute Cart cart, HttpSession session) throws Exception {
+
+ ModelAndView mav = new ModelAndView();
+
+ User user = (User) session.getAttribute("session_user");
+ String username = user.getUsername();
+
+ if ( cartService.selectCartItemsCountForUsername(username) == 10 )
+ { // 장바구니에 담긴 상품이 10개인 경우, 장바구니에 담긴 상품을 빼도록 유도함
+ mav.setViewName("cart/addtoCartFail/상품 추가 오류");
+ return mav;
+ }
+
+ cart.setUsername(username);
+ logger.info(cart.toString());
+ cartService.insert(cart);
+ mav.setViewName("redirect:/cart/viewCart.do");
+ return mav;
+ }
+
+ /**
+ * 로그인한 회원의 장바구니 페이지를 조회함
+ *
+ * @param session
+ * @return mav
+ * @throws Exception
+ */
+
+ @RequestMapping(value = "viewCart.do", method = RequestMethod.GET)
+ public ModelAndView viewCart(HttpSession session) throws Exception {
+ User user = (User) session.getAttribute("session_user");
+
+ String username = user.getUsername();
+ logger.info("login User: " + username);
+
+ List> userCartInfoList = cartService.selectUserCartList(username);
+
+ int totalPrice = 0;
+
+ for ( HashMap map : userCartInfoList )
+ {
+ int eachPrice = (Integer) map.get("saleprice");
+ int eachCount = (Integer) map.get("count");
+
+ totalPrice += eachPrice * eachCount;
+
+ Iterator iterator = map.keySet().iterator();
+ while (iterator.hasNext()) {
+ String key = String.valueOf(iterator.next());
+ logger.info("key = " + key);
+ logger.info(" value = " + map.get(key));
+ }
+ }
+
+ logger.info("totalPrice = " + totalPrice);
+
+ ModelAndView mav = new ModelAndView("cart/viewCart/장바구니");
+ mav.addObject("userCartInfoList", userCartInfoList);
+ mav.addObject("cartCount", userCartInfoList.size());
+ mav.addObject("totalPrice", totalPrice);
+
+ return mav;
+
+ }
+
+ /**
+ * 장바구니에 있는 Item의 수량을 바꾼 후, 수정 버튼을 눌렀을 때 호출됨
+ *
+ * @param cart
+ * @return updatedItemCart
+ * @throws Exception
+ */
+
+ @ResponseBody
+ @RequestMapping(value = "updateCart.do", method = RequestMethod.POST)
+ public Cart updateCart(@RequestBody Cart cart) throws Exception {
+
+ cartService.update(cart);
+ int updatedCartno = cart.getCartno();
+
+ Cart updatedItemCart = cartService.selectUserCartOne(updatedCartno);
+
+ return updatedItemCart;
+ }
+
+ /**
+ * 장바구니에 있는 특정 Item을 삭제했을 때 호출됨
+ *
+ * @param cart
+ * @return deletedItemCart
+ * @throws Exception
+ */
+
+ @ResponseBody
+ @RequestMapping(value = "deleteCart.do", method = RequestMethod.POST)
+ public Cart deleteCart(@RequestBody Cart cart) throws Exception {
+
+ int deleteCartNo = cart.getCartno();
+
+ cartService.delete(deleteCartNo);
+
+ Cart deletedItemCart = cartService.selectUserCartOne(deleteCartNo);
+
+ return deletedItemCart;
+ }
+
+ /**
+ * 장바구니에 있는 모든 Item을 삭제할 때 호출됨
+ *
+ * @param session
+ * @return mav
+ * @throws Exception
+ */
+
+ @RequestMapping(value = "deleteAllCart.do", method = RequestMethod.POST)
+ public ModelAndView deleteAllCart(HttpSession session) throws Exception {
+
+ ModelAndView mav = new ModelAndView();
+
+ User user = (User) session.getAttribute("session_user");
+ String username = user.getUsername();
+
+ cartService.deleteAll(username);
+
+ mav.setViewName("redirect:/cart/viewCart.do");
+
+ return mav;
+ }
+}
diff --git a/src/main/java/com/ustyle/controller/CheckoutController.java b/src/main/java/com/ustyle/controller/CheckoutController.java
new file mode 100644
index 0000000..47062b6
--- /dev/null
+++ b/src/main/java/com/ustyle/controller/CheckoutController.java
@@ -0,0 +1,195 @@
+package com.ustyle.controller;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.inject.Inject;
+import javax.servlet.http.HttpSession;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+
+import com.ustyle.domain.Item;
+import com.ustyle.domain.Product;
+import com.ustyle.domain.Purchase;
+import com.ustyle.domain.Sales;
+import com.ustyle.domain.User;
+import com.ustyle.service.CartService;
+import com.ustyle.service.ItemService;
+import com.ustyle.service.ProductService;
+import com.ustyle.service.SalesService;
+import com.ustyle.service.UserService;
+
+@Controller
+@RequestMapping("/checkout/*")
+public class CheckoutController {
+
+ private static final Logger logger = LoggerFactory.getLogger(CheckoutController.class);
+ private static final int SHIPPING_PRICE = 3000;
+
+ @Inject
+ private UserService userService;
+
+ @Inject
+ private ProductService productService;
+
+ @Inject
+ private ItemService itemService;
+
+ @Inject
+ private CartService cartService;
+
+ @Inject
+ private SalesService salesService;
+
+ /**
+ * 장바구니 페이지에서 결제 버튼을 눌렀을 때 호출됨
+ *
+ * @param session
+ * @return mav
+ * @throws Exception
+ */
+
+ @ResponseBody
+ @RequestMapping(value = "checkout.do", method = RequestMethod.POST)
+ public ModelAndView checkout(HttpSession session) throws Exception {
+ ModelAndView mav = new ModelAndView("checkout/checkout/상품 결제");
+
+ User user = (User) session.getAttribute("session_user");
+ String username = user.getUsername();
+ logger.info("login User: " + username);
+
+ List> userSelectedItemidList = cartService.selectUserItemidList(username);
+
+ int totalPrice = 0; // 諛곗넚鍮꾨�� �젣�쇅�븳 媛�寃�
+ int shippingPrice = 0; // 諛곗넚鍮�
+ int finalPrice = 0; // 諛곗넚鍮꾨�� �룷�븿�븳 媛�寃�
+ int point = user.getPoint(); // �궗�슜�옄 �룷�씤�듃
+
+ for ( HashMap map : userSelectedItemidList )
+ {
+ Iterator iterator = map.keySet().iterator();
+ while (iterator.hasNext()) {
+ String key = String.valueOf(iterator.next());
+ logger.info("key = " + key);
+ logger.info(" value = " + map.get(key));
+ }
+
+ int eachItemid = (Integer) map.get("itemid");
+ int eachTotalCount = Integer.parseInt(String.valueOf(map.get("totalcount")));
+ // HashMap�쑝濡� 諛쏆쓣 �븣, MySQL sum �븿�닔瑜� �씠�슜�븳 媛믪쓣 int�삎�쑝濡� 諛쏆� 紐삵븯誘�濡�, �쐞�� 媛숈씠 String�쑝濡� 諛쏆� �썑 int濡� �떎�떆 蹂��솚�븯���떎.
+
+ Item eachItem = itemService.read(eachItemid);
+ int eachStock = eachItem.getStock();
+
+ if ( eachTotalCount > eachStock )
+ {
+ Product outofStockProduct = productService.read(eachItem.getProductid());
+ Item outofStockItem = eachItem;
+
+ String outofStockProductname = outofStockProduct.getProductname();
+ String outofStockColor = outofStockItem.getColor();
+ String outofStockSize = outofStockItem.getSize();
+
+ mav.addObject("outofStockProductname", outofStockProductname);
+ mav.addObject("outofStockColor", outofStockColor);
+ mav.addObject("outofStockSize", outofStockSize);
+ mav.addObject("maxStock", eachStock);
+
+ mav.setViewName("checkout/checkoutFail/결제 오류");
+ return mav;
+ }
+
+ int eachItemPrice = (Integer) map.get("saleprice");
+
+ totalPrice += ( eachItemPrice * eachTotalCount );
+ }
+
+ mav.addObject("userSelectedItemidList", userSelectedItemidList);
+
+ if ( totalPrice < 30000 )
+ {
+ finalPrice = totalPrice + SHIPPING_PRICE;
+ shippingPrice = SHIPPING_PRICE;
+ }
+ else
+ {
+ finalPrice = totalPrice;
+ shippingPrice = 0;
+ }
+
+ mav.addObject("totalPrice", totalPrice);
+ mav.addObject("shippingPrice", shippingPrice);
+ mav.addObject("finalPrice", finalPrice);
+ mav.addObject("point", point);
+
+ logger.info("TOTAL PRICE: " + totalPrice);
+
+ return mav;
+ }
+
+ /**
+ * 결제 페이지에서 배송지와 사용할 포인트를 입력한 후, 최종적으로 결제 버튼을 눌렀을 때 호출됨
+ *
+ * @param session
+ * @param purchase
+ * @param totalprice
+ * @return mav
+ * @throws Exception
+ */
+
+ @RequestMapping(value = "checkoutSuccess.do", method = RequestMethod.POST)
+ public ModelAndView checkoutSuccess(HttpSession session,
+ @ModelAttribute Purchase purchase, Integer totalprice) throws Exception {
+
+ ModelAndView mav = new ModelAndView("checkout/checkoutSuccess/결제 성공");
+
+ User user = (User) session.getAttribute("session_user");
+ String username = user.getUsername();
+
+ purchase.setUsername(username);
+
+ logger.info("FINAL PRICE = " + totalprice);
+ logger.info("BEFORE PURCHASE = " + purchase.toString());
+
+ double point_ratio = userService.selectUserPointRatio(username);
+ int addpoint = (int) (totalprice * point_ratio);
+ logger.info("ADD POINT = " + addpoint);
+
+ HashMap addPointMap = new HashMap();
+ addPointMap.put("username", username);
+ addPointMap.put("addpoint", addpoint);
+
+ salesService.updateAddPoint(addPointMap);
+ salesService.insertPurchase(purchase);
+
+ logger.info("AFTER PURCHASE = " + purchase.toString());
+
+ int purchaseid = purchase.getPurchaseid();
+
+ int pointAfterPurchase = userService.selectOneUser(username).getPoint();
+
+ session.setAttribute("session_userpoint", pointAfterPurchase);
+
+ List salesList = salesService.selectUserCartListForPurchase(username);
+
+ for ( Sales sales : salesList )
+ {
+ sales.setPurchaseid(purchaseid);
+ salesService.insert(sales);
+ logger.info("SALES = " + sales.toString());
+ }
+
+ cartService.deleteAll(username); // �옣諛붽뎄�땲 鍮꾩슦湲�
+
+ return mav;
+
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/ustyle/controller/CommonExceptionAdvice.java b/src/main/java/com/ustyle/controller/CommonExceptionAdvice.java
new file mode 100644
index 0000000..ea72c6e
--- /dev/null
+++ b/src/main/java/com/ustyle/controller/CommonExceptionAdvice.java
@@ -0,0 +1,23 @@
+package com.ustyle.controller;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.servlet.ModelAndView;
+
+@ControllerAdvice
+public class CommonExceptionAdvice
+{
+ private static final Logger logger = LoggerFactory.getLogger(CommonExceptionAdvice.class);
+
+ @ExceptionHandler(Exception.class)
+ public ModelAndView errorModelAndView(Exception e) {
+ ModelAndView mav = new ModelAndView();
+ mav.setViewName("error/errorCommon/Error");
+
+ logger.error("ERROR!!!", e); // 콘솔창에 예외 메시지, 예외 발생경로를 띄움.
+ return mav;
+ }
+
+}
diff --git a/src/main/java/com/ustyle/controller/HomeController.java b/src/main/java/com/ustyle/controller/HomeController.java
index f48b99b..bd6fef3 100644
--- a/src/main/java/com/ustyle/controller/HomeController.java
+++ b/src/main/java/com/ustyle/controller/HomeController.java
@@ -1,48 +1,31 @@
package com.ustyle.controller;
-import java.text.DateFormat;
-import java.util.Date;
-import java.util.Locale;
-
-import javax.inject.Inject;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
-import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
-import com.ustyle.service.UserService;
-import com.ustyle.utils.UserEntryValidator;
+import io.swagger.annotations.Api;
/**
* Handles requests for the application home page.
*/
+
@Controller
+@Api(value="swagger", description="swagger-test")
public class HomeController {
-
+
private static final Logger logger = LoggerFactory.getLogger(HomeController.class);
-
- @Inject
- private UserService service;
- @Inject
- private UserEntryValidator userEntryValidator;
- /**
- * Simply selects the home view to render by returning its name.
- */
+
@RequestMapping(value = "/", method = RequestMethod.GET)
- public String home(Locale locale, Model model) {
- logger.info("Welcome home! The client locale is {}.", locale);
-
- Date date = new Date();
- DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
-
- String formattedDate = dateFormat.format(date);
-
- model.addAttribute("serverTime", formattedDate );
-
- return "main/home/MAIN";
+ public String home() {
+ return "redirect:/index.do";
}
+ @RequestMapping(value="/swagger", method = RequestMethod.GET)
+ public String homePost(){
+ return "redirect:/swagger-ui.html";
+ }
+
}
diff --git a/src/main/java/com/ustyle/controller/ItemAdminController.java b/src/main/java/com/ustyle/controller/ItemAdminController.java
new file mode 100644
index 0000000..f95628e
--- /dev/null
+++ b/src/main/java/com/ustyle/controller/ItemAdminController.java
@@ -0,0 +1,256 @@
+package com.ustyle.controller;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.inject.Inject;
+import javax.validation.Valid;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+
+import com.ustyle.domain.Item;
+import com.ustyle.domain.Product;
+import com.ustyle.service.ItemService;
+import com.ustyle.service.ProductService;
+import com.ustyle.utils.PageMaker;
+
+@Controller
+@RequestMapping("/admin/item/*")
+public class ItemAdminController {
+
+ private static final Logger logger = LoggerFactory.getLogger(ItemAdminController.class);
+
+ @Inject
+ private ProductService productService;
+
+ @Inject
+ private ItemService itemService;
+
+ /**
+ * 관리자 페이지에서 특정 상품에 해당하는 Item을 추가하기 위한 페이지를 불러옴
+ *
+ * @param productid
+ * @return mav
+ * @throws Exception
+ */
+
+ @RequestMapping(value = "addItem.do", method = RequestMethod.GET)
+ public ModelAndView addItemForm(@RequestParam(value = "productid", required = false) Integer productid)
+ throws Exception {
+
+ ModelAndView mav = new ModelAndView("item/addItem");
+
+ Product product = productService.read(productid);
+
+ int originalprice = product.getOriginalprice();
+ int saleprice = product.getSaleprice();
+
+ mav.addObject("productid", productid);
+ mav.addObject("originalprice", originalprice);
+ mav.addObject("saleprice", saleprice);
+ return mav;
+ }
+
+ /**
+ * Item을 추가하는 페이지의 form을 이용하여 Item을 추가함
+ *
+ * @param item
+ * @return productList
+ * @throws Exception
+ */
+
+ @RequestMapping(value = "addItem.do", method = RequestMethod.POST)
+ public String addItem(@ModelAttribute @Valid Item item) throws Exception {
+
+ logger.info(item.toString());
+ itemService.insert(item);
+
+ return "redirect:/admin/product/productList.do";
+ }
+
+ /**
+ * 관리자 페이지에서 특정 옵션에 따른 검색을 통하여 그 조건에 맞는 Item을 호출함
+ *
+ * @param pageMaker
+ * @param searchOption
+ * @param searchKeyword
+ * @return mav
+ * @throws Exception
+ */
+
+ @RequestMapping("itemList.do")
+ public ModelAndView itemList(PageMaker pageMaker, @RequestParam(value = "o", required = false) String searchOption,
+ @RequestParam(value = "k", required = false) String searchKeyword) throws Exception {
+ ModelAndView mav = new ModelAndView();
+
+ if ( searchKeyword != null )
+ searchKeyword = searchKeyword.trim();
+
+ HashMap map = new HashMap();
+ int page = ( pageMaker.getPage() != null ) ? pageMaker.getPage() : 1;
+ pageMaker.setPage(page);
+
+ if ( searchKeyword == null || searchKeyword.trim() == "") {
+ List- list = new ArrayList
- ();
+ mav.addObject("itemList", list);
+ mav.setViewName("item/itemList");
+ return mav;
+ }
+
+ map.put("searchOption", searchOption);
+ map.put("searchKeyword", searchKeyword);
+ int totalCnt = itemService.selectListCnt(map); // DB연동_ 총 갯수 구해오기
+ int countPerPage = 10;
+ int countPerPaging = 5;
+
+ int first = ((pageMaker.getPage() - 1) * countPerPage) + 1;
+ int last = first + countPerPage - 1;
+ map.put("first", first);
+ map.put("last", last);
+ List
- list = itemService.itemList(map);
+ pageMaker.setCount(totalCnt, countPerPage, countPerPaging);
+ logger.info(list.toString());
+
+ mav.addObject("itemList", list);
+ mav.addObject("pageMaker", pageMaker);
+ mav.setViewName("item/itemList");
+ mav.addObject("searchOption", searchOption);
+ mav.addObject("searchKeyword", searchKeyword);
+
+ return mav;
+ }
+
+ /**
+ * Item 정보를 수정하기 위해 불러올 페이지를 호출함
+ * @param itemid
+ * @return mav
+ * @throws Exception
+ */
+
+ @RequestMapping(value = "modifyItem.do", method = RequestMethod.GET)
+ public ModelAndView modifyItemForm(@RequestParam("itemid") Integer itemid) throws Exception {
+ ModelAndView mav = new ModelAndView("item/modifyItem");
+
+ Item modifyItem = itemService.read(itemid);
+
+ logger.info(modifyItem.toString());
+
+ mav.addObject("item", modifyItem);
+ return mav;
+ }
+
+ /**
+ * Item 수정 페이지의 form을 이용하여 Item 수정 작업을 진행함
+ *
+ * @param item
+ * @return productList
+ * @throws Exception
+ */
+
+ @RequestMapping(value = "modifyItem.do", method = RequestMethod.POST)
+ public String modifyItem(@ModelAttribute @Valid Item item) throws Exception {
+ logger.info(item.toString());
+ itemService.update(item);
+ int productid = item.getProductid();
+ return "redirect:/admin/item/itemList.do?o=productid&k=" + productid;
+ }
+
+ @ResponseBody
+ @RequestMapping(value = "alreadyExistItem.do", method = RequestMethod.POST)
+ public ResponseEntity alreadyExistItem(@RequestBody Item item) throws Exception {
+ ResponseEntity entity = null;
+
+ boolean isExistItem = true;
+ System.out.println(item.toString());
+ try
+ {
+ isExistItem = itemService.existItem(item);
+
+ logger.info("IS EXIST ITEM = " + isExistItem);
+
+ if ( isExistItem == true ) {
+ entity = new ResponseEntity("FAIL", HttpStatus.OK);
+ }
+ else {
+ entity = new ResponseEntity("SUCCESS", HttpStatus.OK);
+ }
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ entity = new ResponseEntity(e.getMessage(), HttpStatus.BAD_REQUEST);
+ }
+
+ return entity;
+ }
+
+ @ResponseBody
+ @RequestMapping(value = "isDeleteItem.do", method = RequestMethod.POST)
+ public ResponseEntity isDeleteItem(@RequestBody Item item) throws Exception {
+
+ ResponseEntity entity = null;
+
+ int itemid = item.getItemid();
+ boolean isExistSalesTable = true;
+
+ try
+ {
+ isExistSalesTable = itemService.existSalesTable(itemid);
+
+ if ( isExistSalesTable == true ) {
+ entity = new ResponseEntity("FAIL", HttpStatus.OK);
+ }
+ else {
+ entity = new ResponseEntity("SUCCESS", HttpStatus.OK);
+ }
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ entity = new ResponseEntity(e.getMessage(), HttpStatus.BAD_REQUEST);
+ }
+
+ return entity;
+ }
+
+ /**
+ * 특정 Item을 삭제함
+ *
+ * @param itemid
+ * @return itemList 페이지
+ * @throws Exception
+ */
+
+ @ResponseBody
+ @RequestMapping(value = "deleteItem.do", method = RequestMethod.POST)
+ public ResponseEntity itemDelete(@RequestBody Item item) throws Exception {
+ int itemid = item.getItemid();
+ ResponseEntity entity = null;
+
+ try
+ {
+ logger.info("ITEM TO DELETE = " + item);
+ itemService.deleteItem(itemid);
+ entity = new ResponseEntity("SUCCESS", HttpStatus.OK);
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ entity = new ResponseEntity(e.getMessage(), HttpStatus.BAD_REQUEST);
+ }
+
+ return entity;
+ }
+}
diff --git a/src/main/java/com/ustyle/controller/PinController.java b/src/main/java/com/ustyle/controller/PinController.java
new file mode 100644
index 0000000..3645c01
--- /dev/null
+++ b/src/main/java/com/ustyle/controller/PinController.java
@@ -0,0 +1,380 @@
+package com.ustyle.controller;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.inject.Inject;
+import javax.servlet.http.HttpSession;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+
+import com.ustyle.domain.Pin;
+import com.ustyle.domain.PinBoard;
+import com.ustyle.domain.PinBoardLike;
+import com.ustyle.domain.PinBoardReply;
+import com.ustyle.domain.User;
+import com.ustyle.service.PinService;
+import com.ustyle.utils.PageMaker;
+
+@Controller
+@RequestMapping("/pin/*")
+public class PinController {
+
+ private static final Logger logger = LoggerFactory.getLogger(PinController.class);
+
+ @Inject
+ private PinService pinService;
+
+ @RequestMapping("pinBoardList.do")
+ public ModelAndView pinBoardList(@RequestParam(value = "pageCount", required = false) Integer pageCount,
+ HttpSession session) throws Exception {
+
+ PageMaker pageMaker = new PageMaker();
+
+ int page = ( pageCount != null ) ? pageCount.intValue() : 1;
+ pageMaker.setPage(page);
+
+ ModelAndView mav = new ModelAndView("pin/pinBoardList/PinBoard");
+
+ int totalCnt = pinService.selectListCnt(); // DB연동_ 총 갯수 구해오기
+
+ int countPerPaging = 10;
+ int pageCnt = 12; // 한 페이지당 12개씩 보이게 함.
+
+ pageMaker.setCount(totalCnt, pageCnt, countPerPaging);
+
+ HashMap map = new HashMap();
+
+ int first = ((pageMaker.getPage() - 1) * pageCnt) + 1;
+ int last = ( first + pageCnt - 1 > totalCnt ) ? totalCnt : first + pageCnt - 1;
+
+ map.put("first", first);
+ map.put("last", last);
+
+ List pinBoardList = pinService.selectPinBoardList(map);
+ logger.info(pinBoardList.toString());
+
+ mav.addObject("pinBoardList", pinBoardList);
+ mav.addObject("pageMaker", pageMaker);
+ mav.addObject("totalCnt", totalCnt);
+ mav.addObject("first", first);
+ mav.addObject("last", last);
+
+ return mav;
+ }
+
+ @RequestMapping("myPinBoardList.do")
+ public ModelAndView myPinBoardList(@RequestParam(value = "pageCount", required = false) Integer pageCount,
+ @RequestParam(value = "productid", required = false) Integer productid, HttpSession session) throws Exception {
+
+ PageMaker pageMaker = new PageMaker();
+
+ int page = ( pageCount != null ) ? pageCount.intValue() : 1;
+ pageMaker.setPage(page);
+
+ ModelAndView mav = new ModelAndView("pin/myPinBoardList/My PinBoard");
+ User user = (User) session.getAttribute("session_user");
+
+ String username = user.getUsername();
+
+ int totalCnt = pinService.selectListCntForUsername(username); // DB연동_ 총 갯수 구해오기
+ int countPerPaging = 10;
+ int pageCnt = 11; // 4 X 3 행렬에서 맨 위쪽에 있는 추가 버튼을 하나 제외하여 한 페이지당 11개씩 보이게 함.
+
+ pageMaker.setCount(totalCnt, pageCnt, countPerPaging);
+
+ HashMap map = new HashMap();
+
+ map.put("username", username);
+
+ int first = ((pageMaker.getPage() - 1) * pageCnt) + 1;
+ int last = ( first + pageCnt - 1 > totalCnt ) ? totalCnt : first + pageCnt - 1;
+
+ map.put("first", first);
+ map.put("last", last);
+
+ List pinBoardList = pinService.selectPinBoardList(map);
+ logger.info(pinBoardList.toString());
+
+ mav.addObject("pinBoardList", pinBoardList);
+ mav.addObject("pageMaker", pageMaker);
+ mav.addObject("totalCnt", totalCnt);
+ mav.addObject("first", first);
+ mav.addObject("last", last);
+ mav.addObject("productid", productid);
+ return mav;
+ }
+
+ @RequestMapping(value = "createPinBoard.do", method = RequestMethod.GET)
+ public String createPinBoardForm() throws Exception {
+ return "pin/createPinBoardForm/New Create Form";
+ }
+
+ @RequestMapping(value = "createPinBoard.do", method = RequestMethod.POST)
+ public String createPinBoard(HttpSession session, PinBoard pinBoard) throws Exception {
+ User user = (User) session.getAttribute("session_user");
+ pinBoard.setUsername(user.getUsername());
+ logger.info(pinBoard.toString());
+ pinService.createPinBoard(pinBoard);
+ return "redirect:/pin/myPinBoardList.do";
+ }
+
+ @RequestMapping(value = "modifyPinBoard.do", method = RequestMethod.GET)
+ public ModelAndView modifyPinBoardForm(HttpSession session, @RequestParam int pinboardno) throws Exception {
+
+ PinBoard pinBoard = pinService.getPinBoardByNo(pinboardno);
+
+ ModelAndView mav = new ModelAndView();
+
+ User user = (User) session.getAttribute("session_user");
+ String username = user.getUsername();
+ String pinBoardUsername = pinBoard.getUsername();
+
+ if ( !(pinBoardUsername.equals(username)) ) {
+ mav.setViewName("pin/updatePinBoardError/Update PinBoard Error");
+ return mav;
+ }
+
+ List> pinBoardProductList = pinService.selectPinBoardProductList(pinBoard.getPinboardno());
+
+ mav.setViewName("pin/updatePinBoardForm/Update PinBoard");
+ mav.addObject("pinBoard", pinBoard);
+ mav.addObject("pinBoardProductList", pinBoardProductList);
+
+ return mav;
+ }
+
+ @RequestMapping(value = "modifyPinBoard.do", method = RequestMethod.POST)
+ public String modifyPinBoard(PinBoard pinBoard) throws Exception {
+
+ logger.info(pinBoard.toString());
+ pinService.modifyPinBoard(pinBoard);
+ return "redirect:/pin/myPinBoardList.do";
+ }
+
+ @ResponseBody
+ @RequestMapping(value = "updatePinBoardPictureurl.do", method = RequestMethod.POST)
+ public ResponseEntity updatePinBoardPictureurl(@RequestBody PinBoard pinBoard) throws Exception {
+
+ ResponseEntity entity = null;
+
+ try
+ {
+ logger.info("PINBOARD TO CHANGEMAINIMAGE = " + pinBoard.toString());
+ pinService.updatePictureurl(pinBoard);
+ entity = new ResponseEntity("SUCCESS", HttpStatus.OK);
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ entity = new ResponseEntity(e.getMessage(), HttpStatus.BAD_REQUEST);
+ }
+
+ return entity;
+ }
+
+ @ResponseBody
+ @RequestMapping(value = "deletePinBoard.do", method = RequestMethod.POST)
+ public ResponseEntity deletePinBoard(@RequestBody PinBoard pinBoard) throws Exception {
+
+ ResponseEntity entity = null;
+
+ int pinboardno = pinBoard.getPinboardno();
+
+ try
+ {
+ logger.info("PINBOARDNUM TO DELETE = " + pinboardno);
+
+ pinService.deletePinBoard(pinboardno);
+ entity = new ResponseEntity("SUCCESS", HttpStatus.OK);
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ entity = new ResponseEntity(e.getMessage(), HttpStatus.BAD_REQUEST);
+ }
+
+ return entity;
+ }
+
+ @ResponseBody
+ @RequestMapping(value = "addLike.do", method = RequestMethod.POST)
+ public int addLike(@RequestBody PinBoardLike pinBoardLike) throws Exception {
+
+ logger.info("PINBOARDLIKE TO ADD = " + pinBoardLike.toString());
+
+ int pinboardno = pinBoardLike.getPinboardno();
+
+ pinService.plusLike(pinboardno);
+ pinService.addLikeList(pinBoardLike);
+
+ int selectLikeCnt = pinService.selectLikeCnt(pinboardno);
+
+ return selectLikeCnt;
+ }
+
+ @ResponseBody
+ @RequestMapping(value = "removeLike.do", method = RequestMethod.POST)
+ public int removeLike(@RequestBody PinBoardLike pinBoardLike) throws Exception {
+
+ logger.info("PINBOARDLIKE TO REMOVE = " + pinBoardLike.toString());
+
+ int pinboardno = pinBoardLike.getPinboardno();
+
+ pinService.minusLike(pinboardno);
+ pinService.removeLikeList(pinBoardLike);
+
+ int selectLikeCnt = pinService.selectLikeCnt(pinboardno);
+
+ return selectLikeCnt;
+ }
+
+// =======================================================================
+
+ @RequestMapping(value = "viewPinBoard.do", method = RequestMethod.GET)
+ public ModelAndView viewPinBoard(@RequestParam(value = "productid", required = false) Integer productid,
+ int pinboardno, HttpSession session) throws Exception {
+
+ ModelAndView mav = new ModelAndView("pinList");
+ List pinList = pinService.getPins(pinboardno);
+ PinBoard pinBoard = pinService.getPinBoardByNo(pinboardno);
+ List> pinBoardProductList = pinService.selectPinBoardProductList(pinboardno);
+ logger.info("=============" + pinList.toString());
+ logger.info("=============" + pinBoard.toString());
+
+ for ( HashMap map : pinBoardProductList )
+ {
+ Iterator iterator = map.keySet().iterator();
+ while (iterator.hasNext()) {
+ String key = String.valueOf(iterator.next());
+ logger.info("key = " + key);
+ logger.info(" value = " + map.get(key));
+ }
+ }
+
+ User user = (User) session.getAttribute("session_user");
+
+ if ( user != null ) {
+ String username = user.getUsername();
+
+ HashMap map = new HashMap();
+ map.put("pinboardno", pinboardno);
+ map.put("username", username);
+
+ boolean isCheckLike = pinService.checkLike(map); // 특정 PinBoard에 대한 좋아요를 체크했는지 확인하는 변수
+
+ mav.addObject("isCheckLike", isCheckLike);
+ mav.addObject("username", username);
+ }
+
+ mav.addObject(pinList);
+ mav.addObject("pinBoardProductList", pinBoardProductList);
+ mav.addObject(pinBoard);
+
+ if ( productid != null )
+ mav.addObject("productid", productid);
+
+ return mav;
+ }
+
+ @ResponseBody
+ @RequestMapping(value = "insertPin.do", method = RequestMethod.POST)
+ public ResponseEntity insertPin(@RequestBody Pin pin) {
+
+ ResponseEntity entity = null;
+
+ try
+ {
+ logger.info("PIN TO INSERT = " + pin.toString());
+
+ boolean isExistPin = pinService.existPin(pin); // 선택한 상품이 Pin으로 이미 추가되어있는지 체크함.
+
+ if ( isExistPin == true ) {
+ entity = new ResponseEntity("EXIST OF PIN", HttpStatus.OK);
+ }
+ else {
+ int pinboardno = pin.getPinboardno();
+
+ int totalPinCnt = pinService.selectPinCnt(pinboardno);
+ // 하나의 PinBoard에 Pin을 최대 4개까지만 넣을 수 있도록 함.
+
+ if ( totalPinCnt >= 4 ) {
+ entity = new ResponseEntity("EXCEED OF PIN", HttpStatus.OK);
+ }
+ else {
+ // Pin이 없는 PinBoard에 Pin을 추가하는 경우, 추가하는 Pin의 대표 이미지를 PinBoard의 대표 이미지로 넣음.
+ if ( totalPinCnt == 0 ) {
+ PinBoard updatePinBoard = new PinBoard();
+
+ updatePinBoard.setPinboardno(pinboardno);
+ updatePinBoard.setMainpictureproductid(pin.getProductid());
+
+ pinService.updatePictureurl(updatePinBoard);
+ }
+
+ pinService.insertPin(pin);
+ entity = new ResponseEntity("SUCCESS", HttpStatus.OK);
+ }
+ }
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ entity = new ResponseEntity(e.getMessage(), HttpStatus.BAD_REQUEST);
+ }
+
+ return entity;
+ }
+
+ @ResponseBody
+ @RequestMapping(value = "deletePin.do", method = RequestMethod.POST)
+ public ResponseEntity deletePin(@RequestBody Pin pin) throws Exception {
+
+ ResponseEntity entity = null;
+
+ try
+ {
+ logger.info("PIN TO DELETE = " + pin.toString());
+
+ pinService.deletePin(pin);
+
+ int pinboardno = pin.getPinboardno();
+
+ int mainPictureProductid = pinService.getPinBoardByNo(pinboardno).getMainpictureproductid();
+ int pinBoardProductid = pin.getProductid();
+
+ int totalPinCnt = pinService.selectPinCnt(pinboardno);
+
+ /* PinBoard에 있는 Pin이 하나도 없거나 삭제하려는 Pin이 PinBoard의 메인 이미지로 설정된 경우,
+ PinBoard의 이미지를 다시 기본 이미지로 바꿈. */
+ if ( totalPinCnt == 0 || mainPictureProductid == pinBoardProductid ) {
+ PinBoard updatePinBoard = new PinBoard();
+
+ updatePinBoard.setPinboardno(pinboardno);
+ updatePinBoard.setMainpictureproductid(0);
+
+ pinService.updatePictureurl(updatePinBoard);
+ }
+
+ entity = new ResponseEntity("SUCCESS", HttpStatus.OK);
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ entity = new ResponseEntity(e.getMessage(), HttpStatus.BAD_REQUEST);
+ }
+
+ return entity;
+ }
+}
diff --git a/src/main/java/com/ustyle/controller/ProductAdminController.java b/src/main/java/com/ustyle/controller/ProductAdminController.java
new file mode 100644
index 0000000..acf451f
--- /dev/null
+++ b/src/main/java/com/ustyle/controller/ProductAdminController.java
@@ -0,0 +1,256 @@
+package com.ustyle.controller;
+
+import java.net.URLEncoder;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.validation.Valid;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.validation.BindingResult;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+
+import com.ustyle.domain.Product;
+import com.ustyle.service.ProductService;
+import com.ustyle.utils.PageMaker;
+
+@Controller
+@RequestMapping("/admin/product/*")
+public class ProductAdminController {
+
+ private static final Logger logger = LoggerFactory.getLogger(ProductAdminController.class);
+
+ @Inject
+ private ProductService service;
+
+ @Resource(name="uploadPath")
+ private String uploadPath;
+
+ @RequestMapping(value = "addProduct.do", method = RequestMethod.GET)
+ public String addProductForm() {
+ return "product/addProduct";
+ }
+
+ @RequestMapping(value = "addProduct.do", method = RequestMethod.POST)
+ public ModelAndView addProduct(@ModelAttribute @Valid Product product, BindingResult bindingResult)
+ throws Exception {
+
+ String[] files = product.getFiles();
+
+ if ( files != null ) // 업로드할 상품의 이미지가 존재하는 경우
+ {
+ product.setMainpictureurl(files[0]); // 대표 이미지 추가
+
+ String filesStr = Arrays.toString(files);
+ product.setPictureurl(filesStr);
+ }
+
+ logger.info(product.toString());
+
+ ModelAndView mav = new ModelAndView("");
+
+ if (bindingResult.hasErrors()) {
+ mav.getModel().putAll(bindingResult.getModel());
+ mav.setViewName("product/addProduct");
+ return mav;
+ }
+
+ service.insert(product);
+ mav.setViewName("redirect:/admin/product/productList.do");
+ return mav;
+ }
+
+ @RequestMapping(value = "readProduct.do", method = RequestMethod.GET)
+ public String readProduct(@RequestParam("productid") Integer productid, @RequestParam("page") Integer page,
+ Model model) throws Exception
+ {
+ Product readProduct = service.read(productid);
+
+ logger.info(readProduct.toString());
+
+ model.addAttribute("product", readProduct);
+ model.addAttribute("page", page); // 목록으로 돌아갈 때, 페이지 번호를 유지시킴
+
+ return "product/readProduct";
+ }
+
+ @RequestMapping("readProductImage/{productid}")
+ @ResponseBody
+ public List readProductImage(@PathVariable("productid") Integer productid) throws Exception
+ {
+ String readPictureUrl = service.selectPictureurl(productid).replaceAll("\\[|\\]", "");
+ String[] imageFiles = readPictureUrl.split(", ");
+ List readPictureList = new ArrayList(Arrays.asList(imageFiles));
+
+ for ( String pictureUrl : readPictureList )
+ logger.info(pictureUrl.toString());
+
+ return readPictureList;
+ }
+
+ @RequestMapping(value = "modifyProduct.do", method = RequestMethod.GET)
+ public String modifyProductForm(@RequestParam("productid") Integer productid,
+ @RequestParam("page") Integer page, Model model) throws Exception {
+
+ Product modifyProduct = service.read(productid);
+
+ logger.info(modifyProduct.toString());
+
+ model.addAttribute("product", modifyProduct);
+ model.addAttribute("page", page); // 목록으로 돌아갈 때, 페이지 번호를 유지시킴
+
+ return "product/modifyProduct";
+ }
+
+ @RequestMapping(value = "modifyProduct.do", method = RequestMethod.POST)
+ public ModelAndView modifyProduct(@ModelAttribute @Valid Product product, int page,
+ String searchOption, String searchKeyword) throws Exception {
+
+ String[] files = product.getFiles();
+
+ if ( files != null ) // 업로드할 상품의 이미지가 존재하는 경우
+ {
+ product.setMainpictureurl(files[0]); // 대표 이미지 수정
+
+ String filesStr = Arrays.toString(files);
+ product.setPictureurl(filesStr);
+ }
+
+ logger.info(product.toString());
+
+ ModelAndView mav = new ModelAndView();
+
+ service.update(product);
+
+ int productid = product.getProductid();
+
+ if ( searchKeyword != null ) {
+ searchKeyword = URLEncoder.encode(searchKeyword, "UTF-8"); // 한글이 깨져나오지 않게 하기 위한 처리
+ mav.setViewName("redirect:/admin/product/readProduct.do?productid=" + productid +"&page=" + page + "&o=" + searchOption + "&k=" + searchKeyword);
+ }
+ else
+ mav.setViewName("redirect:/admin/product/readProduct.do?productid=" + productid + "&page=" + page);
+
+ mav.addObject(product);
+ return mav;
+ }
+
+ @RequestMapping("productList.do")
+ public ModelAndView productList(PageMaker pagemaker, @RequestParam(value = "o", required = false) String searchOption,
+ @RequestParam(value = "k", required = false) String searchKeyword) throws Exception {
+ ModelAndView mav = new ModelAndView();
+
+ if ( searchKeyword != null )
+ searchKeyword = searchKeyword.trim();
+
+ HashMap map = new HashMap();
+
+ int page = pagemaker.getPage() != null ? pagemaker.getPage() : 1;
+ pagemaker.setPage(page);
+ map.put("searchOption", searchOption);
+ map.put("searchKeyword", searchKeyword);
+
+ int totalCnt = service.selectListCnt(map); // DB연동_ 총 갯수 구해오기
+ int countPerPage = 10;
+ int countPerPaging = 5;
+
+ int first = ((pagemaker.getPage() - 1) * countPerPage) + 1;
+ int last = first + countPerPage - 1;
+ map.put("first", first);
+ map.put("last", last);
+
+ List list = service.productList(map);
+ pagemaker.setCount(totalCnt, countPerPage, countPerPaging);
+ logger.info(list.toString());
+
+ String temp = null;
+
+ for (int i = 0; i < list.size(); i++) {
+ temp = list.get(i).getPictureurl();
+
+ if (temp.length() < 50)
+ temp = "/ustylenone.jpg";
+ else
+ temp = temp.substring(1, 55);
+
+ list.get(i).setPictureurl(temp);
+ }
+
+ mav.addObject("productList", list);
+ mav.addObject("pageMaker", pagemaker);
+ mav.setViewName("product/productList");
+ mav.addObject("searchOption", searchOption);
+ mav.addObject("searchKeyword", searchKeyword);
+ mav.addObject("uploadPath", uploadPath);
+ return mav;
+ }
+
+ @ResponseBody
+ @RequestMapping(value = "isDeleteProduct.do", method = RequestMethod.POST)
+ public ResponseEntity isDeleteProduct(@RequestBody Product product) throws Exception {
+
+ ResponseEntity entity = null;
+
+ int productid = product.getProductid();
+ boolean isExistProduct = true;
+
+ try
+ {
+ isExistProduct = service.existSalesAndPinTable(productid);
+
+ if ( isExistProduct == true ) {
+ entity = new ResponseEntity("FAIL", HttpStatus.OK);
+ }
+ else {
+ entity = new ResponseEntity("SUCCESS", HttpStatus.OK);
+ }
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ entity = new ResponseEntity(e.getMessage(), HttpStatus.BAD_REQUEST);
+ }
+
+ return entity;
+ }
+
+ @ResponseBody
+ @RequestMapping(value = "deleteProduct.do", method = RequestMethod.POST)
+ public ResponseEntity productDelete(@RequestBody Product product) throws Exception {
+
+ ResponseEntity entity = null;
+
+ try
+ {
+ logger.info("PRODUCT TO DELETE = " + product);
+
+ int productid = product.getProductid();
+ service.delete(productid);
+ entity = new ResponseEntity("SUCCESS", HttpStatus.OK);
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ entity = new ResponseEntity(e.getMessage(), HttpStatus.BAD_REQUEST);
+ }
+
+ return entity;
+ // => product가 지워질 때, no action 제약조건으로 DB가 설계되었으므로, Service 단에서 product에 해당하는 item을 지우는 방향으로 진행
+ }
+}
diff --git a/src/main/java/com/ustyle/controller/ProductController.java b/src/main/java/com/ustyle/controller/ProductController.java
new file mode 100644
index 0000000..02ce913
--- /dev/null
+++ b/src/main/java/com/ustyle/controller/ProductController.java
@@ -0,0 +1,229 @@
+package com.ustyle.controller;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+
+import com.ustyle.domain.Item;
+import com.ustyle.domain.Product;
+import com.ustyle.service.ItemService;
+import com.ustyle.service.ProductService;
+import com.ustyle.utils.PageMaker;
+
+@Controller
+@RequestMapping("/product/*")
+public class ProductController {
+
+ private static final Logger logger = LoggerFactory.getLogger(ProductController.class);
+
+ @Inject
+ private ProductService productService;
+
+ @Inject
+ private ItemService itemService;
+
+ /**
+ * 특정 카테고리에 대한 상품 리스트를 불러옴(옵션에 따른 정렬 가능)
+ *
+ * @param pageCount
+ * @param countPerPage
+ * @param subcategory
+ * @param brand
+ * @param sortby
+ * @return mav
+ * @throws Exception
+ */
+
+ @RequestMapping(value = "productList.do", method = RequestMethod.GET)
+ public ModelAndView productList(@RequestParam(value = "pageCount", required = false) Integer pageCount,
+ @RequestParam(value = "countPerPage", required = false) Integer countPerPage,
+ @RequestParam(value = "subcategory", required = false) String subcategory,
+ @RequestParam(value = "brand", required = false) String brand,
+ @RequestParam(value = "sortby", defaultValue = "productid") String sortby) throws Exception {
+
+ PageMaker pageMaker = new PageMaker();
+
+ int page = ( pageCount != null ) ? pageCount.intValue() : 1;
+ pageMaker.setPage(page);
+
+ ModelAndView mav = new ModelAndView("product/productList/" + subcategory);
+
+ HashMap map = new HashMap();
+ map.put("subcategory", subcategory);
+ map.put("brand", brand);
+
+ int totalCnt = productService.selectListCntForSubcategory(map); // DB연동_ 총 갯수 구해오기
+
+ int countPerPaging = 10;
+
+ int pageCnt = ( countPerPage != null ) ? countPerPage.intValue() : 12;
+
+ pageMaker.setCount(totalCnt, pageCnt, countPerPaging);
+
+ logger.info("SORTBY = " + sortby);
+
+ int first = ((pageMaker.getPage() - 1) * pageCnt) + 1;
+ int last = ( first + pageCnt - 1 > totalCnt ) ? totalCnt : first + pageCnt - 1;
+
+ map.put("first", first);
+ map.put("last", last);
+ map.put("sortby", sortby);
+
+ List productList = productService.productListForSubcategory(map);
+ List> brandList = productService.brandListForSubcategory(subcategory);
+ List> subcategoryList = productService.subcategoryListForSubcategory(subcategory);
+ List> priceList = productService.priceRangeForSubcategory(subcategory);
+
+ logger.info(productList.toString());
+ mav.addObject("productList", productList);
+ mav.addObject("brandList", brandList);
+ mav.addObject("subcategoryList", subcategoryList);
+ mav.addObject("priceList", priceList);
+
+ mav.addObject("subcategory", subcategory);
+ mav.addObject("brand", brand);
+ mav.addObject("sortby", sortby);
+ mav.addObject("totalCnt", totalCnt);
+ mav.addObject("first", first);
+ mav.addObject("last", last);
+ mav.addObject("pageMaker", pageMaker);
+
+ return mav;
+ }
+
+ @RequestMapping(value = "searchProductList.do", method = RequestMethod.GET)
+ public ModelAndView searchProductList(@RequestParam(value = "pageCount", required = false) Integer pageCount,
+ @RequestParam(value = "countPerPage", required = false) Integer countPerPage,
+ @RequestParam(value = "productname", required = false) String productname,
+ @RequestParam(value = "sortby", defaultValue = "productid") String sortby) throws Exception {
+
+ PageMaker pageMaker = new PageMaker();
+
+ int page = ( pageCount != null ) ? pageCount.intValue() : 1;
+ pageMaker.setPage(page);
+
+ ModelAndView mav = new ModelAndView("product/searchProductList/검색 결과");
+
+ HashMap map = new HashMap();
+ map.put("productname", productname);
+
+ int totalCnt = productService.selectListCntForProductname(map); // DB연동_ 총 갯수 구해오기
+
+ int countPerPaging = 10;
+
+ int pageCnt = ( countPerPage != null ) ? countPerPage.intValue() : 12;
+
+ pageMaker.setCount(totalCnt, pageCnt, countPerPaging);
+
+ logger.info("PRODUCTNAME TO SEARCH = " + productname);
+ logger.info("SORTBY = " + sortby);
+
+ int first = ((pageMaker.getPage() - 1) * pageCnt) + 1;
+ int last = ( first + pageCnt - 1 > totalCnt ) ? totalCnt : first + pageCnt - 1;
+
+ map.put("first", first);
+ map.put("last", last);
+ map.put("sortby", sortby);
+
+ List productList = productService.productListForProductname(map);
+ System.out.println(totalCnt);
+ logger.info(productList.toString());
+ mav.addObject("productList", productList);
+ mav.addObject("sortby", sortby);
+ mav.addObject("totalCnt", totalCnt);
+ mav.addObject("first", first);
+ mav.addObject("last", last);
+ mav.addObject("pageMaker", pageMaker);
+
+ return mav;
+ }
+
+ /**
+ * 상품 상세정보를 상세페이지에 불러옴
+ *
+ * @param productid
+ * @return mav
+ * @throws Exception
+ */
+
+ @RequestMapping(value = "productDetail.do", method = RequestMethod.GET)
+ public ModelAndView productDetail(@RequestParam(value = "productid", required = false)
+ Integer productid) throws Exception {
+
+ Product product = productService.read(productid);
+
+ ModelAndView mav = new ModelAndView("product/productDetail/" + product.getProductname());
+
+ String mainPictureurl = product.getMainpictureurl();
+ product.setMainpictureurl(mainPictureurl.replace("/s_", "/"));
+
+ String readPictureurl = product.getPictureurl().replaceAll("\\[|\\]", "");
+ String[] imageFiles = readPictureurl.split(", ");
+ List pictureList = new ArrayList(Arrays.asList(imageFiles));
+
+ logger.info(product.toString());
+
+ List itemColorList = itemService.selectColorList(productid); // 상품의 색상을 리스트로 가져옴
+
+ int totalItemNum = itemService.totalItem(productid); // 하나의 상품에 속하는 아이템의 총 개수
+
+ mav.addObject("product", product);
+ mav.addObject("totalItemNum", totalItemNum);
+ mav.addObject("pictureList", pictureList);
+ mav.addObject("itemColorList", itemColorList);
+
+ return mav;
+ }
+
+ /**
+ * 선택된 색상에 해당하는 Item 객체 리스트를 가져옴
+ *
+ * @param selectedColorItem
+ * @return selectedColorItemList
+ * @throws Exception
+ */
+
+ @ResponseBody
+ @RequestMapping(value = "selectedColor.do", method = RequestMethod.POST)
+ public List
- selectedColorAjax(@RequestBody Item selectedColorItem) throws Exception {
+
+ List
- selectedColorItemList = itemService.selectedColorItemList(selectedColorItem);
+
+ for ( Item eachItem : selectedColorItemList )
+ logger.info(eachItem.toString());
+
+ return selectedColorItemList;
+ }
+
+ /**
+ * 선택된 색상, 사이즈에 해당하는 Item 객체 한 개를 가져옴
+ *
+ * @param selectedSizeItem
+ * @return selectedColorSizeItem
+ * @throws Exception
+ */
+
+ @ResponseBody
+ @RequestMapping(value = "selectedSize.do", method = RequestMethod.POST)
+ public Item selectedSizeAjax(@RequestBody Item selectedSizeItem) throws Exception {
+
+ Item selectedColorSizeItem = itemService.selectedColorSizeItem(selectedSizeItem);
+
+ logger.info(selectedColorSizeItem.toString());
+
+ return selectedColorSizeItem;
+ }
+}
diff --git a/src/main/java/com/ustyle/controller/ReviewController.java b/src/main/java/com/ustyle/controller/ReviewController.java
new file mode 100644
index 0000000..be573ff
--- /dev/null
+++ b/src/main/java/com/ustyle/controller/ReviewController.java
@@ -0,0 +1,121 @@
+package com.ustyle.controller;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.ustyle.domain.Review;
+import com.ustyle.service.ReviewService;
+import com.ustyle.utils.PageMaker;
+
+@RestController
+@RequestMapping("/reviews")
+public class ReviewController
+{
+ private static final Logger logger = LoggerFactory.getLogger(ReviewController.class);
+
+ @Inject
+ private ReviewService service;
+
+ /**
+ * 상품 리뷰를 추가할 때 호출되는 메소드
+ * @param review
+ * @return entity
+ */
+
+ @RequestMapping(value = "", method = RequestMethod.POST)
+ public ResponseEntity register(@RequestBody Review review)
+ {
+ ResponseEntity entity = null;
+
+ try
+ {
+ String username = review.getUsername();
+ int productid = review.getProductid();
+
+ HashMap reviewMap = new HashMap();
+ reviewMap.put("username", username);
+ reviewMap.put("productid", productid);
+
+ boolean isExistReview = service.existReview(reviewMap);
+
+ if ( isExistReview == true ) {
+ entity = new ResponseEntity("FAIL", HttpStatus.OK);
+ }
+ else {
+ service.writeReview(review);
+ entity = new ResponseEntity("SUCCESS", HttpStatus.OK);
+ }
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ entity = new ResponseEntity(e.getMessage(), HttpStatus.BAD_REQUEST);
+ }
+
+ return entity;
+ }
+
+ /**
+ * 한 페이지당 상품 리뷰를 다섯개씩 보여주는 메소드
+ * @param productid
+ * @param page
+ * @return entity
+ */
+
+ @RequestMapping(value = "/{productid}/{page}", method = RequestMethod.GET)
+ public ResponseEntity