diff --git a/internal/schema/simple_obj_info_schema.go b/internal/schema/simple_obj_info_schema.go index 28a7b775..8fa9c86a 100644 --- a/internal/schema/simple_obj_info_schema.go +++ b/internal/schema/simple_obj_info_schema.go @@ -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"` diff --git a/internal/service/comment/comment_service.go b/internal/service/comment/comment_service.go index 654ee9f3..3e3db499 100644 --- a/internal/service/comment/comment_service.go +++ b/internal/service/comment/comment_service.go @@ -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) diff --git a/internal/service/object_info/object_info.go b/internal/service/object_info/object_info.go index 5fbf55f7..feda14f9 100644 --- a/internal/service/object_info/object_info.go +++ b/internal/service/object_info/object_info.go @@ -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) diff --git a/internal/service/question_service.go b/internal/service/question_service.go index a1377882..25820563 100644 --- a/internal/service/question_service.go +++ b/internal/service/question_service.go @@ -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)]) } } diff --git a/internal/service/rank/rank_service.go b/internal/service/rank/rank_service.go index 534913d8..4ef63d00 100644 --- a/internal/service/rank/rank_service.go +++ b/internal/service/rank/rank_service.go @@ -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 } diff --git a/internal/service/vote_service.go b/internal/service/vote_service.go index 39d4282d..41ea00e5 100644 --- a/internal/service/vote_service.go +++ b/internal/service/vote_service.go @@ -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) }