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(search_repo): question accept status error

kumfo8b861b6fd7af
diff --git a/docs/docs.go b/docs/docs.go
index cce01432..1660ee72 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -2911,6 +2911,45 @@ const docTemplate = `{
}
}
},
+ "/answer/api/v1/post/render": {
+ "post": {
+ "security": [
+ {
+ "ApiKeyAuth": []
+ }
+ ],
+ "description": "render post content",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Upload"
+ ],
+ "summary": "render post content",
+ "parameters": [
+ {
+ "description": "PostRenderReq",
+ "name": "data",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/schema.PostRenderReq"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/handler.RespBody"
+ }
+ }
+ }
+ }
+ },
"/answer/api/v1/question": {
"put": {
"security": [
@@ -6589,6 +6628,14 @@ const docTemplate = `{
}
}
},
+ "schema.PostRenderReq": {
+ "type": "object",
+ "properties": {
+ "content": {
+ "type": "string"
+ }
+ }
+ },
"schema.QuestionAdd": {
"type": "object",
"required": [
diff --git a/docs/swagger.json b/docs/swagger.json
index 3503fce7..91ca0f4c 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -2899,6 +2899,45 @@
}
}
},
+ "/answer/api/v1/post/render": {
+ "post": {
+ "security": [
+ {
+ "ApiKeyAuth": []
+ }
+ ],
+ "description": "render post content",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Upload"
+ ],
+ "summary": "render post content",
+ "parameters": [
+ {
+ "description": "PostRenderReq",
+ "name": "data",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/schema.PostRenderReq"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/handler.RespBody"
+ }
+ }
+ }
+ }
+ },
"/answer/api/v1/question": {
"put": {
"security": [
@@ -6577,6 +6616,14 @@
}
}
},
+ "schema.PostRenderReq": {
+ "type": "object",
+ "properties": {
+ "content": {
+ "type": "string"
+ }
+ }
+ },
"schema.QuestionAdd": {
"type": "object",
"required": [
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index b02e9494..232fe850 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -976,6 +976,11 @@ definitions:
type:
type: string
type: object
+ schema.PostRenderReq:
+ properties:
+ content:
+ type: string
+ type: object
schema.QuestionAdd:
properties:
content:
@@ -3684,6 +3689,30 @@ paths:
summary: user's votes
tags:
- Activity
+ /answer/api/v1/post/render:
+ post:
+ consumes:
+ - application/json
+ description: render post content
+ parameters:
+ - description: PostRenderReq
+ in: body
+ name: data
+ required: true
+ schema:
+ $ref: '#/definitions/schema.PostRenderReq'
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/handler.RespBody'
+ security:
+ - ApiKeyAuth: []
+ summary: render post content
+ tags:
+ - Upload
/answer/api/v1/question:
delete:
consumes:
diff --git a/internal/repo/search_common/search_repo.go b/internal/repo/search_common/search_repo.go
index eac0620c..3f47d798 100644
--- a/internal/repo/search_common/search_repo.go
+++ b/internal/repo/search_common/search_repo.go
@@ -33,7 +33,7 @@ var (
"`user_id`",
"`vote_count`",
"`answer_count`",
- "0 as `accepted`",
+ "CASE WHEN `accepted_answer_id` >0 THEN 2 ELSE 0 END as `accepted`",
"`question`.`status` as `status`",
"`post_update_time`",
}