fix: return code to FE issue
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user