You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.2 KiB
Go

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package export
import (
"joybuywork/internal/plugins/export"
"joybuywork/internal/plugins/export/xlsx"
"joybuywork/internal/service/queue/types"
"joybuywork/internal/utils/logic"
"joybuywork/internal/utils/upload"
"errors"
"os"
"time"
)
type base struct {
logic.Logic
Req *types.Download
}
func (s *base) _eptFile(header export.HeaderField, rowData []export.RowData) (path string, err error) {
ept := xlsx.NewExport(s.Ctx, header, 0)
err = ept.ExportFile(rowData)
if err != nil {
return
}
path, err = upload.File(ept.GetFullPath(), ept.GetFilename())
defer os.Remove(ept.GetFullPath())
if err != nil {
return
}
return s._yun(ept.GetFullPath(), ept.GetFilename(), int64(len(rowData)))
}
func (s *base) _yun(fullPath, filename string, count int64) (path string, err error) {
path, err = upload.File(fullPath, filename)
defer os.Remove(fullPath)
if err != nil {
return
}
w := count / 200000
// 等阿里云全球加速同步
if w > 0 {
time.Sleep(time.Duration(w) * time.Second)
}
return
}
func (s *base) _checkCount(count int64) (err error) {
if count > 200000 {
return errors.New("当前导出数据已经超过20万行,如果确实需要导出,请联系平台工作人员或者对接开放平台文档拉取")
}
return
}