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).
|
err := datasource.DefaultDB().Table(m.TableName()).Where("invoke_target=? and status=1", INVOKE_FILE_EXPORT).
|
||||||
Find(&results).Error
|
Find(&results).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusInternalServerError, services.ErrResp(err.Error()))
|
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
language := ctx.AcceptLanguage(c)
|
language := ctx.AcceptLanguage(c)
|
||||||
@@ -46,7 +46,7 @@ func (m *SysJob) GetFileExportTable(c *gin.Context) {
|
|||||||
for _, job := range results {
|
for _, job := range results {
|
||||||
var params TargetParams
|
var params TargetParams
|
||||||
if err := json.Unmarshal([]byte(job.TargetParams), ¶ms); err != nil {
|
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
|
return
|
||||||
}
|
}
|
||||||
TableDisplay := i18n.TKey(language, "table."+params.TableName)
|
TableDisplay := i18n.TKey(language, "table."+params.TableName)
|
||||||
@@ -67,14 +67,14 @@ func (m *FileExport) GetFileList(c *gin.Context) {
|
|||||||
var querys FileExportQuery
|
var querys FileExportQuery
|
||||||
|
|
||||||
if err := c.ShouldBindQuery(&querys); err != nil {
|
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||||
c.JSON(http.StatusBadRequest, services.ErrResp(err.Error()))
|
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
files, err := file.GetFileInfo(querys.Path, querys.Suffix)
|
files, err := file.GetFileInfo(querys.Path, querys.Suffix)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("failed to GetFileInfo:", err)
|
log.Error("failed to GetFileInfo:", err)
|
||||||
c.JSON(http.StatusInternalServerError, services.ErrResp(err.Error()))
|
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +100,7 @@ func (m *FileExport) Total(c *gin.Context) {
|
|||||||
fileCount, dirCount, err := file.GetFileAndDirCount(dir)
|
fileCount, dirCount, err := file.GetFileAndDirCount(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("failed to GetFileAndDirCount:", err)
|
log.Error("failed to GetFileAndDirCount:", err)
|
||||||
c.JSON(http.StatusInternalServerError, services.ErrResp(err.Error()))
|
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
total := fileCount + dirCount
|
total := fileCount + dirCount
|
||||||
@@ -114,13 +114,13 @@ func (m *FileExport) DownloadHandler(c *gin.Context) {
|
|||||||
|
|
||||||
file, err := os.Open(filePath)
|
file, err := os.Open(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusInternalServerError, services.ErrResp(err.Error()))
|
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
if _, err := os.Stat(filePath); os.IsNotExist(err) {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,7 +135,7 @@ func (m *FileExport) Delete(c *gin.Context) {
|
|||||||
filePath := filepath.Join(dir, fileName)
|
filePath := filepath.Join(dir, fileName)
|
||||||
|
|
||||||
if err := os.Remove(filePath); err != nil {
|
if err := os.Remove(filePath); err != nil {
|
||||||
c.JSON(http.StatusInternalServerError, services.ErrResp(err.Error()))
|
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.JSON(http.StatusNoContent, nil) // 204 No Content
|
c.JSON(http.StatusNoContent, nil) // 204 No Content
|
||||||
|
|||||||
Reference in New Issue
Block a user