Kaynağa Gözat

Merge branch 'develop' into jmh

jmh 4 yıl önce
ebeveyn
işleme
4e022473f5

+ 0 - 96
src/main/java/com/style24/front/support/controller/TsfCustomErrorController.java

@@ -1,96 +0,0 @@
-package com.style24.front.support.controller;
-
-import java.io.IOException;
-import java.util.Map;
-
-import javax.servlet.RequestDispatcher;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.springframework.boot.autoconfigure.web.servlet.error.AbstractErrorController;
-import org.springframework.boot.web.error.ErrorAttributeOptions;
-import org.springframework.boot.web.servlet.error.ErrorAttributes;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
-import org.springframework.mobile.device.Device;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.servlet.ModelAndView;
-
-import com.style24.front.support.util.ViewUtils;
-
-import lombok.extern.slf4j.Slf4j;
-
-/**
- * Custom Error Controller
- * 		Disabling the Whitelabel Error Page
- * 		- application.yml 파일에 다음을 추가
- * 			server.error.path='/error'
- * 			server.error.whitelabel.enabled=false
- * 
- * @author gagamel
- * @since 2020. 9. 11
- */
-@Controller
-@RequestMapping("${server.error.path:${error.path:/error}}")
-@Slf4j
-public class TsfCustomErrorController extends AbstractErrorController {
-
-	public TsfCustomErrorController(ErrorAttributes errorAttributes) {
-		super(errorAttributes);
-	}
-
-	@Override
-	public String getErrorPath() {
-		return this.getErrorPath();
-	}
-
-	/**
-	 * HTML로 응답을 주는 경우의 처리
-	 * @param request - HttpServletRequest
-	 * @param response - HttpServletResponse
-	 * @return
-	 * @throws IOException
-	 */
-	@RequestMapping(produces = MediaType.TEXT_HTML_VALUE)
-	public ModelAndView errorHtml(HttpServletRequest request, HttpServletResponse response, Device device) throws IOException {
-		HttpStatus status = this.getStatus(request);
-		log.error("status.value(): {}", status.value());
-
-		Map<String, Object> model = this.getErrorAttributes(request, ErrorAttributeOptions.defaults());
-
-		response.setStatus(status.value());
-		ModelAndView mav = this.resolveErrorView(request, response, status, model);
-
-		if (status.value() == HttpStatus.NOT_FOUND.value()) {
-			return (mav != null) ? mav : new ModelAndView(ViewUtils.getDeviceViewName("error/404"), model);
-		}
-
-		Object oExceptionType = request.getAttribute(RequestDispatcher.ERROR_EXCEPTION_TYPE);
-		if (oExceptionType != null) {
-			String exceptionType = oExceptionType.toString();
-			log.error("ERROR_EXCEPTION_TYPE: {}", exceptionType);
-
-			// Thymeleaf의 HTML 파일을 못 찾는 에러는 "org.thymeleaf.exceptions.TemplateInputException"임.
-			if (exceptionType.endsWith("org.thymeleaf.exceptions.TemplateInputException")) {
-				return (mav != null) ? mav : new ModelAndView(ViewUtils.getDeviceViewName("error/404"), model);
-			}
-		}
-
-		return (mav != null) ? mav : new ModelAndView(ViewUtils.getDeviceViewName("error/500"), model);
-	}
-
-	/**
-	 * HTML 외의 응답이 필요한 경우의 처리
-	 * @param request - HttpServletRequest
-	 * @return
-	 */
-	@RequestMapping
-	public ResponseEntity<Map<String, Object>> error(HttpServletRequest request) {
-		Map<String, Object> body = this.getErrorAttributes(request, ErrorAttributeOptions.defaults());
-		HttpStatus status = this.getStatus(request);
-		return new ResponseEntity<>(body, status);
-	}
-
-}

+ 63 - 0
src/main/java/com/style24/front/support/controller/TsfErrorController.java

