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.
pass pointer instead of slice to Find(...) method
Nikita Sivukhin6d84720404e4
diff --git a/internal/repo/answer/answer_repo.go b/internal/repo/answer/answer_repo.goindex 2c2787f6..35de6c17 100644--- a/internal/repo/answer/answer_repo.go+++ b/internal/repo/answer/answer_repo.go@@ -198,7 +198,7 @@ func (ar *answerRepo) GetAnswerList(ctx context.Context, answer *entity.Answer)answerList = make([]*entity.Answer, 0)answer.ID = uid.DeShortID(answer.ID)answer.QuestionID = uid.DeShortID(answer.QuestionID)- err = ar.data.DB.Context(ctx).Find(answerList, answer)+ err = ar.data.DB.Context(ctx).Find(&answerList, answer)if err != nil {err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()}@@ -216,7 +216,7 @@ func (ar *answerRepo) GetAnswerPage(ctx context.Context, page, pageSize int, ansanswer.ID = uid.DeShortID(answer.ID)answer.QuestionID = uid.DeShortID(answer.QuestionID)answerList = make([]*entity.Answer, 0)- total, err = pager.Help(page, pageSize, answerList, answer, ar.data.DB.Context(ctx))+ total, err = pager.Help(page, pageSize, &answerList, answer, ar.data.DB.Context(ctx))if err != nil {err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()}diff --git a/internal/repo/collection/collection_repo.go b/internal/repo/collection/collection_repo.goindex 1aecaf47..a3faacdb 100644--- a/internal/repo/collection/collection_repo.go+++ b/internal/repo/collection/collection_repo.go@@ -108,7 +108,7 @@ func (cr *collectionRepo) GetCollection(ctx context.Context, id int) (collection// GetCollectionList get collection list allfunc (cr *collectionRepo) GetCollectionList(ctx context.Context, collection *entity.Collection) (collectionList []*entity.Collection, err error) {collectionList = make([]*entity.Collection, 0)- err = cr.data.DB.Context(ctx).Find(collectionList, collection)+ err = cr.data.DB.Context(ctx).Find(&collectionList, collection)err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()return}diff --git a/internal/repo/question/question_repo.go b/internal/repo/question/question_repo.goindex 117ee38f..c144411b 100644--- a/internal/repo/question/question_repo.go+++ b/internal/repo/question/question_repo.go@@ -272,7 +272,7 @@ func (qr *questionRepo) FindByID(ctx context.Context, id []string) (questionListfunc (qr *questionRepo) GetQuestionList(ctx context.Context, question *entity.Question) (questionList []*entity.Question, err error) {question.ID = uid.DeShortID(question.ID)questionList = make([]*entity.Question, 0)- err = qr.data.DB.Context(ctx).Find(questionList, question)+ err = qr.data.DB.Context(ctx).Find(&questionList, question)if err != nil {return questionList, errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()}diff --git a/internal/repo/role/power_repo.go b/internal/repo/role/power_repo.goindex 8da7c663..bbd600e9 100644--- a/internal/repo/role/power_repo.go+++ b/internal/repo/role/power_repo.go@@ -44,7 +44,7 @@ func NewPowerRepo(data *data.Data) role.PowerRepo {// GetPowerList get list allfunc (pr *powerRepo) GetPowerList(ctx context.Context, power *entity.Power) (powerList []*entity.Power, err error) {powerList = make([]*entity.Power, 0)- err = pr.data.DB.Context(ctx).Find(powerList, power)+ err = pr.data.DB.Context(ctx).Find(&powerList, power)if err != nil {err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()}