From 310c528ea499d5811a93be5294801642445f5c82 Mon Sep 17 00:00:00 2001 From: simonzhangsz Date: Mon, 9 Sep 2024 17:24:38 +0800 Subject: [PATCH] fix: return code to FE issue --- features/lm/file_export/controller.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/features/lm/file_export/controller.go b/features/lm/file_export/controller.go index 9ce7fdff..d5610fff 100644 --- a/features/lm/file_export/controller.go +++ b/features/lm/file_export/controller.go @@ -38,7 +38,7 @@ func (m *SysJob) GetFileExportTable(c *gin.Context) { err := datasource.DefaultDB().Table(m.TableName()).Where("invoke_target=? and status=1", INVOKE_FILE_EXPORT). Find(&results).Error if err != nil { - c.JSON(http.StatusInternalServerError, services.ErrResp(err.Error())) + c.JSON(http.StatusOK, services.ErrResp(err.Error())) return } language := ctx.AcceptLanguage(c) @@ -46,7 +46,7 @@ func (m *SysJob) GetFileExportTable(c *gin.Context) { for _, job := range results { var params TargetParams if err := json.Unmarshal([]byte(job.TargetParams), ¶ms); err != nil { - c.JSON(http.StatusInternalServerError, services.ErrResp(err.Error())) + c.JSON(http.StatusOK, services.ErrResp(err.Error())) return } TableDisplay := i18n.TKey(language, "table."+params.TableName) @@ -67,14 +67,14 @@ func (m *FileExport) GetFileList(c *gin.Context) { var querys FileExportQuery if err := c.ShouldBindQuery(&querys); err != nil { - c.JSON(http.StatusBadRequest, services.ErrResp(err.Error())) + c.JSON(http.StatusOK, services.ErrResp(err.Error())) return } files, err := file.GetFileInfo(querys.Path, querys.Suffix) if err != nil { log.Error("failed to GetFileInfo:", err) - c.JSON(http.StatusInternalServerError, services.ErrResp(err.Error())) + c.JSON(http.StatusOK, services.ErrResp(err.Error())) return } @@ -100,7 +100,7 @@ func (m *FileExport) Total(c *gin.Context) { fileCount, dirCount, err := file.GetFileAndDirCount(dir) if err != nil { log.Error("failed to GetFileAndDirCount:", err) - c.JSON(http.StatusInternalServerError, services.ErrResp(err.Error())) + c.JSON(http.StatusOK, services.ErrResp(err.Error())) return } total := fileCount + dirCount @@ -114,13 +114,13 @@ func (m *FileExport) DownloadHandler(c *gin.Context) { file, err := os.Open(filePath) if err != nil { - c.JSON(http.StatusInternalServerError, services.ErrResp(err.Error())) + c.JSON(http.StatusOK, services.ErrResp(err.Error())) return } defer file.Close() if _, err := os.Stat(filePath); os.IsNotExist(err) { - c.JSON(http.StatusNotFound, services.ErrResp(err.Error())) + c.JSON(http.StatusOK, services.ErrResp(err.Error())) return } @@ -135,7 +135,7 @@ func (m *FileExport) Delete(c *gin.Context) { filePath := filepath.Join(dir, fileName) if err := os.Remove(filePath); err != nil { - c.JSON(http.StatusInternalServerError, services.ErrResp(err.Error())) + c.JSON(http.StatusOK, services.ErrResp(err.Error())) return } c.JSON(http.StatusNoContent, nil) // 204 No Content