...
|
...
|
@@ -11,6 +11,7 @@ import ( |
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/middleware"
|
|
|
"io"
|
|
|
"path/filepath"
|
|
|
"strings"
|
|
|
)
|
|
|
|
|
|
type BaseController struct {
|
...
|
...
|
@@ -124,17 +125,19 @@ func (controller *BaseController) GetExcelFile() (io.Reader, error) { |
|
|
return excelFile, nil
|
|
|
}
|
|
|
|
|
|
func (controller *BaseController) GetFileWithExt() (io.Reader, string, error) {
|
|
|
func (controller *BaseController) GetFileWithExt() (io.Reader, string,string, error) {
|
|
|
excelFile, fileHeader, err := controller.GetFile("file")
|
|
|
if err != nil {
|
|
|
log.Logger.Error(err.Error())
|
|
|
return nil, "", fmt.Errorf("上传文件不存在")
|
|
|
return nil, "","", fmt.Errorf("上传文件不存在")
|
|
|
}
|
|
|
ext := filepath.Ext(fileHeader.Filename)
|
|
|
if !(ext == ".xlsx" || ext == ".xls" || ext == ".csv") {
|
|
|
return nil, "", fmt.Errorf("仅支持上传文件格式 xls/xlsx/csv")
|
|
|
return nil, "","", fmt.Errorf("仅支持上传文件格式 xls/xlsx/csv")
|
|
|
}
|
|
|
return excelFile, ext, nil
|
|
|
fileName := filepath.Base(fileHeader.Filename)
|
|
|
fileName = strings.TrimRight(fileName,ext)
|
|
|
return excelFile, ext,fileName, nil
|
|
|
}
|
|
|
|
|
|
func Must(err error) {
|
...
|
...
|
|