Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

fix delete question

aichy126b7e6d3ee35c8
diff --git a/internal/controller/question_controller.go b/internal/controller/question_controller.go
index bdb39b89..203fbcf8 100644
--- a/internal/controller/question_controller.go
+++ b/internal/controller/question_controller.go
@@ -43,7 +43,7 @@ func (qc *QuestionController) RemoveQuestion(ctx *gin.Context) {
}
req.UserID = middleware.GetLoginUserIDFromContext(ctx)
if can, err := qc.rankService.CheckRankPermission(ctx, req.UserID, rank.QuestionDeleteRank); err != nil || !can {
- handler.HandleResponse(ctx, err, errors.Forbidden(reason.RankFailToMeetTheCondition))
+ handler.HandleResponse(ctx, errors.Forbidden(reason.RankFailToMeetTheCondition), errors.Forbidden(reason.RankFailToMeetTheCondition))
return
}
userinfo := middleware.GetUserInfoFromContext(ctx)
diff --git a/internal/service/question_service.go b/internal/service/question_service.go
index f13dee2c..e5012427 100644
--- a/internal/service/question_service.go
+++ b/internal/service/question_service.go
@@ -188,7 +188,7 @@ func (qs *QuestionService) RemoveQuestion(ctx context.Context, req *schema.Remov
if questionInfo.AcceptedAnswerID != "0" {
return errors.BadRequest(reason.QuestionCannotDeleted)
}
- if questionInfo.AnswerCount > 0 {
+ if questionInfo.AnswerCount > 1 {
return errors.BadRequest(reason.QuestionCannotDeleted)
}