fix(log): log-datasources List 返回 {list,total} 格式对齐前端期望
前端 logCenterApi.listDatasources 期望 res.list 数组,但后端 List handler 返回裸数组导致前端取 res?.list 为 undefined。改为 model.ListResponse 对齐 项目其他列表端点的惯例格式。
This commit is contained in:
1 parent
5fb74a787a
commit
7ed4ce8d3a
1 file changed
+2
-1
@@ -40,7 +40,8 @@ func (h *LogDSHandler) List(c *gin.Context) {
|
|||||||
if sources == nil {
|
if sources == nil {
|
||||||
sources = []model.LogDataSource{}
|
sources = []model.LogDataSource{}
|
||||||
}
|
}
|
||||||
c.JSON(200, model.Response{Code: 200, Data: sources})
|
// 按项目惯例返回 {list,total},前端 listDatasources 取 .list // Logan.Li
|
||||||
|
c.JSON(200, model.Response{Code: 200, Data: model.ListResponse{List: sources, Total: int64(len(sources))}})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get GET /api/v1/log-datasources/:id
|
// Get GET /api/v1/log-datasources/:id
|
||||||
|
|||||||
Reference in new issue
Block a user