@@ -1,6 +1,7 @@
|
|||||||
package com.cloudhandson.vpdbackoffice.web;
|
package com.cloudhandson.vpdbackoffice.web;
|
||||||
|
|
||||||
import com.cloudhandson.vpdbackoffice.service.AppException;
|
import com.cloudhandson.vpdbackoffice.service.AppException;
|
||||||
|
import org.springframework.dao.DataAccessException;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
@@ -13,4 +14,16 @@ public class AppExceptionHandler {
|
|||||||
model.addAttribute("errorMessage", exception.getMessage());
|
model.addAttribute("errorMessage", exception.getMessage());
|
||||||
return "error";
|
return "error";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ExceptionHandler(DataAccessException.class)
|
||||||
|
public String handleDataAccessException(DataAccessException exception, Model model) {
|
||||||
|
String detail = exception.getMostSpecificCause() == null
|
||||||
|
? exception.getMessage()
|
||||||
|
: exception.getMostSpecificCause().getMessage();
|
||||||
|
model.addAttribute("errorTitle", "ADB 연결 설정이 필요합니다.");
|
||||||
|
model.addAttribute("errorMessage",
|
||||||
|
"BACKOFFICE_DB_URL, BACKOFFICE_DB_USERNAME, BACKOFFICE_DB_PASSWORD를 실제 ADB 값으로 설정하고 "
|
||||||
|
+ "./run.sh backoffice-support를 실행한 뒤 다시 시도하세요. 상세: " + detail);
|
||||||
|
return "error";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package com.cloudhandson.vpdbackoffice.web;
|
|||||||
import com.cloudhandson.vpdbackoffice.service.BearerTokenService;
|
import com.cloudhandson.vpdbackoffice.service.BearerTokenService;
|
||||||
import com.cloudhandson.vpdbackoffice.service.PermissionService;
|
import com.cloudhandson.vpdbackoffice.service.PermissionService;
|
||||||
import com.cloudhandson.vpdbackoffice.service.ProtectedObjectService;
|
import com.cloudhandson.vpdbackoffice.service.ProtectedObjectService;
|
||||||
|
import java.util.List;
|
||||||
|
import org.springframework.dao.DataAccessException;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@@ -26,9 +28,23 @@ public class DashboardController {
|
|||||||
|
|
||||||
@GetMapping("/")
|
@GetMapping("/")
|
||||||
public String dashboard(Model model) {
|
public String dashboard(Model model) {
|
||||||
model.addAttribute("objects", protectedObjectService.findEnabled());
|
try {
|
||||||
model.addAttribute("roles", permissionService.findRoles());
|
model.addAttribute("objects", protectedObjectService.findEnabled());
|
||||||
model.addAttribute("tokens", bearerTokenService.findAll());
|
model.addAttribute("roles", permissionService.findRoles());
|
||||||
|
model.addAttribute("tokens", bearerTokenService.findAll());
|
||||||
|
} catch (DataAccessException e) {
|
||||||
|
model.addAttribute("objects", List.of());
|
||||||
|
model.addAttribute("roles", List.of());
|
||||||
|
model.addAttribute("tokens", List.of());
|
||||||
|
model.addAttribute("setupError", dbSetupMessage(e));
|
||||||
|
}
|
||||||
return "dashboard";
|
return "dashboard";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String dbSetupMessage(DataAccessException e) {
|
||||||
|
String detail = e.getMostSpecificCause() == null ? e.getMessage() : e.getMostSpecificCause().getMessage();
|
||||||
|
return "ADB 연결을 확인할 수 없습니다. BACKOFFICE_DB_URL, BACKOFFICE_DB_USERNAME, "
|
||||||
|
+ "BACKOFFICE_DB_PASSWORD를 설정하고 ./run.sh backoffice-support를 먼저 실행하세요. 상세: "
|
||||||
|
+ detail;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,14 @@
|
|||||||
<p>보호 객체, Bearer Token, ORDS 검증 상태를 확인합니다.</p>
|
<p>보호 객체, Bearer Token, ORDS 검증 상태를 확인합니다.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="alert alert-warning" th:if="${setupError}">
|
||||||
|
<div class="fw-semibold">DB 연결 설정이 필요합니다.</div>
|
||||||
|
<div th:text="${setupError}"></div>
|
||||||
|
<div class="mt-2">
|
||||||
|
<code>./run.sh backoffice-support</code>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<section class="summary-grid">
|
<section class="summary-grid">
|
||||||
<a class="summary-tile" href="/permissions">
|
<a class="summary-tile" href="/permissions">
|
||||||
<span class="label">보호 객체</span>
|
<span class="label">보호 객체</span>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<nav th:replace="~{fragments/layout :: nav}"></nav>
|
<nav th:replace="~{fragments/layout :: nav}"></nav>
|
||||||
<main class="container py-4">
|
<main class="container py-4">
|
||||||
<div class="alert alert-danger">
|
<div class="alert alert-danger">
|
||||||
<strong>처리할 수 없습니다.</strong>
|
<strong th:text="${errorTitle} ?: '처리할 수 없습니다.'">처리할 수 없습니다.</strong>
|
||||||
<span th:text="${errorMessage} ?: '요청 처리 중 오류가 발생했습니다.'"></span>
|
<span th:text="${errorMessage} ?: '요청 처리 중 오류가 발생했습니다.'"></span>
|
||||||
</div>
|
</div>
|
||||||
<a class="btn btn-outline-primary" href="/">대시보드</a>
|
<a class="btn btn-outline-primary" href="/">대시보드</a>
|
||||||
|
|||||||
Reference in New Issue
Block a user