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.
feat(queued): add status:pending(quesiton/answer/comment),and change question status query
kumfo2ae98a69494d
diff --git a/internal/entity/answer_entity.go b/internal/entity/answer_entity.goindex e3520b8c..39a17ebf 100644--- a/internal/entity/answer_entity.go+++ b/internal/entity/answer_entity.go@@ -28,6 +28,7 @@ const (AnswerStatusAvailable = 1AnswerStatusDeleted = 10+ AnswerStatusPending = 11)var AdminAnswerSearchStatus = map[string]int{diff --git a/internal/entity/comment_entity.go b/internal/entity/comment_entity.goindex 37f51198..8b79663a 100644--- a/internal/entity/comment_entity.go+++ b/internal/entity/comment_entity.go@@ -30,6 +30,7 @@ import (const (CommentStatusAvailable = 1CommentStatusDeleted = 10+ CommentStatusPending = 11)// Comment commentdiff --git a/internal/entity/question_entity.go b/internal/entity/question_entity.goindex 2dd4ec2e..0e589aeb 100644--- a/internal/entity/question_entity.go+++ b/internal/entity/question_entity.go@@ -27,6 +27,7 @@ const (QuestionStatusAvailable = 1QuestionStatusClosed = 2QuestionStatusDeleted = 10+ QuestionStatusPending = 11QuestionUnPin = 1QuestionPin = 2QuestionShow = 1diff --git a/internal/migrations/v13.go b/internal/migrations/v13.goindex 2c2c80a6..4fcde381 100644--- a/internal/migrations/v13.go+++ b/internal/migrations/v13.go@@ -24,6 +24,7 @@ import ("encoding/json""fmt""time"+ "xorm.io/builder""github.com/apache/incubator-answer/internal/base/constant""github.com/apache/incubator-answer/internal/entity"@@ -184,7 +185,7 @@ func updateTagCount(ctx context.Context, x *xorm.Engine) error {questionsHideMap[item.ObjectID] = false}questionList := make([]QuestionV13, 0)- err = x.Context(ctx).In("id", questionIDs).In("question.status", []int{entity.QuestionStatusAvailable, entity.QuestionStatusClosed}).Find(&questionList, &QuestionV13{})+ err = x.Context(ctx).In("id", questionIDs).And(builder.Lt{"question.status": entity.QuestionStatusDeleted}).Find(&questionList, &QuestionV13{})if err != nil {return fmt.Errorf("get questions failed: %w", err)}@@ -256,7 +257,7 @@ func updateTagCount(ctx context.Context, x *xorm.Engine) error {// updateUserQuestionCount update user question countfunc updateUserQuestionCount(ctx context.Context, x *xorm.Engine) error {questionList := make([]QuestionV13, 0)- err := x.Context(ctx).In("status", []int{entity.QuestionStatusAvailable, entity.QuestionStatusClosed}).Find(&questionList, &QuestionV13{})+ err := x.Context(ctx).Where(builder.Lt{"status": entity.QuestionStatusDeleted}).Find(&questionList, &QuestionV13{})if err != nil {return fmt.Errorf("get question failed: %w", err)}diff --git a/internal/repo/question/question_repo.go b/internal/repo/question/question_repo.goindex 6c97620a..ee30929f 100644--- a/internal/repo/question/question_repo.go+++ b/internal/repo/question/question_repo.go@@ -276,7 +276,7 @@ func (qr *questionRepo) GetQuestionList(ctx context.Context, question *entity.Qufunc (qr *questionRepo) GetQuestionCount(ctx context.Context) (count int64, err error) {session := qr.data.DB.Context(ctx)- session.In("status", []int{entity.QuestionStatusAvailable, entity.QuestionStatusClosed})+ session.Where(builder.Lt{"status": entity.QuestionStatusDeleted})count, err = session.Count(&entity.Question{Show: entity.QuestionShow})if err != nil {return 0, errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()@@ -286,7 +286,7 @@ func (qr *questionRepo) GetQuestionCount(ctx context.Context) (count int64, errfunc (qr *questionRepo) GetUserQuestionCount(ctx context.Context, userID string) (count int64, err error) {session := qr.data.DB.Context(ctx)- session.In("status", []int{entity.QuestionStatusAvailable, entity.QuestionStatusClosed})+ session.Where(builder.Lt{"status": entity.QuestionStatusDeleted})count, err = session.Count(&entity.Question{UserID: userID})if err != nil {return count, errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()