Quellcode durchsuchen

weibo_data_list

Xingyu Xian vor 2 Tagen
Ursprung
Commit
3737e424b2
3 geänderte Dateien mit 38 neuen und 32 gelöschten Zeilen
  1. 1 1
      model/http_model/history_data_list.go
  2. 16 13
      service/s_t_cooperate.go
  3. 21 18
      service/talent_platform_link_info.go

+ 1 - 1
model/http_model/history_data_list.go

@@ -5,7 +5,7 @@ type HistoryDataListRequest struct {
 }
 
 type HistoryDataListData struct {
-	TalentLocalDataListInfo []*HistoryDataList `json:"talent_local_data_list_info"`
+	TalentLocalDataListInfo []*HistoryDataList `json:"history_data_info"`
 	Total                   int64              `json:"total"`
 }
 

+ 16 - 13
service/s_t_cooperate.go

@@ -285,20 +285,23 @@ func (*stcooperate) GetHistoryDataList(ctx context.Context, request *http_model.
 		return nil, platformUserErr
 	}
 	if platformUserInfo != nil {
-
 		// 2. 查找平台历史作品列表
-		historyList, err := GetWeiBoHistoryList(ctx, platformUserInfo.HomePageUrl)
-		if err != nil {
-			return nil, err
-		}
-		if historyList != nil {
-			for _, history := range historyList {
-				var historyResp *http_model.HistoryDataList
-				historyResp = &http_model.HistoryDataList{}
-				historyResp.CommitCount = history.Likes
-				historyResp.CommitCount = history.Comments
-				historyResp.CreatedAt = history.CreatedAt
-				historyRespList.TalentLocalDataListInfo = append(historyRespList.TalentLocalDataListInfo, historyResp)
+		if platformUserInfo.PlatformId == 1 {
+
+		} else if platformUserInfo.PlatformId == 3 {
+			historyList, err := GetWeiBoHistoryList(ctx, platformUserInfo.HomePageUrl)
+			if err != nil {
+				return nil, err
+			}
+			if historyList != nil {
+				for _, history := range historyList {
+					var historyResp *http_model.HistoryDataList
+					historyResp = &http_model.HistoryDataList{}
+					historyResp.CommitCount = history.Likes
+					historyResp.CommitCount = history.Comments
+					historyResp.CreatedAt = history.CreatedAt
+					historyRespList.TalentLocalDataListInfo = append(historyRespList.TalentLocalDataListInfo, historyResp)
+				}
 			}
 		}
 	}

+ 21 - 18
service/talent_platform_link_info.go

@@ -230,23 +230,25 @@ type WeiboPostsResponse struct {
 		Data struct {
 			Cards []struct {
 				Mblog struct {
-					Id              string   `json:"id"`
-					Text            string   `json:"text"`
-					CreatedAt       string   `json:"created_at"`
-					AttitudesCount  int      `json:"attitudes_count"`  // 点赞数
-					CommentsCount   int      `json:"comments_count"`   // 评论数
-					RepostsCount    int      `json:"reposts_count"`    // 转发数
-					PendingApproval int      `json:"pending_approval"` // 待审数
-					PicIds          []string `json:"pic_ids"`          // 图片ID列表
-					PageInfo        struct {
-						Type    string `json:"type"` // 内容类型(video/article)
-						PagePic struct {
-							Url string `json:"url"` // 封面图URL
-						} `json:"page_pic"`
-						MediaInfo struct {
-							StreamUrl string `json:"stream_url"` // 视频流地址
-						} `json:"media_info"`
-					} `json:"page_info"`
+					RetweetedStatus struct {
+						Id              string   `json:"id"`
+						Text            string   `json:"text"`
+						CreatedAt       string   `json:"created_at"`
+						AttitudesCount  int      `json:"attitudes_count"`  // 点赞数
+						CommentsCount   int      `json:"comments_count"`   // 评论数
+						RepostsCount    int      `json:"reposts_count"`    // 转发数
+						PendingApproval int      `json:"pending_approval"` // 待审数
+						PicIds          []string `json:"pic_ids"`          // 图片ID列表
+						PageInfo        struct {
+							Type    string `json:"type"` // 内容类型(video/article)
+							PagePic struct {
+								Url string `json:"url"` // 封面图URL
+							} `json:"page_pic"`
+							MediaInfo struct {
+								StreamUrl string `json:"stream_url"` // 视频流地址
+							} `json:"media_info"`
+						} `json:"page_info"`
+					} `json:"retweeted_status"`
 				} `json:"mblog"`
 			} `json:"cards"`
 		} `json:"data"`
@@ -284,7 +286,7 @@ func parseWeiboPosts(body []byte) ([]WeiboPostStats, error) {
 			break
 		}
 
-		mblog := card.Mblog
+		mblog := card.Mblog.RetweetedStatus
 		hasVideo := mblog.PageInfo.Type == "video"
 
 		posts = append(posts, WeiboPostStats{
@@ -303,6 +305,7 @@ func parseWeiboPosts(body []byte) ([]WeiboPostStats, error) {
 	return posts, nil
 }
 
+// GetWeiBoHistoryList 微博历史作品数据
 func GetWeiBoHistoryList(ctx context.Context, homePageUrl string) ([]WeiboPostStats, error) {
 	url := "http://120.46.92.62:6888/api/weibo/user_post" // 替换为实际API地址
 	method := "POST"