feat[Go]: implement /api/v1/system/status GET (#15348)

### What problem does this PR solve?

As title

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
- [x] New Feature (non-breaking change which adds functionality)
- [x] Refactoring
This commit is contained in:
Haruko386
2026-05-29 10:12:12 +08:00
committed by GitHub
parent 58eb957c30
commit 834236a3ec
7 changed files with 259 additions and 2 deletions

View File

@@ -173,6 +173,9 @@ func (h *ConnectorHandler) ListLogs(c *gin.Context) {
jsonError(c, code, err.Error())
return
}
if logs == nil {
logs = []*entity.ConnectorSyncLog{}
}
c.JSON(http.StatusOK, gin.H{
"code": common.CodeSuccess,

View File

@@ -199,6 +199,7 @@ func TestConnectorHandlerListLogs(t *testing.T) {
wantMsg string
wantTotal float64
wantLogID string
wantLogs int
}{
{
name: "success",
@@ -225,6 +226,17 @@ func TestConnectorHandlerListLogs(t *testing.T) {
wantCode: common.CodeSuccess,
wantTotal: 1,
wantLogID: "log-1",
wantLogs: 1,
},
{
name: "empty logs",
service: fakeConnectorService{
logs: nil,
total: 0,
},
wantCode: common.CodeSuccess,
wantTotal: 0,
wantLogs: 0,
},
{
name: "unauthorized",
@@ -266,10 +278,23 @@ func TestConnectorHandlerListLogs(t *testing.T) {
t.Fatalf("total=%v body=%v", data["total"], body)
}
logs := data["logs"].([]interface{})
if len(logs) != tt.wantLogs {
t.Fatalf("logs=%v body=%v", logs, body)
}
if logs[0].(map[string]interface{})["id"] != tt.wantLogID {
t.Fatalf("logs=%v body=%v", logs, body)
}
}
if tt.wantLogID == "" && tt.wantMsg == "" {
data := body["data"].(map[string]interface{})
if data["total"] != tt.wantTotal {
t.Fatalf("total=%v body=%v", data["total"], body)
}
logs := data["logs"].([]interface{})
if len(logs) != tt.wantLogs {
t.Fatalf("logs=%v body=%v", logs, body)
}
}
})
}
}

View File

@@ -115,6 +115,27 @@ func (h *SystemHandler) GetConfigs(c *gin.Context) {
})
}
// GetStatus get RAGFlow status
func (h *SystemHandler) GetStatus(c *gin.Context) {
_, errorCode, errorMessage := GetUser(c)
if errorCode != common.CodeSuccess {
jsonError(c, errorCode, errorMessage)
return
}
status, err := h.systemService.GetStatus()
if err != nil {
jsonError(c, common.CodeServerError, err.Error())
return
}
c.JSON(http.StatusOK, gin.H{
"code": common.CodeSuccess,
"data": status,
"message": "success",
})
}
// GetVersion get RAGFlow version
// @Summary Get RAGFlow Version
// @Description Get the current version of the application