Merge branch 'sxy' into dev
This commit is contained in:
commit
ed37a9b85e
@ -6,6 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/360EntSecGroup-Skylar/excelize"
|
"github.com/360EntSecGroup-Skylar/excelize"
|
||||||
@ -162,7 +163,7 @@ func ExportRegister(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
columns := []string{"画家姓名", "性别", "手机号", "身份证号", "通讯地址", "身份证照片", "本人近照", "作品名称", "报名时间", "更新时间"}
|
columns := []string{"画家姓名", "性别", "手机号", "身份证号", "通讯地址", "身份证照片", "本人近照", "作品名称", "报名时间", "更新时间"}
|
||||||
exportFileName := fmt.Sprintf("%s迁想妙得.xlsx", time.Now().Format("20060102"))
|
exportFileName := fmt.Sprintf("%s迁想妙得.xlsx", time.Now().Format("20060102"))
|
||||||
filePath := fmt.Sprintf("../runtime/%s", exportFileName)
|
filePath := fmt.Sprintf("./runtime/%s", exportFileName)
|
||||||
data := make([]interface{}, 0)
|
data := make([]interface{}, 0)
|
||||||
for _, v := range resp.Data {
|
for _, v := range resp.Data {
|
||||||
var temp []string
|
var temp []string
|
||||||
@ -194,6 +195,13 @@ func ExportRegister(c *gin.Context) {
|
|||||||
response.ResponseQuickMsg(c, msg.Fail, err.Error(), nil)
|
response.ResponseQuickMsg(c, msg.Fail, err.Error(), nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
defer func() {
|
||||||
|
if err := os.Remove(filePath); err != nil {
|
||||||
|
logger.Errorf("删除临时文件失败: %v", err)
|
||||||
|
} else {
|
||||||
|
logger.Info("临时文件已清理:", filePath)
|
||||||
|
}
|
||||||
|
}()
|
||||||
var httpType string
|
var httpType string
|
||||||
if config.Data.System.IsHttps {
|
if config.Data.System.IsHttps {
|
||||||
httpType = model.HttpsType
|
httpType = model.HttpsType
|
||||||
|
@ -4,17 +4,19 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/dubbogo/gost/log/logger"
|
|
||||||
"github.com/exhibition-main/internal/msg"
|
|
||||||
"github.com/tealeg/xlsx"
|
|
||||||
"go.uber.org/zap"
|
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/dubbogo/gost/log/logger"
|
||||||
|
"github.com/exhibition-main/internal/msg"
|
||||||
|
"github.com/tealeg/xlsx"
|
||||||
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PostForm 发送post请求
|
// PostForm 发送post请求
|
||||||
@ -82,6 +84,10 @@ func ToExcelByType(titleList []string, dataList []interface{}, dataType string,
|
|||||||
_ = file.Write(&buffer)
|
_ = file.Write(&buffer)
|
||||||
fmt.Println("=======================Save============================")
|
fmt.Println("=======================Save============================")
|
||||||
if filePath != "" {
|
if filePath != "" {
|
||||||
|
dir := filepath.Dir(filePath)
|
||||||
|
if err = CreateDirPath(dir); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
if err = file.Save(filePath); err != nil {
|
if err = file.Save(filePath); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user