mirror of https://gitee.com/answerdev/answer.git
update del Answer
This commit is contained in:
parent
e0c53bea11
commit
c413bf3b09
|
@ -76,9 +76,25 @@ func (as *AnswerService) RemoveAnswer(ctx context.Context, req *schema.RemoveAns
|
||||||
if answerInfo.UserID != req.UserID {
|
if answerInfo.UserID != req.UserID {
|
||||||
return errors.BadRequest(reason.UnauthorizedError)
|
return errors.BadRequest(reason.UnauthorizedError)
|
||||||
}
|
}
|
||||||
|
if answerInfo.VoteCount > 0 {
|
||||||
|
return errors.BadRequest(reason.UnauthorizedError)
|
||||||
|
}
|
||||||
if answerInfo.Adopted == schema.AnswerAdoptedEnable {
|
if answerInfo.Adopted == schema.AnswerAdoptedEnable {
|
||||||
return errors.BadRequest(reason.UnauthorizedError)
|
return errors.BadRequest(reason.UnauthorizedError)
|
||||||
}
|
}
|
||||||
|
questionInfo, exist, err := as.questionRepo.GetQuestion(ctx, answerInfo.QuestionID)
|
||||||
|
if err != nil {
|
||||||
|
return errors.BadRequest(reason.UnauthorizedError)
|
||||||
|
}
|
||||||
|
if !exist {
|
||||||
|
return errors.BadRequest(reason.UnauthorizedError)
|
||||||
|
}
|
||||||
|
if questionInfo.AnswerCount > 1 {
|
||||||
|
return errors.BadRequest(reason.UnauthorizedError)
|
||||||
|
}
|
||||||
|
if questionInfo.AcceptedAnswerID != "" {
|
||||||
|
return errors.BadRequest(reason.UnauthorizedError)
|
||||||
|
}
|
||||||
|
|
||||||
// user add question count
|
// user add question count
|
||||||
err = as.questionCommon.UpdateAnswerCount(ctx, answerInfo.QuestionID, -1)
|
err = as.questionCommon.UpdateAnswerCount(ctx, answerInfo.QuestionID, -1)
|
||||||
|
|
Loading…
Reference in New Issue