feat:新增图文导入的其他平台
This commit is contained in:
parent
0b2f0da573
commit
28e7e3beba
@ -30,6 +30,8 @@ type excelData struct {
|
||||
SubNum string //用户编号 必须字段
|
||||
TikTok string
|
||||
Instagram string
|
||||
YouTube string
|
||||
BlueSky string
|
||||
Youtube string
|
||||
Desc string //艺人简介
|
||||
TitleRequire string //标题要求 必须字段
|
||||
@ -178,27 +180,35 @@ func readExcel(excelPath string) ([]excelData, error) {
|
||||
if subNum == "" {
|
||||
return nil, fmt.Errorf("第%d行应该有编号", i+1)
|
||||
}
|
||||
tikTok := getCellValue(f, sheetName, i, 2)
|
||||
blueSky := getCellValue(f, sheetName, i, 3)
|
||||
if blueSky == "" {
|
||||
return nil, fmt.Errorf("第%d行应该有bluesky账号昵称", i+1)
|
||||
}
|
||||
tikTok := getCellValue(f, sheetName, i, 4)
|
||||
if tikTok == "" {
|
||||
return nil, fmt.Errorf("第%d行应该有tiktok账号昵称", i+1)
|
||||
}
|
||||
instagram := getCellValue(f, sheetName, i, 3)
|
||||
youtube := getCellValue(f, sheetName, i, 5)
|
||||
if youtube == "" {
|
||||
return nil, fmt.Errorf("第%d行应该有youtube账号昵称", i+1)
|
||||
}
|
||||
instagram := getCellValue(f, sheetName, i, 6)
|
||||
if instagram == "" {
|
||||
return nil, fmt.Errorf("第%d行应该有ins账号昵称", i+1)
|
||||
}
|
||||
desc := getCellValue(f, sheetName, i, 4)
|
||||
titleRequire := getCellValue(f, sheetName, i, 5)
|
||||
desc := getCellValue(f, sheetName, i, 6)
|
||||
titleRequire := getCellValue(f, sheetName, i, 7)
|
||||
if titleRequire == "" {
|
||||
return nil, fmt.Errorf("第%d行应该有标题要求", i+1)
|
||||
}
|
||||
contentRequire := getCellValue(f, sheetName, i, 6)
|
||||
contentRequire := getCellValue(f, sheetName, i, 8)
|
||||
if contentRequire == "" {
|
||||
return nil, fmt.Errorf("第%d行应该有内容要求", i+1)
|
||||
}
|
||||
photoRequire := getCellValue(f, sheetName, i, 7)
|
||||
photoUrl := getCellValue(f, sheetName, i, 8)
|
||||
photoNumStr := getCellValue(f, sheetName, i, 9)
|
||||
photoDpi := getCellValue(f, sheetName, i, 10)
|
||||
photoRequire := getCellValue(f, sheetName, i, 9)
|
||||
photoUrl := getCellValue(f, sheetName, i, 10)
|
||||
photoNumStr := getCellValue(f, sheetName, i, 11)
|
||||
photoDpi := getCellValue(f, sheetName, i, 12)
|
||||
var num int
|
||||
if photoUrl == "" { //如果没有关联画作,数量必须有,需求必须有
|
||||
//需求必须有
|
||||
@ -220,8 +230,10 @@ func readExcel(excelPath string) ([]excelData, error) {
|
||||
data := excelData{
|
||||
ArtistName: artistName,
|
||||
SubNum: subNum,
|
||||
BlueSky: blueSky,
|
||||
TikTok: tikTok,
|
||||
Instagram: instagram,
|
||||
YouTube: youtube,
|
||||
Desc: desc,
|
||||
TitleRequire: titleRequire,
|
||||
ContentRequire: contentRequire,
|
||||
|
||||
@ -293,6 +293,7 @@ func (p *BatchProcessor) submitTask(req *excelData) error {
|
||||
if !tiktokFound {
|
||||
return fmt.Errorf("未找到匹配的TikTok账号: %s", req.TikTok)
|
||||
}
|
||||
|
||||
// 获取 Instagram 自媒体账号
|
||||
accountListIns, err := service.CastProvider.MediaUserList(context.Background(), &apiCast.MediaUserListReq{
|
||||
ArtistVal: req.ArtistName,
|
||||
@ -307,7 +308,6 @@ func (p *BatchProcessor) submitTask(req *excelData) error {
|
||||
if accountListIns == nil || len(accountListIns.Data) == 0 {
|
||||
return fmt.Errorf("ins自媒体账号数量为0")
|
||||
}
|
||||
|
||||
// 查找 Instagram 账号
|
||||
insFound := false
|
||||
for _, user := range accountListIns.Data {
|
||||
@ -322,6 +322,62 @@ func (p *BatchProcessor) submitTask(req *excelData) error {
|
||||
return fmt.Errorf("未找到匹配的Instagram账号: %s", req.Instagram)
|
||||
}
|
||||
|
||||
// 获取 Bluesky 自媒体账号
|
||||
accountListBlueSky, err := service.CastProvider.MediaUserList(context.Background(), &apiCast.MediaUserListReq{
|
||||
ArtistVal: req.ArtistName,
|
||||
PlatformID: 5, // Bluesky platform ID
|
||||
Page: 1,
|
||||
PageSize: 10,
|
||||
ArtistUuid: strconv.FormatUint(list.UserList[0].Id, 10),
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("获取 Bluesky 账号失败: %s", err.Error())
|
||||
}
|
||||
if accountListBlueSky == nil || len(accountListBlueSky.Data) == 0 {
|
||||
return fmt.Errorf("bluesky自媒体账号数量为0")
|
||||
}
|
||||
// 查找 Bluesky 账号
|
||||
blueSkyFound := false
|
||||
for _, user := range accountListBlueSky.Data {
|
||||
if user.PlatformUserName == req.BlueSky {
|
||||
req.MediaAccountNames = append(req.MediaAccountNames, user.PlatformUserName)
|
||||
req.MediaAccountUuids = append(req.MediaAccountUuids, user.MediaAccountUuid)
|
||||
blueSkyFound = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !blueSkyFound {
|
||||
return fmt.Errorf("未找到匹配的Bluesky账号: %s", req.BlueSky)
|
||||
}
|
||||
|
||||
// 获取 YouTube 自媒体账号
|
||||
accountListYouTube, err := service.CastProvider.MediaUserList(context.Background(), &apiCast.MediaUserListReq{
|
||||
ArtistVal: req.ArtistName,
|
||||
PlatformID: 2, // YouTube platform ID
|
||||
Page: 1,
|
||||
PageSize: 10,
|
||||
ArtistUuid: strconv.FormatUint(list.UserList[0].Id, 10),
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("获取 YouTube 账号失败: %s", err.Error())
|
||||
}
|
||||
if accountListYouTube == nil || len(accountListYouTube.Data) == 0 {
|
||||
return fmt.Errorf("youtube自媒体账号数量为0")
|
||||
}
|
||||
// 查找 YouTube 账号
|
||||
youTubeFound := false
|
||||
for _, user := range accountListYouTube.Data {
|
||||
if user.PlatformUserName == req.YouTube {
|
||||
req.MediaAccountNames = append(req.MediaAccountNames, user.PlatformUserName)
|
||||
req.MediaAccountUuids = append(req.MediaAccountUuids, user.MediaAccountUuid)
|
||||
youTubeFound = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !youTubeFound {
|
||||
return fmt.Errorf("未找到匹配的YouTube账号: %s", req.YouTube)
|
||||
}
|
||||
|
||||
switch {
|
||||
case req.PhotoUrl == "": // 如果没有提供照片 URL,生成标题和内容
|
||||
// 生成标题和内容
|
||||
|
||||
Loading…
Reference in New Issue
Block a user