(ctx context.Context, item *schema.GetRevisionResp)
| 427 | } |
| 428 | |
| 429 | func (rs *RevisionService) parseItem(ctx context.Context, item *schema.GetRevisionResp) { |
| 430 | var ( |
| 431 | err error |
| 432 | question entity.QuestionWithTagsRevision |
| 433 | questionInfo *schema.QuestionInfoResp |
| 434 | answer entity.Answer |
| 435 | answerInfo *schema.AnswerInfo |
| 436 | tag entity.Tag |
| 437 | tagInfo *schema.GetTagResp |
| 438 | ) |
| 439 | |
| 440 | shortID := handler.GetEnableShortID(ctx) |
| 441 | if shortID { |
| 442 | item.ObjectID = uid.EnShortID(item.ObjectID) |
| 443 | } |
| 444 | switch item.ObjectType { |
| 445 | case constant.ObjectTypeStrMapping["question"]: |
| 446 | err = json.Unmarshal([]byte(item.Content), &question) |
| 447 | if err != nil { |
| 448 | break |
| 449 | } |
| 450 | questionInfo = rs.questionCommon.ShowFormatWithTag(ctx, &question) |
| 451 | if shortID { |
| 452 | questionInfo.ID = uid.EnShortID(questionInfo.ID) |
| 453 | } |
| 454 | item.ContentParsed = questionInfo |
| 455 | case constant.ObjectTypeStrMapping["answer"]: |
| 456 | err = json.Unmarshal([]byte(item.Content), &answer) |
| 457 | if err != nil { |
| 458 | break |
| 459 | } |
| 460 | answerInfo = rs.answerService.ShowFormat(ctx, &answer) |
| 461 | if shortID { |
| 462 | answerInfo.ID = uid.EnShortID(answerInfo.ID) |
| 463 | answerInfo.QuestionID = uid.EnShortID(answerInfo.QuestionID) |
| 464 | } |
| 465 | item.ContentParsed = answerInfo |
| 466 | case constant.ObjectTypeStrMapping["tag"]: |
| 467 | err = json.Unmarshal([]byte(item.Content), &tag) |
| 468 | if err != nil { |
| 469 | break |
| 470 | } |
| 471 | tagInfo = &schema.GetTagResp{ |
| 472 | TagID: tag.ID, |
| 473 | CreatedAt: tag.CreatedAt.Unix(), |
| 474 | UpdatedAt: tag.UpdatedAt.Unix(), |
| 475 | SlugName: tag.SlugName, |
| 476 | DisplayName: tag.DisplayName, |
| 477 | OriginalText: tag.OriginalText, |
| 478 | ParsedText: tag.ParsedText, |
| 479 | FollowCount: tag.FollowCount, |
| 480 | QuestionCount: tag.QuestionCount, |
| 481 | Recommend: tag.Recommend, |
| 482 | Reserved: tag.Reserved, |
| 483 | } |
| 484 | tagInfo.GetExcerpt() |
| 485 | item.ContentParsed = tagInfo |
| 486 | } |
no test coverage detected