From 483adb21980223a47c99917cf6c55eac81792b6f Mon Sep 17 00:00:00 2001 From: aichy Date: Thu, 29 Sep 2022 10:37:20 +0800 Subject: [PATCH 1/2] fix --- internal/repo/answer_repo.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/repo/answer_repo.go b/internal/repo/answer_repo.go index 402ab3a7..e9e117b5 100644 --- a/internal/repo/answer_repo.go +++ b/internal/repo/answer_repo.go @@ -184,7 +184,7 @@ func (ar *answerRepo) SearchList(ctx context.Context, search *entity.AnswerSearc session = session.And("user_id = ?", search.UserID) } if search.Order == entity.Answer_Search_OrderBy_Time { - session = session.OrderBy("updated_at desc") + session = session.OrderBy("created_at desc") } else if search.Order == entity.Answer_Search_OrderBy_Vote { session = session.OrderBy("vote_count desc") } else { @@ -194,7 +194,7 @@ func (ar *answerRepo) SearchList(ctx context.Context, search *entity.AnswerSearc session = session.And("status = ?", entity.AnswerStatusAvailable) session = session.Limit(search.PageSize, offset) - count, err = session.OrderBy("updated_at desc").FindAndCount(&rows) + count, err = session.FindAndCount(&rows) if err != nil { return rows, count, errors.InternalServer(reason.DatabaseError).WithError(err).WithStack() } From 58a81848db71fd1d128abd4882ee36def2c1b336 Mon Sep 17 00:00:00 2001 From: aichy Date: Thu, 29 Sep 2022 10:38:17 +0800 Subject: [PATCH 2/2] swagger --- docs/docs.go | 2 +- docs/swagger.json | 2 +- docs/swagger.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/docs.go b/docs/docs.go index e09a2ac8..6a96d93a 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -884,7 +884,7 @@ const docTemplate = `{ } }, "/answer/api/v1/answer/list": { - "post": { + "get": { "security": [ { "ApiKeyAuth": [] diff --git a/docs/swagger.json b/docs/swagger.json index 9feff4b0..414e874a 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -872,7 +872,7 @@ } }, "/answer/api/v1/answer/list": { - "post": { + "get": { "security": [ { "ApiKeyAuth": [] diff --git a/docs/swagger.yaml b/docs/swagger.yaml index ba4fed36..d07ebf1a 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -1877,7 +1877,7 @@ paths: tags: - api-answer /answer/api/v1/answer/list: - post: + get: consumes: - application/json description: AnswerList
order (default or updated)