feat: add PostgreSQL web installation wizard
Signed Release / release (push) Failing after 5m1s

This commit is contained in:
Qiufeng
2026-08-04 07:42:20 +08:00
parent b714f9851e
commit 1affcd9a5e
61 changed files with 1992 additions and 431 deletions
@@ -1,19 +1,41 @@
package com.kaidi.oa.web;
import com.kaidi.oa.common.ApiResp;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Map;
/** Liveness probe. */
/** Readiness probe used by the installer and online-update rollback gate. */
@RestController
@RequestMapping("/api/oa")
public class HealthController {
private final DataSource dataSource;
public HealthController(DataSource dataSource) {
this.dataSource = dataSource;
}
@GetMapping("/health")
public ApiResp<Map<String, String>> health() {
return ApiResp.ok(Map.of("status", "UP"));
public ResponseEntity<ApiResp<Map<String, String>>> health() {
try (Connection connection = dataSource.getConnection();
Statement statement = connection.createStatement();
ResultSet result = statement.executeQuery("SELECT 1")) {
if (connection.isValid(2) && result.next() && result.getInt(1) == 1) {
return ResponseEntity.ok(ApiResp.ok(Map.of("status", "UP", "database", "UP")));
}
} catch (Exception ignored) {
// Health responses deliberately avoid exposing connection details.
}
return ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE)
.body(new ApiResp<>(50301, "database unavailable", Map.of("status", "DOWN", "database", "DOWN")));
}
}