Compare commits
No commits in common. "db0c06482865b78919f43617563e1a075b105ca8" and "6773cc62e7c7fc7e609024b580773d7d13f9d183" have entirely different histories.
db0c064828
...
6773cc62e7
@ -9,26 +9,14 @@ type ArtistAccount struct {
|
|||||||
Account map[apiCast.PlatformIDENUM]string `json:"account"`
|
Account map[apiCast.PlatformIDENUM]string `json:"account"`
|
||||||
}
|
}
|
||||||
type ArtistMedia struct {
|
type ArtistMedia struct {
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
Img string `json:"img"`
|
Img string `json:"img"`
|
||||||
Video string `json:"video"`
|
Video string `json:"video"`
|
||||||
Youtube string `json:"youtube"`
|
|
||||||
Instagram string `json:"instagram"`
|
|
||||||
TikTok string `json:"tiktok"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type FailedRecord struct {
|
type FailedRecord struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Msg string `json:"msg"`
|
Msg string `json:"msg"`
|
||||||
}
|
}
|
||||||
type ArtistVideoDetail struct {
|
|
||||||
Id string `json:"id"`
|
|
||||||
ArtistName string `json:"artistName"`
|
|
||||||
Title string `json:"title"`
|
|
||||||
WorkUuid string `json:"workUuid"`
|
|
||||||
Youtube string `json:"youtube"`
|
|
||||||
Instagram string `json:"instagram"`
|
|
||||||
TikTok string `json:"tiktok"`
|
|
||||||
}
|
|
||||||
|
@ -52,12 +52,8 @@ func WorkConfirm(c *gin.Context) { // 确认作品并扣除余量
|
|||||||
VideoConsumptionNumber: 1,
|
VideoConsumptionNumber: 1,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
failedRecords = append(failedRecords, FailedRecord{
|
service.Error(c, err)
|
||||||
Name: v.ArtistName,
|
return
|
||||||
Msg: fmt.Sprintf("扣除余额失败: %s", err.Error()),
|
|
||||||
})
|
|
||||||
log.Printf(fmt.Sprintf("扣除余额失败: %s", err.Error()))
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
_, err = service.CastProvider.UpdateStatus(c, &apiCast.UpdateStatusReq{
|
_, err = service.CastProvider.UpdateStatus(c, &apiCast.UpdateStatusReq{
|
||||||
WorkAction: apiCast.WorkActionENUM_CONFIRM,
|
WorkAction: apiCast.WorkActionENUM_CONFIRM,
|
||||||
@ -66,12 +62,8 @@ func WorkConfirm(c *gin.Context) { // 确认作品并扣除余量
|
|||||||
ConfirmStatus: 1,
|
ConfirmStatus: 1,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
failedRecords = append(failedRecords, FailedRecord{
|
service.Error(c, err)
|
||||||
Name: v.ArtistName,
|
return
|
||||||
Msg: fmt.Sprintf("更新状态失败: %s", err.Error()),
|
|
||||||
})
|
|
||||||
log.Printf(fmt.Sprintf("更新状态失败: %s", err.Error()))
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
service.Success(c, failedRecords)
|
service.Success(c, failedRecords)
|
||||||
|
@ -85,8 +85,6 @@ func ImportPublish(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
// 5.发布视频
|
// 5.发布视频
|
||||||
var failedRecords []FailedRecord
|
var failedRecords []FailedRecord
|
||||||
var artistResp []ArtistVideoDetail
|
|
||||||
|
|
||||||
for _, artist := range artists {
|
for _, artist := range artists {
|
||||||
var infoResp *accountFiee.UserInfoResponse
|
var infoResp *accountFiee.UserInfoResponse
|
||||||
var err error
|
var err error
|
||||||
@ -160,7 +158,7 @@ func ImportPublish(c *gin.Context) {
|
|||||||
platformIDs = append(platformIDs, apiCast.PlatformIDENUM(info.PlatformID))
|
platformIDs = append(platformIDs, apiCast.PlatformIDENUM(info.PlatformID))
|
||||||
}
|
}
|
||||||
newCtx := cast.NewCtxWithUserInfo(c)
|
newCtx := cast.NewCtxWithUserInfo(c)
|
||||||
resp, err := service.CastProvider.UpdateWorkVideo(newCtx, &apiCast.UpdateWorkVideoReq{
|
_, err = service.CastProvider.UpdateWorkVideo(newCtx, &apiCast.UpdateWorkVideoReq{
|
||||||
Title: artist.Title,
|
Title: artist.Title,
|
||||||
Content: artist.Title,
|
Content: artist.Title,
|
||||||
VideoUrl: artist.Video,
|
VideoUrl: artist.Video,
|
||||||
@ -207,28 +205,10 @@ func ImportPublish(c *gin.Context) {
|
|||||||
log.Printf(fmt.Sprintf("发布"+artist.Name+"视频"+artist.Title+"失败: %s", err.Error()))
|
log.Printf(fmt.Sprintf("发布"+artist.Name+"视频"+artist.Title+"失败: %s", err.Error()))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
artistResp = append(artistResp, ArtistVideoDetail{
|
|
||||||
Id: artist.Id,
|
|
||||||
ArtistName: artist.Name,
|
|
||||||
Title: artist.Title,
|
|
||||||
WorkUuid: resp.WorkUuid,
|
|
||||||
Youtube: artist.Youtube,
|
|
||||||
Instagram: artist.Instagram,
|
|
||||||
TikTok: artist.TikTok,
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
|
||||||
excelUrl, err := exportRecordsToExcel(artistResp)
|
|
||||||
if err != nil {
|
|
||||||
service.Error(c, err)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6. 返回结果
|
// 6. 返回结果
|
||||||
service.Success(c, map[string]interface{}{
|
service.Success(c, failedRecords)
|
||||||
"excelUrl": excelUrl,
|
|
||||||
"failedRecords": failedRecords,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func readArtistVideoInfo(excelPath, unzipPath string) ([]ArtistMedia, error) {
|
func readArtistVideoInfo(excelPath, unzipPath string) ([]ArtistMedia, error) {
|
||||||
@ -264,25 +244,10 @@ func readArtistVideoInfo(excelPath, unzipPath string) ([]ArtistMedia, error) {
|
|||||||
if title != "" {
|
if title != "" {
|
||||||
title = strings.TrimSpace(title)
|
title = strings.TrimSpace(title)
|
||||||
}
|
}
|
||||||
youtube, _ := f.GetCellValue(sheetName, fmt.Sprintf("D%d", i+1))
|
|
||||||
if youtube != "" {
|
|
||||||
youtube = strings.TrimSpace(youtube)
|
|
||||||
}
|
|
||||||
instagram, _ := f.GetCellValue(sheetName, fmt.Sprintf("E%d", i+1))
|
|
||||||
if instagram != "" {
|
|
||||||
instagram = strings.TrimSpace(instagram)
|
|
||||||
}
|
|
||||||
tiktok, _ := f.GetCellValue(sheetName, fmt.Sprintf("F%d", i+1))
|
|
||||||
if tiktok != "" {
|
|
||||||
tiktok = strings.TrimSpace(tiktok)
|
|
||||||
}
|
|
||||||
artists = append(artists, ArtistMedia{
|
artists = append(artists, ArtistMedia{
|
||||||
Id: id,
|
Id: id,
|
||||||
Name: artistName,
|
Name: artistName,
|
||||||
Title: title,
|
Title: title,
|
||||||
Youtube: youtube,
|
|
||||||
Instagram: instagram,
|
|
||||||
TikTok: tiktok,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
artists, err = matchArtistMedia(artists, unzipPath)
|
artists, err = matchArtistMedia(artists, unzipPath)
|
||||||
@ -388,41 +353,3 @@ func UploadToAnotherService(ctx context.Context, fileData []byte, path string) e
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
func exportRecordsToExcel(artistInfos []ArtistVideoDetail) (string, error) {
|
|
||||||
f := excelize.NewFile()
|
|
||||||
sheet := "Sheet1"
|
|
||||||
f.NewSheet(sheet)
|
|
||||||
|
|
||||||
// 写表头
|
|
||||||
headers := []string{"序号", "画家名", "标题", "uuid", "youtube", "instagram", "tiktok"}
|
|
||||||
|
|
||||||
for col, h := range headers {
|
|
||||||
_ = f.SetCellValue(sheet, string(rune('A'+col))+"1", h)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 写数据
|
|
||||||
for i, artistInfo := range artistInfos {
|
|
||||||
row := i + 2
|
|
||||||
_ = f.SetCellValue(sheet, "A"+strconv.Itoa(row), artistInfo.Id)
|
|
||||||
_ = f.SetCellValue(sheet, "B"+strconv.Itoa(row), artistInfo.ArtistName)
|
|
||||||
_ = f.SetCellValue(sheet, "C"+strconv.Itoa(row), artistInfo.Title)
|
|
||||||
_ = f.SetCellValue(sheet, "D"+strconv.Itoa(row), artistInfo.WorkUuid)
|
|
||||||
_ = f.SetCellValue(sheet, "E"+strconv.Itoa(row), artistInfo.Youtube)
|
|
||||||
_ = f.SetCellValue(sheet, "F"+strconv.Itoa(row), artistInfo.Instagram)
|
|
||||||
_ = f.SetCellValue(sheet, "G"+strconv.Itoa(row), artistInfo.TikTok)
|
|
||||||
}
|
|
||||||
// 保存文件
|
|
||||||
filename := "画家视频详情记录.xlsx"
|
|
||||||
fileDir := "./runtime/import/" // 自定义目录
|
|
||||||
_ = os.MkdirAll(fileDir, os.ModePerm)
|
|
||||||
filePath := filepath.Join(fileDir, filename)
|
|
||||||
if err := f.SaveAs(filePath); err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
excelUrl, err := upload.PutBos(filePath, "excel", true)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
|
|
||||||
}
|
|
||||||
return excelUrl, nil
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user