mager: 合并11.3版本,包名和主线一样方便复制

This commit is contained in:
TsMask
2024-11-23 18:54:02 +08:00
parent c0368c07ef
commit d5954d40c8
514 changed files with 24451 additions and 17932 deletions

View File

@@ -6,13 +6,12 @@ import (
"os"
"path/filepath"
"nms_cxy/lib/file"
"nms_cxy/lib/log"
"nms_cxy/lib/services"
"nms_cxy/src/framework/datasource"
"nms_cxy/src/framework/i18n"
"nms_cxy/src/framework/utils/ctx"
"be.ems/lib/file"
"be.ems/lib/log"
"be.ems/lib/services"
"be.ems/src/framework/datasource"
"be.ems/src/framework/i18n"
"be.ems/src/framework/utils/ctx"
"github.com/gin-gonic/gin"
)
@@ -39,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)
@@ -47,7 +46,7 @@ func (m *SysJob) GetFileExportTable(c *gin.Context) {
for _, job := range results {
var params TargetParams
if err := json.Unmarshal([]byte(job.TargetParams), &params); 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)
@@ -68,14 +67,15 @@ 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(err)
c.JSON(http.StatusInternalServerError, services.ErrResp(err.Error()))
log.Error("failed to GetFileInfo:", err)
c.JSON(http.StatusOK, services.ErrResp(err.Error()))
return
}
// split files list
@@ -99,8 +99,8 @@ func (m *FileExport) Total(c *gin.Context) {
fileCount, dirCount, err := file.GetFileAndDirCount(dir)
if err != nil {
log.Error(err)
c.JSON(http.StatusInternalServerError, services.ErrResp(err.Error()))
log.Error("failed to GetFileAndDirCount:", err)
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