update show Deleted question

This commit is contained in:
aichy126
2023-05-19 15:58:56 +08:00
parent 5b649e4392
commit 5e33c28146
6 changed files with 22 additions and 2 deletions
@@ -5,6 +5,7 @@ type SimpleObjectInfo struct {
ObjectID string `json:"object_id"`
ObjectCreatorUserID string `json:"object_creator_user_id"`
QuestionID string `json:"question_id"`
QuestionStatus int `json:"status"`
AnswerID string `json:"answer_id"`
CommentID string `json:"comment_id"`
TagID string `json:"tag_id"`
@@ -452,6 +452,9 @@ func (cs *CommentService) GetCommentPersonalWithPage(ctx context.Context, req *s
commentResp.UrlTitle = htmltext.UrlTitle(objInfo.Title)
commentResp.QuestionID = objInfo.QuestionID
commentResp.AnswerID = objInfo.AnswerID
if objInfo.QuestionStatus == entity.QuestionStatusDeleted {
commentResp.Title = "Deleted question"
}
}
}
resp = append(resp, commentResp)
@@ -135,6 +135,7 @@ func (os *ObjService) GetInfo(ctx context.Context, objectID string) (objInfo *sc
ObjectID: questionInfo.ID,
ObjectCreatorUserID: questionInfo.UserID,
QuestionID: questionInfo.ID,
QuestionStatus: questionInfo.Status,
ObjectType: objectType,
Title: questionInfo.Title,
Content: questionInfo.ParsedText, // todo trim
@@ -158,6 +159,7 @@ func (os *ObjService) GetInfo(ctx context.Context, objectID string) (objInfo *sc
ObjectID: answerInfo.ID,
ObjectCreatorUserID: answerInfo.UserID,
QuestionID: answerInfo.QuestionID,
QuestionStatus: questionInfo.Status,
AnswerID: answerInfo.ID,
ObjectType: objectType,
Title: questionInfo.Title, // this should be question title
@@ -185,6 +187,7 @@ func (os *ObjService) GetInfo(ctx context.Context, objectID string) (objInfo *sc
}
if exist {
objInfo.QuestionID = questionInfo.ID
objInfo.QuestionStatus = questionInfo.Status
objInfo.Title = questionInfo.Title
}
answerInfo, exist, err := os.answerRepo.GetAnswer(ctx, commentInfo.ObjectID)
+9 -2
View File
@@ -853,14 +853,18 @@ func (qs *QuestionService) PersonalAnswerPage(ctx context.Context, req *schema.P
_, ok := questionMaps[item.QuestionID]
if ok {
item.QuestionInfo = questionMaps[item.QuestionID]
} else {
continue
}
info := &schema.UserAnswerInfo{}
_ = copier.Copy(info, item)
info.AnswerID = item.ID
info.QuestionID = item.QuestionID
if item.QuestionInfo.Status != entity.QuestionStatusDeleted {
userAnswerlist = append(userAnswerlist, info)
if item.QuestionInfo.Status == entity.QuestionStatusDeleted {
info.QuestionInfo.Title = "Deleted question"
}
userAnswerlist = append(userAnswerlist, info)
}
return pager.NewPageModel(total, userAnswerlist), nil
@@ -894,6 +898,9 @@ func (qs *QuestionService) PersonalCollectionPage(ctx context.Context, req *sche
questionMaps[uid.EnShortID(id)].UpdateUserInfo = nil
questionMaps[uid.EnShortID(id)].Content = ""
questionMaps[uid.EnShortID(id)].HTML = ""
if questionMaps[uid.EnShortID(id)].Status == entity.QuestionStatusDeleted {
questionMaps[uid.EnShortID(id)].Title = "Deleted question"
}
list = append(list, questionMaps[uid.EnShortID(id)])
}
}
+3
View File
@@ -269,6 +269,9 @@ func (rs *RankService) GetRankPersonalWithPage(ctx context.Context, req *schema.
commentResp.Title = objInfo.Title
commentResp.UrlTitle = htmltext.UrlTitle(objInfo.Title)
commentResp.Content = objInfo.Content
if objInfo.QuestionStatus == entity.QuestionStatusDeleted {
commentResp.Title = "Deleted question"
}
commentResp.QuestionID = objInfo.QuestionID
commentResp.AnswerID = objInfo.AnswerID
}
+3
View File
@@ -195,6 +195,9 @@ func (vs *VoteService) ListUserVotes(ctx context.Context, req schema.GetVoteWith
Content: objInfo.Content,
VoteType: activity_type.Format(voteInfo.ActivityType),
}
if objInfo.QuestionStatus == entity.QuestionStatusDeleted {
item.Title = "Deleted question"
}
resp = append(resp, item)
}