diff --git a/internal/service/answer_service.go b/internal/service/answer_service.go index 78d727dc..2e9020e7 100644 --- a/internal/service/answer_service.go +++ b/internal/service/answer_service.go @@ -224,6 +224,7 @@ func (as *AnswerService) Update(ctx context.Context, req *schema.AnswerUpdateReq now := time.Now() insertData := new(entity.Answer) insertData.ID = req.ID + insertData.UserID = answerInfo.UserID insertData.QuestionID = req.QuestionID insertData.OriginalText = req.Content insertData.ParsedText = req.HTML diff --git a/internal/service/question_service.go b/internal/service/question_service.go index 37178a5a..6997109e 100644 --- a/internal/service/question_service.go +++ b/internal/service/question_service.go @@ -282,6 +282,14 @@ func (qs *QuestionService) UpdateQuestion(ctx context.Context, req *schema.Quest return } + dbinfo, has, err := qs.questionRepo.GetQuestion(ctx, req.ID) + if err != nil { + return + } + if !has { + return + } + now := time.Now() question := &entity.Question{} question.Title = req.Title @@ -290,13 +298,8 @@ func (qs *QuestionService) UpdateQuestion(ctx context.Context, req *schema.Quest question.ID = req.ID question.UpdatedAt = now question.PostUpdateTime = now - dbinfo, has, err := qs.questionRepo.GetQuestion(ctx, question.ID) - if err != nil { - return - } - if !has { - return - } + question.UserID = dbinfo.UserID + question.LastEditUserID = "0" if dbinfo.UserID != req.UserID { question.LastEditUserID = req.UserID