Compare commits
No commits in common. "0b93a23d4e11e179a6da84fa8e8a21f8b3563f55" and "bbf81de56e702b37e473c5af05c07345a243fd52" have entirely different histories.
0b93a23d4e
...
bbf81de56e
@ -38,19 +38,21 @@ type excelData struct {
|
|||||||
PhotoUrl string //画作地址
|
PhotoUrl string //画作地址
|
||||||
PhotoNum int //图片数量 必须字段
|
PhotoNum int //图片数量 必须字段
|
||||||
LineNum int
|
LineNum int
|
||||||
MediaAccountUuids []string
|
|
||||||
MediaAccountNames []string
|
|
||||||
}
|
}
|
||||||
type publishImageReq struct {
|
type publishImageReq struct {
|
||||||
ArtistName string //艺人
|
ArtistName string //艺人
|
||||||
SubNum string //用户编号
|
SubNum string //用户编号
|
||||||
Title string //标题
|
Title string //标题
|
||||||
Content string //内容
|
Content string //内容
|
||||||
TikTok string
|
|
||||||
Instagram string
|
|
||||||
GeneratePhotoUrl []string //生成图片地址
|
GeneratePhotoUrl []string //生成图片地址
|
||||||
MediaAccountUuids []string
|
}
|
||||||
MediaAccountNames []string
|
|
||||||
|
// 记录处理结果
|
||||||
|
type ProcessResult struct {
|
||||||
|
ExcelData excelData
|
||||||
|
Success bool
|
||||||
|
ErrorMessage string
|
||||||
|
TaskID string
|
||||||
}
|
}
|
||||||
|
|
||||||
func getErrorMessage(err error) string {
|
func getErrorMessage(err error) string {
|
||||||
@ -164,44 +166,27 @@ func readExcel(excelPath string) ([]excelData, error) {
|
|||||||
var result []excelData
|
var result []excelData
|
||||||
for i := 1; i < len(rows); i++ { // 从第2行开始(跳过表头)
|
for i := 1; i < len(rows); i++ { // 从第2行开始(跳过表头)
|
||||||
row := rows[i]
|
row := rows[i]
|
||||||
if len(row) == 0 {
|
if len(row) == 0 || strings.TrimSpace(row[0]) == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
artistName := getCellValue(f, sheetName, i, 0)
|
artistName := getCellValue(f, sheetName, i, 0)
|
||||||
if artistName == "" {
|
|
||||||
return nil, fmt.Errorf("第%d行应该有艺人名称", i+1)
|
|
||||||
}
|
|
||||||
subNum := getCellValue(f, sheetName, i, 1)
|
subNum := getCellValue(f, sheetName, i, 1)
|
||||||
if subNum == "" {
|
|
||||||
return nil, fmt.Errorf("第%d行应该有编号", i+1)
|
|
||||||
}
|
|
||||||
tikTok := getCellValue(f, sheetName, i, 2)
|
tikTok := getCellValue(f, sheetName, i, 2)
|
||||||
if tikTok == "" {
|
|
||||||
return nil, fmt.Errorf("第%d行应该有tiktok账号昵称", i+1)
|
|
||||||
}
|
|
||||||
instagram := getCellValue(f, sheetName, i, 3)
|
instagram := getCellValue(f, sheetName, i, 3)
|
||||||
if instagram == "" {
|
youtube := getCellValue(f, sheetName, i, 4)
|
||||||
return nil, fmt.Errorf("第%d行应该有ins账号昵称", i+1)
|
desc := getCellValue(f, sheetName, i, 5)
|
||||||
}
|
titleRequire := getCellValue(f, sheetName, i, 6)
|
||||||
desc := getCellValue(f, sheetName, i, 4)
|
contentRequire := getCellValue(f, sheetName, i, 7)
|
||||||
titleRequire := getCellValue(f, sheetName, i, 5)
|
photoRequire := getCellValue(f, sheetName, i, 8)
|
||||||
if titleRequire == "" {
|
photoUrl := getCellValue(f, sheetName, i, 9)
|
||||||
return nil, fmt.Errorf("第%d行应该有标题要求", i+1)
|
|
||||||
}
|
|
||||||
contentRequire := getCellValue(f, sheetName, i, 6)
|
|
||||||
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)
|
|
||||||
var num int
|
var num int
|
||||||
if photoUrl == "" { //如果没有关联画作,数量必须有,需求必须有
|
if photoUrl == "" { //如果没有关联画作,数量必须有,需求必须有
|
||||||
//需求必须有
|
//需求必须有
|
||||||
if photoRequire == "" {
|
if photoRequire == "" {
|
||||||
return nil, fmt.Errorf("第%d行应该有图片需求", i+1)
|
return nil, fmt.Errorf("第%d行应该有图片需求", i+1)
|
||||||
}
|
}
|
||||||
|
photoNumStr := getCellValue(f, sheetName, i, 10)
|
||||||
//转换成功
|
//转换成功
|
||||||
photoNum, err := strconv.Atoi(strings.TrimSpace(photoNumStr))
|
photoNum, err := strconv.Atoi(strings.TrimSpace(photoNumStr))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -219,11 +204,11 @@ func readExcel(excelPath string) ([]excelData, error) {
|
|||||||
SubNum: subNum,
|
SubNum: subNum,
|
||||||
TikTok: tikTok,
|
TikTok: tikTok,
|
||||||
Instagram: instagram,
|
Instagram: instagram,
|
||||||
|
Youtube: youtube,
|
||||||
Desc: desc,
|
Desc: desc,
|
||||||
TitleRequire: titleRequire,
|
TitleRequire: titleRequire,
|
||||||
ContentRequire: contentRequire,
|
ContentRequire: contentRequire,
|
||||||
PhotoRequire: photoRequire,
|
PhotoUrl: photoRequire,
|
||||||
PhotoUrl: photoUrl,
|
|
||||||
PhotoNum: num,
|
PhotoNum: num,
|
||||||
LineNum: i, //行数
|
LineNum: i, //行数
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,13 +1,9 @@
|
|||||||
package imports
|
package imports
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"fonchain-fiee/api/accountFiee"
|
|
||||||
apiCast "fonchain-fiee/api/cast"
|
|
||||||
"fonchain-fiee/pkg/config"
|
"fonchain-fiee/pkg/config"
|
||||||
"fonchain-fiee/pkg/service"
|
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -112,77 +108,6 @@ func (p *BatchProcessor) GetStatus() int {
|
|||||||
|
|
||||||
// 提交任务
|
// 提交任务
|
||||||
func (p *BatchProcessor) submitSingleTask(req excelData, num int) error {
|
func (p *BatchProcessor) submitSingleTask(req excelData, num int) error {
|
||||||
//var infoResp *accountFiee.UserInfoResponse
|
|
||||||
list, err := service.AccountFieeProvider.UserList(context.Background(), &accountFiee.UserListRequest{
|
|
||||||
Name: req.ArtistName,
|
|
||||||
SubNum: req.SubNum,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("获取用户信息失败: %s", err.Error())
|
|
||||||
}
|
|
||||||
if len(list.UserList) == 0 {
|
|
||||||
return fmt.Errorf("未找到用户信息: %s", req.ArtistName)
|
|
||||||
}
|
|
||||||
if len(list.UserList) > 0 {
|
|
||||||
_, err = service.AccountFieeProvider.Info(context.Background(), &accountFiee.InfoRequest{
|
|
||||||
ID: list.UserList[0].Id,
|
|
||||||
Domain: "app",
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("获取用户信息失败: %s", err.Error())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
accountListTikTok, err := service.CastProvider.MediaUserList(context.Background(), &apiCast.MediaUserListReq{
|
|
||||||
ArtistVal: req.ArtistName,
|
|
||||||
PlatformID: 1,
|
|
||||||
Page: 1,
|
|
||||||
PageSize: 10,
|
|
||||||
ArtistUuid: strconv.FormatUint(list.UserList[0].Id, 10),
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("tiktok自媒体账号数量获取失败: %s,账号数量:%d", err.Error(), len(accountListTikTok.Data))
|
|
||||||
}
|
|
||||||
if accountListTikTok == nil || len(accountListTikTok.Data) == 0 {
|
|
||||||
return fmt.Errorf("tiktok自媒体账号数量为0")
|
|
||||||
}
|
|
||||||
tiktokFound := false
|
|
||||||
for _, user := range accountListTikTok.Data {
|
|
||||||
if user.PlatformUserName == req.TikTok {
|
|
||||||
req.MediaAccountNames = append(req.MediaAccountNames, user.PlatformUserName)
|
|
||||||
req.MediaAccountUuids = append(req.MediaAccountUuids, user.MediaAccountUuid)
|
|
||||||
tiktokFound = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !tiktokFound {
|
|
||||||
return fmt.Errorf("未找到匹配的TikTok账号: %s", req.TikTok)
|
|
||||||
}
|
|
||||||
accountListIns, err := service.CastProvider.MediaUserList(context.Background(), &apiCast.MediaUserListReq{
|
|
||||||
ArtistVal: req.ArtistName,
|
|
||||||
PlatformID: 3,
|
|
||||||
Page: 1,
|
|
||||||
PageSize: 10,
|
|
||||||
ArtistUuid: strconv.FormatUint(list.UserList[0].Id, 10),
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("ins自媒体账号数量获取失败: %s,账号数量:%d", err.Error(), len(accountListIns.Data))
|
|
||||||
}
|
|
||||||
if accountListIns == nil || len(accountListIns.Data) == 0 {
|
|
||||||
return fmt.Errorf("ins自媒体账号数量为0")
|
|
||||||
}
|
|
||||||
insFound := false
|
|
||||||
for _, user := range accountListIns.Data {
|
|
||||||
if user.PlatformUserName == req.Instagram {
|
|
||||||
req.MediaAccountNames = append(req.MediaAccountNames, user.PlatformUserName)
|
|
||||||
req.MediaAccountUuids = append(req.MediaAccountUuids, user.MediaAccountUuid)
|
|
||||||
insFound = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !insFound {
|
|
||||||
return fmt.Errorf("未找到匹配的Instagram账号: %s", req.Instagram)
|
|
||||||
}
|
|
||||||
p.mu.Lock()
|
p.mu.Lock()
|
||||||
defer p.mu.Unlock()
|
defer p.mu.Unlock()
|
||||||
//title, content, err := p.generateTitleAndContent(req)
|
//title, content, err := p.generateTitleAndContent(req)
|
||||||
@ -471,8 +396,6 @@ func (p *BatchProcessor) UpdateTaskStatuses(taskId string) (err error) {
|
|||||||
Title: p.tasks[taskId].Title,
|
Title: p.tasks[taskId].Title,
|
||||||
Content: p.tasks[taskId].Content,
|
Content: p.tasks[taskId].Content,
|
||||||
GeneratePhotoUrl: []string{p.tasks[taskId].Data.PhotoUrl},
|
GeneratePhotoUrl: []string{p.tasks[taskId].Data.PhotoUrl},
|
||||||
TikTok: p.tasks[taskId].Data.TikTok,
|
|
||||||
Instagram: p.tasks[taskId].Data.Instagram,
|
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
p.tasks[taskId].Status = TaskFailed
|
p.tasks[taskId].Status = TaskFailed
|
||||||
p.inProgress[taskId] = true
|
p.inProgress[taskId] = true
|
||||||
@ -532,8 +455,6 @@ func (p *BatchProcessor) UpdateTaskStatuses(taskId string) (err error) {
|
|||||||
SubNum: p.tasks[getTaskDetailRes.Output.TaskID].Data.SubNum,
|
SubNum: p.tasks[getTaskDetailRes.Output.TaskID].Data.SubNum,
|
||||||
Title: p.tasks[getTaskDetailRes.Output.TaskID].Title,
|
Title: p.tasks[getTaskDetailRes.Output.TaskID].Title,
|
||||||
Content: p.tasks[getTaskDetailRes.Output.TaskID].Content,
|
Content: p.tasks[getTaskDetailRes.Output.TaskID].Content,
|
||||||
TikTok: p.tasks[taskId].Data.TikTok,
|
|
||||||
Instagram: p.tasks[taskId].Data.Instagram,
|
|
||||||
GeneratePhotoUrl: uploadedURLs,
|
GeneratePhotoUrl: uploadedURLs,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
localTask.Status = TaskFailed
|
localTask.Status = TaskFailed
|
||||||
|
|||||||
@ -32,38 +32,35 @@ func publishImage(req publishImageReq) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------获取自媒体账号
|
//-----------------------------------------------------获取自媒体账号
|
||||||
//accountList, err := service.CastProvider.MediaUserList(context.Background(), &apiCast.MediaUserListReq{
|
accountList, err := service.CastProvider.MediaUserList(context.Background(), &apiCast.MediaUserListReq{
|
||||||
// ArtistUuid: strconv.FormatUint(list.UserList[0].Id, 10),
|
ArtistUuid: strconv.FormatUint(list.UserList[0].Id, 10),
|
||||||
// ArtistVal: req.ArtistName,
|
ArtistVal: req.ArtistName,
|
||||||
// Page: 1,
|
Page: 1,
|
||||||
// PageSize: 10,
|
PageSize: 10,
|
||||||
//})
|
})
|
||||||
//if err != nil {
|
if err != nil {
|
||||||
// return fmt.Errorf("自媒体账号数量获取失败: %s,账号数量:%d", err.Error(), len(accountList.Data))
|
return fmt.Errorf("自媒体账号数量获取失败: %s,账号数量:%d", err.Error(), len(accountList.Data))
|
||||||
//}
|
}
|
||||||
//if accountList == nil || len(accountList.Data) == 0 {
|
if accountList == nil || len(accountList.Data) == 0 {
|
||||||
// return fmt.Errorf("自媒体账号数量为0")
|
return fmt.Errorf("自媒体账号数量为0")
|
||||||
//}
|
}
|
||||||
//var mediaAccountUuids []string
|
var mediaAccountUuids []string
|
||||||
//var mediaAccountNames []string
|
var mediaAccountNames []string
|
||||||
//platformIDs 1 tiktok 2youtube 3ins
|
platformIDs := []apiCast.PlatformIDENUM{}
|
||||||
//platformIDs := []apiCast.PlatformIDENUM{}
|
for _, info := range accountList.Data {
|
||||||
//for _, info := range accountList.Data {
|
mediaAccountUuids = append(mediaAccountUuids, info.MediaAccountUuid)
|
||||||
// if info.ArtistName == req.TikTok || info.ArtistName == req.Instagram {
|
mediaAccountNames = append(mediaAccountNames, info.PlatformUserName)
|
||||||
// mediaAccountUuids = append(mediaAccountUuids, info.MediaAccountUuid)
|
platformIDs = append(platformIDs, apiCast.PlatformIDENUM(info.PlatformID))
|
||||||
// mediaAccountNames = append(mediaAccountNames, info.PlatformUserName)
|
}
|
||||||
// platformIDs = append(platformIDs, apiCast.PlatformIDENUM(info.PlatformID))
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
//---------------------------------------------------发布
|
//---------------------------------------------------发布
|
||||||
_, err = service.CastProvider.UpdateWorkImage(context.Background(), &apiCast.UpdateWorkImageReq{
|
_, err = service.CastProvider.UpdateWorkImage(context.Background(), &apiCast.UpdateWorkImageReq{
|
||||||
Title: req.Title,
|
Title: req.Title,
|
||||||
Content: req.Content,
|
Content: req.Content,
|
||||||
Images: req.GeneratePhotoUrl,
|
Images: req.GeneratePhotoUrl,
|
||||||
MediaAccountUuids: req.MediaAccountUuids,
|
MediaAccountUuids: mediaAccountUuids,
|
||||||
MediaAccountNames: req.MediaAccountNames,
|
MediaAccountNames: mediaAccountNames,
|
||||||
PlatformIDs: []apiCast.PlatformIDENUM{1, 3},
|
PlatformIDs: platformIDs,
|
||||||
PublishConfig1: &apiCast.PublishConfig{
|
PublishConfig1: &apiCast.PublishConfig{
|
||||||
CanComment: 1,
|
CanComment: 1,
|
||||||
CanJoin: 1,
|
CanJoin: 1,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user