update question answer delete status

This commit is contained in:
aichy126 2023-02-15 15:01:58 +08:00
parent a2b036cc16
commit 6abb196e00
6 changed files with 12 additions and 182 deletions

View File

@ -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": {

View File

@ -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": {

View File

@ -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

View File

@ -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{}

View File

@ -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)

View File

@ -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
}