mirror of https://gitee.com/answerdev/answer.git
update answer
This commit is contained in:
parent
d7511a6697
commit
cf2fc12e38
|
@ -48,6 +48,8 @@ backend:
|
|||
other: No permission to delete.
|
||||
cannot_update:
|
||||
other: No permission to update.
|
||||
question_closed_cannot_add:
|
||||
other: Questions are closed and cannot be added.
|
||||
comment:
|
||||
edit_without_permission:
|
||||
other: Comment are not allowed to edit.
|
||||
|
|
|
@ -44,6 +44,8 @@ backend:
|
|||
other: 没有删除权限。
|
||||
cannot_update:
|
||||
other: 没有更新权限。
|
||||
question_closed_cannot_add:
|
||||
other: 问题已关闭不可以新增回答
|
||||
comment:
|
||||
edit_without_permission:
|
||||
other: 不允许编辑评论。
|
||||
|
|
|
@ -25,6 +25,7 @@ const (
|
|||
AnswerNotFound = "error.answer.not_found"
|
||||
AnswerCannotDeleted = "error.answer.cannot_deleted"
|
||||
AnswerCannotUpdate = "error.answer.cannot_update"
|
||||
AnswerCannotAddByClosedQuestion = "error.answer.question_closed_cannot_add"
|
||||
CommentEditWithoutPermission = "error.comment.edit_without_permission"
|
||||
DisallowVote = "error.object.disallow_vote"
|
||||
DisallowFollow = "error.object.disallow_follow"
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"github.com/answerdev/answer/internal/schema"
|
||||
"github.com/answerdev/answer/internal/service/activity"
|
||||
"github.com/answerdev/answer/internal/service/activity_common"
|
||||
"github.com/answerdev/answer/pkg/uid"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
|
@ -37,6 +38,7 @@ func (ac *ActivityController) GetObjectTimeline(ctx *gin.Context) {
|
|||
if handler.BindAndCheck(ctx, req) {
|
||||
return
|
||||
}
|
||||
req.ObjectID = uid.DeShortID(req.ObjectID)
|
||||
|
||||
req.UserID = middleware.GetLoginUserIDFromContext(ctx)
|
||||
if userInfo := middleware.GetUserInfoFromContext(ctx); userInfo != nil {
|
||||
|
|
|
@ -138,6 +138,10 @@ func (as *AnswerService) Insert(ctx context.Context, req *schema.AnswerAddReq) (
|
|||
if !exist {
|
||||
return "", errors.BadRequest(reason.QuestionNotFound)
|
||||
}
|
||||
if questionInfo.Status == entity.QuestionStatusClosed || questionInfo.Status == entity.QuestionStatusDeleted {
|
||||
err = errors.BadRequest(reason.AnswerCannotAddByClosedQuestion)
|
||||
return "", err
|
||||
}
|
||||
insertData := new(entity.Answer)
|
||||
insertData.UserID = req.UserID
|
||||
insertData.OriginalText = req.Content
|
||||
|
|
Loading…
Reference in New Issue