(ctx context.Context, data *entity.Question)
| 640 | } |
| 641 | |
| 642 | func (qs *QuestionCommon) ShowFormat(ctx context.Context, data *entity.Question) *schema.QuestionInfoResp { |
| 643 | info := schema.QuestionInfoResp{} |
| 644 | info.ID = data.ID |
| 645 | if handler.GetEnableShortID(ctx) { |
| 646 | info.ID = uid.EnShortID(data.ID) |
| 647 | } |
| 648 | info.Title = data.Title |
| 649 | info.UrlTitle = htmltext.UrlTitle(data.Title) |
| 650 | info.Content = data.OriginalText |
| 651 | info.HTML = data.ParsedText |
| 652 | info.ViewCount = data.ViewCount |
| 653 | info.UniqueViewCount = data.UniqueViewCount |
| 654 | info.VoteCount = data.VoteCount |
| 655 | info.AnswerCount = data.AnswerCount |
| 656 | info.CollectionCount = data.CollectionCount |
| 657 | info.FollowCount = data.FollowCount |
| 658 | info.AcceptedAnswerID = data.AcceptedAnswerID |
| 659 | info.LastAnswerID = data.LastAnswerID |
| 660 | info.CreateTime = data.CreatedAt.Unix() |
| 661 | info.UpdateTime = data.UpdatedAt.Unix() |
| 662 | info.PostUpdateTime = data.PostUpdateTime.Unix() |
| 663 | if data.PostUpdateTime.Unix() < 1 { |
| 664 | info.PostUpdateTime = 0 |
| 665 | } |
| 666 | info.QuestionUpdateTime = data.UpdatedAt.Unix() |
| 667 | if data.UpdatedAt.Unix() < 1 { |
| 668 | info.QuestionUpdateTime = 0 |
| 669 | } |
| 670 | info.Status = data.Status |
| 671 | info.Pin = data.Pin |
| 672 | info.Show = data.Show |
| 673 | info.UserID = data.UserID |
| 674 | info.LastEditUserID = data.LastEditUserID |
| 675 | if data.LastAnswerID != "0" { |
| 676 | answerInfo, exist, err := qs.answerRepo.GetAnswer(ctx, data.LastAnswerID) |
| 677 | if err == nil && exist { |
| 678 | if answerInfo.LastEditUserID != "0" { |
| 679 | info.LastAnsweredUserID = answerInfo.LastEditUserID |
| 680 | } else { |
| 681 | info.LastAnsweredUserID = answerInfo.UserID |
| 682 | } |
| 683 | } |
| 684 | } |
| 685 | info.Tags = make([]*schema.TagResp, 0) |
| 686 | return &info |
| 687 | } |
| 688 | func (qs *QuestionCommon) ShowFormatWithTag(ctx context.Context, data *entity.QuestionWithTagsRevision) *schema.QuestionInfoResp { |
| 689 | info := qs.ShowFormat(ctx, &data.Question) |
| 690 | Tags := make([]*schema.TagResp, 0) |
no test coverage detected