update question answer del

This commit is contained in:
aichy126 2023-03-01 17:49:55 +08:00
parent c3d8d30892
commit ba7891b097
5 changed files with 54 additions and 19 deletions

View File

@ -1,5 +1,4 @@
// Package docs GENERATED BY SWAG; DO NOT EDIT
// This file was generated by swaggo/swag
// Code generated by swaggo/swag. DO NOT EDIT
package docs
import "github.com/swaggo/swag"
@ -5984,9 +5983,6 @@ const docTemplate = `{
"schema.GetOtherUserInfoResp": {
"type": "object",
"properties": {
"has": {
"type": "boolean"
},
"info": {
"$ref": "#/definitions/schema.GetOtherUserInfoByUsernameResp"
}
@ -6986,7 +6982,11 @@ const docTemplate = `{
},
"user_info": {
"description": "user info",
"$ref": "#/definitions/schema.UserBasicInfo"
"allOf": [
{
"$ref": "#/definitions/schema.UserBasicInfo"
}
]
},
"vote_count": {
"type": "integer"
@ -6998,7 +6998,11 @@ const docTemplate = `{
"properties": {
"object": {
"description": "this object",
"$ref": "#/definitions/schema.SearchObject"
"allOf": [
{
"$ref": "#/definitions/schema.SearchObject"
}
]
},
"object_type": {
"description": "object_type",
@ -7173,6 +7177,9 @@ const docTemplate = `{
},
"theme": {
"$ref": "#/definitions/schema.SiteThemeResp"
},
"version": {
"type": "string"
}
}
},
@ -7508,7 +7515,11 @@ const docTemplate = `{
"properties": {
"avatar": {
"description": "avatar",
"$ref": "#/definitions/schema.AvatarInfo"
"allOf": [
{
"$ref": "#/definitions/schema.AvatarInfo"
}
]
},
"bio": {
"description": "bio",

View File

@ -5972,9 +5972,6 @@
"schema.GetOtherUserInfoResp": {
"type": "object",
"properties": {
"has": {
"type": "boolean"
},
"info": {
"$ref": "#/definitions/schema.GetOtherUserInfoByUsernameResp"
}
@ -6974,7 +6971,11 @@
},
"user_info": {
"description": "user info",
"$ref": "#/definitions/schema.UserBasicInfo"
"allOf": [
{
"$ref": "#/definitions/schema.UserBasicInfo"
}
]
},
"vote_count": {
"type": "integer"
@ -6986,7 +6987,11 @@
"properties": {
"object": {
"description": "this object",
"$ref": "#/definitions/schema.SearchObject"
"allOf": [
{
"$ref": "#/definitions/schema.SearchObject"
}
]
},
"object_type": {
"description": "object_type",
@ -7161,6 +7166,9 @@
},
"theme": {
"$ref": "#/definitions/schema.SiteThemeResp"
},
"version": {
"type": "string"
}
}
},
@ -7496,7 +7504,11 @@
"properties": {
"avatar": {
"description": "avatar",
"$ref": "#/definitions/schema.AvatarInfo"
"allOf": [
{
"$ref": "#/definitions/schema.AvatarInfo"
}
]
},
"bio": {
"description": "bio",

View File

@ -488,8 +488,6 @@ definitions:
type: object
schema.GetOtherUserInfoResp:
properties:
has:
type: boolean
info:
$ref: '#/definitions/schema.GetOtherUserInfoByUsernameResp'
type: object
@ -1201,7 +1199,8 @@ definitions:
title:
type: string
user_info:
$ref: '#/definitions/schema.UserBasicInfo'
allOf:
- $ref: '#/definitions/schema.UserBasicInfo'
description: user info
vote_count:
type: integer
@ -1209,7 +1208,8 @@ definitions:
schema.SearchResp:
properties:
object:
$ref: '#/definitions/schema.SearchObject'
allOf:
- $ref: '#/definitions/schema.SearchObject'
description: this object
object_type:
description: object_type
@ -1335,6 +1335,8 @@ definitions:
$ref: '#/definitions/schema.SiteSeoReq'
theme:
$ref: '#/definitions/schema.SiteThemeResp'
version:
type: string
type: object
schema.SiteInterfaceReq:
properties:
@ -1561,7 +1563,8 @@ definitions:
schema.UpdateInfoRequest:
properties:
avatar:
$ref: '#/definitions/schema.AvatarInfo'
allOf:
- $ref: '#/definitions/schema.AvatarInfo'
description: avatar
bio:
description: bio

View File

@ -232,6 +232,11 @@ func (as *AnswerService) Update(ctx context.Context, req *schema.AnswerUpdateReq
return "", nil
}
if answerInfo.Status == entity.AnswerStatusDeleted {
err = errors.BadRequest(reason.AnswerCannotUpdate)
return "", err
}
//If the content is the same, ignore it
if answerInfo.OriginalText == req.Content {
return "", nil

View File

@ -470,6 +470,10 @@ func (qs *QuestionService) UpdateQuestion(ctx context.Context, req *schema.Quest
if !has {
return
}
if dbinfo.Status == entity.QuestionStatusDeleted {
err = errors.BadRequest(reason.QuestionCannotUpdate)
return
}
now := time.Now()
question := &entity.Question{}