diff --git a/pkg/service/import/artist.go b/pkg/service/import/artist.go index c4be75f..3dac408 100644 --- a/pkg/service/import/artist.go +++ b/pkg/service/import/artist.go @@ -16,7 +16,7 @@ type ArtistMedia struct { Video string `json:"video"` } -type failedRecord struct { - name string - msg string +type FailedRecord struct { + Name string `json:"name"` + Msg string `json:"msg"` } diff --git a/pkg/service/import/binding.go b/pkg/service/import/binding.go index 91bf633..241823c 100644 --- a/pkg/service/import/binding.go +++ b/pkg/service/import/binding.go @@ -27,7 +27,7 @@ type artu struct { } func ImportBind(c *gin.Context) { - var failedRecords []failedRecord + var failedRecords []FailedRecord // 1. 上传文件 excelFile, err := c.FormFile("excel") if err != nil { @@ -61,9 +61,9 @@ func ImportBind(c *gin.Context) { Name: artist.Name, }) if err != nil { - failedRecords = append(failedRecords, failedRecord{ - name: artist.Name, - msg: fmt.Sprintf("获取用户信息失败: %s", err.Error()), + failedRecords = append(failedRecords, FailedRecord{ + Name: artist.Name, + Msg: fmt.Sprintf("获取用户信息失败: %s", err.Error()), }) log.Printf(fmt.Sprintf("获取用户信息失败: %s", err.Error())) continue @@ -78,9 +78,9 @@ func ImportBind(c *gin.Context) { Domain: "app", }) if err != nil { - failedRecords = append(failedRecords, failedRecord{ - name: artist.Name, - msg: fmt.Sprintf("查询艺人的信息失败: %s", err.Error()), + failedRecords = append(failedRecords, FailedRecord{ + Name: artist.Name, + Msg: fmt.Sprintf("查询艺人的信息失败: %s", err.Error()), }) log.Printf(fmt.Sprintf("查询艺人的信息失败: %s", err.Error())) continue @@ -92,17 +92,17 @@ func ImportBind(c *gin.Context) { } } if _, ok := apiCast.PlatformIDENUM_name[int32(accountType)]; !ok { - failedRecords = append(failedRecords, failedRecord{ - name: artist.Name, - msg: errors.New("查询平台信息失败:").Error(), + failedRecords = append(failedRecords, FailedRecord{ + Name: artist.Name, + Msg: errors.New("查询平台信息失败:").Error(), }) log.Printf(errors.New("查询平台信息失败:").Error()) continue } if err = cast.CheckUserBundleBalance(int32(res.UserList[0].Id), modelCast.BalanceTypeAccountValue); err != nil { - failedRecords = append(failedRecords, failedRecord{ - name: artist.Name, - msg: fmt.Sprintf("查询检查用户账户数量失败: %s", err.Error()), + failedRecords = append(failedRecords, FailedRecord{ + Name: artist.Name, + Msg: fmt.Sprintf("查询检查用户账户数量失败: %s", err.Error()), }) log.Printf(fmt.Sprintf("查询检查用户账户数量失败: %s", err.Error())) continue @@ -112,9 +112,9 @@ func ImportBind(c *gin.Context) { AccountConsumptionNumber: 1, }) if err != nil { - failedRecords = append(failedRecords, failedRecord{ - name: artist.Name, - msg: fmt.Sprintf("增加账户数量失败: %s", err.Error()), + failedRecords = append(failedRecords, FailedRecord{ + Name: artist.Name, + Msg: fmt.Sprintf("增加账户数量失败: %s", err.Error()), }) log.Printf(fmt.Sprintf("增加账户数量失败: %s", err.Error())) continue @@ -129,18 +129,18 @@ func ImportBind(c *gin.Context) { ArtistPhoneAreaCode: infoResp.TelAreaCode, }) if err != nil { - failedRecords = append(failedRecords, failedRecord{ - name: artist.Name, - msg: fmt.Sprintf("绑定账户信息失败: %s", err.Error()), + failedRecords = append(failedRecords, FailedRecord{ + Name: artist.Name, + Msg: fmt.Sprintf("绑定账户信息失败: %s", err.Error()), }) log.Printf(fmt.Sprintf("绑定账户信息失败: %s", err.Error())) _, err = service.BundleProvider.AddBundleBalance(context.Background(), &bundle.AddBundleBalanceReq{ UserId: int32(res.UserList[0].Id), AccountConsumptionNumber: -1, }) - failedRecords = append(failedRecords, failedRecord{ - name: artist.Name, - msg: fmt.Sprintf("绑定失败后减少余额失败: %s", err.Error()), + failedRecords = append(failedRecords, FailedRecord{ + Name: artist.Name, + Msg: fmt.Sprintf("绑定失败后减少余额失败: %s", err.Error()), }) log.Println(fmt.Sprintf("绑定失败后减少余额失败: %s", err.Error()), errors.New(e.GetMsg(e.InvalidParams))) continue diff --git a/pkg/service/import/confirm.go b/pkg/service/import/confirm.go index 5cad281..82ce8f4 100644 --- a/pkg/service/import/confirm.go +++ b/pkg/service/import/confirm.go @@ -28,15 +28,15 @@ func WorkConfirm(c *gin.Context) { // 确认作品并扣除余量 return } //遍历更新状态 - var failedRecords []failedRecord + var failedRecords []FailedRecord for _, v := range list.Data { res, err := service.AccountFieeProvider.UserList(context.Background(), &account.UserListRequest{ Name: v.ArtistName, }) if err != nil { - failedRecords = append(failedRecords, failedRecord{ - name: v.ArtistName, - msg: fmt.Sprintf("获取用户信息失败: %s", err.Error()), + failedRecords = append(failedRecords, FailedRecord{ + Name: v.ArtistName, + Msg: fmt.Sprintf("获取用户信息失败: %s", err.Error()), }) log.Printf(fmt.Sprintf("获取用户信息失败: %s", err.Error())) continue diff --git a/pkg/service/import/publish.go b/pkg/service/import/publish.go index 207c4de..d54aab6 100644 --- a/pkg/service/import/publish.go +++ b/pkg/service/import/publish.go @@ -84,7 +84,7 @@ func ImportPublish(c *gin.Context) { return } // 5.发布视频 - var failedRecords []failedRecord + var failedRecords []FailedRecord for _, artist := range artists { var infoResp *accountFiee.UserInfoResponse var err error @@ -92,9 +92,9 @@ func ImportPublish(c *gin.Context) { Name: artist.Name, }) if err != nil { - failedRecords = append(failedRecords, failedRecord{ - name: artist.Name, - msg: fmt.Sprintf("获取用户信息失败: %s", err.Error()), + failedRecords = append(failedRecords, FailedRecord{ + Name: artist.Name, + Msg: fmt.Sprintf("获取用户信息失败: %s", err.Error()), }) log.Printf(fmt.Sprintf("获取用户信息失败: %s", err.Error())) continue @@ -105,21 +105,21 @@ func ImportPublish(c *gin.Context) { Domain: "app", }) if err != nil { - failedRecords = append(failedRecords, failedRecord{ - name: artist.Name, - msg: fmt.Sprintf("获取用户信息失败: %s", err.Error()), + failedRecords = append(failedRecords, FailedRecord{ + Name: artist.Name, + Msg: fmt.Sprintf("获取用户信息失败: %s", err.Error()), }) log.Printf(fmt.Sprintf("获取用户信息失败: %s", err.Error())) continue } } - if err = cast.CheckUserBundleBalance(int32(list.UserList[0].Id), modelCast.BalanceTypeAccountValue); err != nil { - failedRecords = append(failedRecords, failedRecord{ - name: artist.Name, - msg: fmt.Sprintf("检查用户账户数量: %s", err.Error()), + if err = cast.CheckUserBundleBalance(int32(list.UserList[0].Id), modelCast.BalanceTypeVideoValue); err != nil { + failedRecords = append(failedRecords, FailedRecord{ + Name: artist.Name, + Msg: fmt.Sprintf("检查用户视频可消耗数量: %s", err.Error()), }) - log.Printf(fmt.Sprintf("检查用户账户数量: %s", err.Error())) + log.Printf(fmt.Sprintf("检查用户视频可消耗数量: %s", err.Error())) continue } //自媒体账号 @@ -127,9 +127,9 @@ func ImportPublish(c *gin.Context) { ArtistUuid: strconv.FormatUint(list.UserList[0].Id, 10), }) if err != nil || accountList == nil { - failedRecords = append(failedRecords, failedRecord{ - name: artist.Name, - msg: fmt.Sprintf("自媒体账号数量获取失败: %s,账号数量:%d", err.Error(), len(accountList.Data)), + failedRecords = append(failedRecords, FailedRecord{ + Name: artist.Name, + Msg: fmt.Sprintf("自媒体账号数量获取失败: %s,账号数量:%d", err.Error(), len(accountList.Data)), }) log.Printf(fmt.Sprintf("自媒体账号数量获取失败: %s,账号数量:%d", err.Error(), len(accountList.Data))) continue @@ -183,9 +183,9 @@ func ImportPublish(c *gin.Context) { Source: 2, }) if err != nil { - failedRecords = append(failedRecords, failedRecord{ - name: artist.Name, - msg: fmt.Sprintf("发布"+artist.Name+"视频"+artist.Title+"失败: %s", err.Error()), + failedRecords = append(failedRecords, FailedRecord{ + Name: artist.Name, + Msg: fmt.Sprintf("发布"+artist.Name+"视频"+artist.Title+"失败: %s", err.Error()), }) log.Printf(fmt.Sprintf("发布"+artist.Name+"视频"+artist.Title+"失败: %s", err.Error())) continue