Compare commits
No commits in common. "c255eb91b235e3fecbb7dbdc5d1fc87c6ef433ea" and "53f6c6e358cb8d1027aa1203ebddf5ba6aad6bf2" have entirely different histories.
c255eb91b2
...
53f6c6e358
@ -6,6 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -15,6 +16,7 @@ import (
|
|||||||
"github.com/exhibition-main/internal/model"
|
"github.com/exhibition-main/internal/model"
|
||||||
"github.com/exhibition-main/internal/msg"
|
"github.com/exhibition-main/internal/msg"
|
||||||
"github.com/exhibition-main/internal/response"
|
"github.com/exhibition-main/internal/response"
|
||||||
|
"github.com/exhibition-main/pkg/service/common"
|
||||||
"github.com/exhibition-main/pkg/utils"
|
"github.com/exhibition-main/pkg/utils"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/gin-gonic/gin/binding"
|
"github.com/gin-gonic/gin/binding"
|
||||||
@ -324,27 +326,27 @@ func ImportRecordByExcel(c *gin.Context) {
|
|||||||
if len(row) < 12 { // 确保列数足够
|
if len(row) < 12 { // 确保列数足够
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// artworkUrl := ""
|
artworkUrl := ""
|
||||||
// if pics, err := excelFile.GetPictures(sheetName, fmt.Sprintf("K%d", i+1)); err == nil && len(pics) > 0 {
|
if pics, err := excelFile.GetPictures(sheetName, fmt.Sprintf("K%d", i+1)); err == nil && len(pics) > 0 {
|
||||||
// tmpFile, err := ioutil.TempFile("", fmt.Sprintf("oss_upload_%d*.jpg", i))
|
tmpFile, err := ioutil.TempFile("", fmt.Sprintf("oss_upload_%d*.jpg", i))
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// logger.Errorf("创建临时文件失败: %v", err)
|
logger.Errorf("创建临时文件失败: %v", err)
|
||||||
// response.ResponseQuickMsg(c, msg.Fail, "创建临时文件失败", nil)
|
response.ResponseQuickMsg(c, msg.Fail, "创建临时文件失败", nil)
|
||||||
// return
|
return
|
||||||
// }
|
}
|
||||||
// defer os.Remove(tmpFile.Name())
|
defer os.Remove(tmpFile.Name())
|
||||||
// if _, err := tmpFile.Write(pics[0].File); err != nil {
|
if _, err := tmpFile.Write(pics[0].File); err != nil {
|
||||||
// logger.Errorf("写入临时文件失败: %v", err)
|
logger.Errorf("写入临时文件失败: %v", err)
|
||||||
// response.ResponseQuickMsg(c, msg.Fail, "写入临时文件失败", nil)
|
response.ResponseQuickMsg(c, msg.Fail, "写入临时文件失败", nil)
|
||||||
// return
|
return
|
||||||
// }
|
}
|
||||||
// //objectKey := fmt.Sprintf("artwork/%s/%d.jpg", time.Now().Format("20060102"), time.Now().UnixNano())
|
//objectKey := fmt.Sprintf("artwork/%s/%d.jpg", time.Now().Format("20060102"), time.Now().UnixNano())
|
||||||
// if url, err := common.PutBos(tmpFile.Name(), "image", false); err == nil {
|
if url, err := common.PutBos(tmpFile.Name(), "image", false); err == nil {
|
||||||
// artworkUrl = url
|
artworkUrl = url
|
||||||
// } else {
|
} else {
|
||||||
// logger.Errorf("上传图片失败: %v", err)
|
logger.Errorf("上传图片失败: %v", err)
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
record := &exhibition.RegisterInfo{
|
record := &exhibition.RegisterInfo{
|
||||||
PreliminaryRatingNo: row[0],
|
PreliminaryRatingNo: row[0],
|
||||||
ReRatingNo: row[1],
|
ReRatingNo: row[1],
|
||||||
@ -356,7 +358,7 @@ func ImportRecordByExcel(c *gin.Context) {
|
|||||||
PhoneNum: string(row[7]),
|
PhoneNum: string(row[7]),
|
||||||
Province: string(row[8]),
|
Province: string(row[8]),
|
||||||
IdCard: string(row[9]),
|
IdCard: string(row[9]),
|
||||||
//ArtworkFile: artworkUrl,
|
ArtworkFile: artworkUrl,
|
||||||
}
|
}
|
||||||
record.Gender = GetGenderByIdCard(record.IdCard)
|
record.Gender = GetGenderByIdCard(record.IdCard)
|
||||||
records = append(records, record)
|
records = append(records, record)
|
||||||
|
Loading…
Reference in New Issue
Block a user