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.

update question answer delete status

aichy1266abb196e00f4
diff --git a/docs/docs.go b/docs/docs.go
index 41460363..1dedea4d 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -4066,22 +4066,7 @@ const docTemplate = `{
"200": {
"description": "OK",
"schema": {
- "allOf": [
- {
- "$ref": "#/definitions/handler.RespBody"
- },
- {
- "type": "object",
- "properties": {
- "data": {
- "type": "array",
- "items": {
- "$ref": "#/definitions/entity.Tag"
- }
- }
- }
- }
- ]
+ "$ref": "#/definitions/handler.RespBody"
}
}
}
@@ -5309,59 +5294,6 @@ const docTemplate = `{
}
},
"definitions": {
- "entity.Tag": {
- "type": "object",
- "properties": {
- "createdAt": {
- "type": "string"
- },
- "displayName": {
- "type": "string"
- },
- "followCount": {
- "type": "integer"
- },
- "id": {
- "type": "string"
- },
- "mainTagID": {
- "type": "integer"
- },
- "mainTagSlugName": {
- "type": "string"
- },
- "originalText": {
- "type": "string"
- },
- "parsedText": {
- "type": "string"
- },
- "questionCount": {
- "type": "integer"
- },
- "recommend": {
- "type": "boolean"
- },
- "reserved": {
- "type": "boolean"
- },
- "revisionID": {
- "type": "string"
- },
- "slugName": {
- "type": "string"
- },
- "status": {
- "type": "integer"
- },
- "updatedAt": {
- "type": "string"
- },
- "userID": {
- "type": "string"
- }
- }
- },
"handler.RespBody": {
"type": "object",
"properties": {
diff --git a/docs/swagger.json b/docs/swagger.json
index abcceeae..ca8d737d 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -4054,22 +4054,7 @@
"200": {
"description": "OK",
"schema": {
- "allOf": [
- {
- "$ref": "#/definitions/handler.RespBody"
- },
- {
- "type": "object",
- "properties": {
- "data": {
- "type": "array",
- "items": {
- "$ref": "#/definitions/entity.Tag"
- }
- }
- }
- }
- ]
+ "$ref": "#/definitions/handler.RespBody"
}
}
}
@@ -5297,59 +5282,6 @@
}
},
"definitions": {
- "entity.Tag": {
- "type": "object",
- "properties": {
- "createdAt": {
- "type": "string"
- },
- "displayName": {
- "type": "string"
- },
- "followCount": {
- "type": "integer"
- },
- "id": {
- "type": "string"
- },
- "mainTagID": {
- "type": "integer"
- },
- "mainTagSlugName": {
- "type": "string"
- },
- "originalText": {
- "type": "string"
- },
- "parsedText": {
- "type": "string"
- },
- "questionCount": {
- "type": "integer"
- },
- "recommend": {
- "type": "boolean"
- },
- "reserved": {
- "type": "boolean"
- },
- "revisionID": {
- "type": "string"
- },
- "slugName": {
- "type": "string"
- },
- "status": {
- "type": "integer"
- },
- "updatedAt": {
- "type": "string"
- },
- "userID": {
- "type": "string"
- }
- }
- },
"handler.RespBody": {
"type": "object",
"properties": {
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index cc8260ed..da69a617 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -1,39 +1,4 @@
definitions:
- entity.Tag:
- properties:
- createdAt:
- type: string
- displayName:
- type: string
- followCount:
- type: integer
- id:
- type: string
- mainTagID:
- type: integer
- mainTagSlugName:
- type: string
- originalText:
- type: string
- parsedText:
- type: string
- questionCount:
- type: integer
- recommend:
- type: boolean
- reserved:
- type: boolean
- revisionID:
- type: string
- slugName:
- type: string
- status:
- type: integer
- updatedAt:
- type: string
- userID:
- type: string
- type: object
handler.RespBody:
properties:
code:
@@ -4403,14 +4368,7 @@ paths:
"200":
description: OK
schema:
- allOf:
- - $ref: '#/definitions/handler.RespBody'
- - properties:
- data:
- items:
- $ref: '#/definitions/entity.Tag'
- type: array
- type: object
+ $ref: '#/definitions/handler.RespBody'
summary: get tags list
tags:
- Tag
diff --git a/internal/controller/tag_controller.go b/internal/controller/tag_controller.go
index 03a3669b..bc2a9a5b 100644
--- a/internal/controller/tag_controller.go
+++ b/internal/controller/tag_controller.go
@@ -56,7 +56,7 @@ func (tc *TagController) SearchTagLike(ctx *gin.Context) {
// @Tags Tag
// @Produce json
// @Param tags query []string false "string collection" collectionFormat(csv)
-// @Success 200 {object} handler.RespBody{data=[]*schema.TagItem}
+// @Success 200 {object} handler.RespBody{}
// @Router /answer/api/v1/tags [get]
func (tc *TagController) GetTagsBySlugName(ctx *gin.Context) {
req := &schema.SearchTagsBySlugName{}
diff --git a/internal/service/answer_service.go b/internal/service/answer_service.go
index 4056b627..974482c9 100644
--- a/internal/service/answer_service.go
+++ b/internal/service/answer_service.go
@@ -78,6 +78,10 @@ func (as *AnswerService) RemoveAnswer(ctx context.Context, req *schema.RemoveAns
if !exist {
return nil
}
+ // if the status is deleted, return directly
+ if answerInfo.Status == entity.AnswerStatusDeleted {
+ return nil
+ }
if !req.IsAdmin {
if answerInfo.UserID != req.UserID {
return errors.BadRequest(reason.AnswerCannotDeleted)
diff --git a/internal/service/question_service.go b/internal/service/question_service.go
index 63a11596..a5b2d681 100644
--- a/internal/service/question_service.go
+++ b/internal/service/question_service.go
@@ -323,6 +323,10 @@ func (qs *QuestionService) RemoveQuestion(ctx context.Context, req *schema.Remov
if err != nil {
return err
}
+ //if the status is deleted, return directly
+ if questionInfo.Status == entity.QuestionStatusDeleted {
+ return nil
+ }
if !has {
return nil
}