add: file export for table
This commit is contained in:
@@ -64,16 +64,33 @@ func (m *SysJob) GetFileExportTable(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (m *FileExport) GetFileList(c *gin.Context) {
|
||||
dir := c.Query("path")
|
||||
suffix := c.Query("suffix")
|
||||
var querys FileExportQuery
|
||||
|
||||
files, err := file.GetFileInfo(dir, suffix)
|
||||
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||
c.JSON(http.StatusBadRequest, 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()))
|
||||
}
|
||||
total := int64(len(files))
|
||||
c.JSON(http.StatusOK, services.TotalDataResp(files, total))
|
||||
|
||||
// split files list
|
||||
lenNum := int64(len(files))
|
||||
start := (querys.PageNum - 1) * querys.PageSize
|
||||
end := start + querys.PageSize
|
||||
var splitList []file.FileInfo
|
||||
if start >= lenNum {
|
||||
splitList = []file.FileInfo{}
|
||||
} else if end >= lenNum {
|
||||
splitList = files[start:]
|
||||
} else {
|
||||
splitList = files[start:end]
|
||||
}
|
||||
total := len(files)
|
||||
c.JSON(http.StatusOK, services.TotalDataResp(splitList, total))
|
||||
}
|
||||
|
||||
func (m *FileExport) Total(c *gin.Context) {
|
||||
|
||||
Reference in New Issue
Block a user