@@ -0,0 +1,63 @@
+package com.style24.front.support.controller;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.http.HttpServletRequest;
+
+import org.springframework.boot.web.servlet.error.ErrorController;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.HttpRequestMethodNotSupportedException;
+import org.springframework.web.bind.annotation.GetMapping;
+
+import com.style24.front.support.util.ViewUtils;
+
+import lombok.extern.slf4j.Slf4j;
+
+import com.gagaframework.web.rest.server.GagaResponseStatus;
+
+/**
+ * Error Controller
+ * 		Disabling the Whitelabel Error Page
+ * 		- application.yml 파일에 다음을 추가
+ * 			server.error.path: /error
+ * 			server.error.whitelabel.enabled: false
+ * 
+ * @author gagamel
+ * @since 2020. 9. 11
+ */
+@Controller
+@Slf4j
+public class TsfErrorController implements ErrorController {
+
+	/**
+	 * 이 메서드는 스프링 부트 2.3.x부터 deprecated됨.
+	 * 이 메서드 대신 custom path를 지정하려면 server.error.path 속성으로 지정해야 한다.
+	 */
+	@Override
+	public String getErrorPath() {
+		return null;
+	}
+
+	/**
+	 * Error
+	 */
+	@GetMapping("/error")
+	public String error(HttpServletRequest request) throws HttpRequestMethodNotSupportedException {
+		Object status = request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE);
+
+		if (status != null) {
+			Integer statusCode = Integer.valueOf(status.toString());
+			log.error("Error StatusCode: {}", statusCode);
+
+			if (statusCode == GagaResponseStatus.NOT_FOUND.getCode()) {
+				return ViewUtils.getDeviceViewName("error/404");
+			}
+		}
+
+		;
+
+		log.error("Error Message: {}", request.getAttribute(RequestDispatcher.ERROR_MESSAGE));
+
+		return ViewUtils.getDeviceViewName("error/500");
+	}
+
+}

+ 9 - 7
src/main/java/com/style24/persistence/mybatis/shop/TsfCounsel.xml

@@ -310,13 +310,15 @@
 	<select id="getGoodsQnaCountInfo" parameterType="Counsel" resultType="Counsel">
 		/* TsfCounsel.getGoodsQnaCountInfo */
 		SELECT COUNT(*)                                              AS TOT_CNT /*총건수*/
-		     , SUM(CASE WHEN ANS_STAT = 'G060_20' THEN 1 ELSE 0 END) AS ANS_CNT /*답변완료건수*/
-		     , SUM(CASE WHEN ANS_STAT = 'G060_10' THEN 1 ELSE 0 END) AS ING_CNT /*처리중건수*/
-		FROM   TB_COUNSEL
-		WHERE  CUST_NO = #{custNo}
-		AND    SITE_CD = #{siteCd}
-		AND    COUNSEL_TYPE = 'G' /*상담유형(상품문의)*/
-		AND    DEL_YN = 'N' /*삭제안된넘*/
+		     , SUM(CASE WHEN A.ANS_STAT = 'G060_20' THEN 1 ELSE 0 END) AS ANS_CNT /*답변완료건수*/
+		     , SUM(CASE WHEN A.ANS_STAT = 'G060_10' THEN 1 ELSE 0 END) AS ING_CNT /*처리중건수*/
+		FROM   TB_COUNSEL A
+		INNER  JOIN TB_GOODS G
+		ON     A.REL_GOODS_CD = G.GOODS_CD
+		WHERE  A.CUST_NO = #{custNo}
+		AND    A.SITE_CD = #{siteCd}
+		AND    A.COUNSEL_TYPE = 'G' /*상담유형(상품문의)*/
+		AND    A.DEL_YN = 'N' /*삭제안된넘*/
 	</select>
 	
 	<!-- 상품문의 총건수 -->

+ 4 - 4
src/main/resources/config/application.yml

@@ -16,18 +16,18 @@ spring:
         redis:
             repositories:
                 enabled: true
-#    mvc.throw-exception-if-no-handler-found: true
-
+     
 server.site.name: front
 
 server:
+    error:
+        path: /error # 오류 응답을 처리할 Handler의 경로
+        whitelabel.enabled: false
 #    servlet:
 #        session:
 #            cookie:
 #                name: WSESSIONID
 #                secure: true
-    error.path: '/error' # 오류 응답을 처리할 Handler의 경로
-    error.whitelabel.enabled: false
 
 # 본인인증
 certify: