[Developer] #424 show DB setup errors

Refs #424
This commit is contained in:
devmrko
2026-06-23 11:12:07 +09:00
parent 7b45b3a028
commit fe8baa4d6a
4 changed files with 41 additions and 4 deletions

View File

@@ -3,6 +3,8 @@ package com.cloudhandson.vpdbackoffice.web;
import com.cloudhandson.vpdbackoffice.service.BearerTokenService;
import com.cloudhandson.vpdbackoffice.service.PermissionService;
import com.cloudhandson.vpdbackoffice.service.ProtectedObjectService;
import java.util.List;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
@@ -26,9 +28,23 @@ public class DashboardController {
@GetMapping("/")
public String dashboard(Model model) {
model.addAttribute("objects", protectedObjectService.findEnabled());
model.addAttribute("roles", permissionService.findRoles());
model.addAttribute("tokens", bearerTokenService.findAll());
try {
model.addAttribute("objects", protectedObjectService.findEnabled());
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";
}
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;
}
}