mirror of https://gitee.com/answerdev/answer.git
update answer
This commit is contained in:
parent
96c0baa7f6
commit
4c1c56713e
|
@ -136,6 +136,24 @@ func (ac *AnswerController) Add(ctx *gin.Context) {
|
||||||
handler.HandleResponse(ctx, nil, nil)
|
handler.HandleResponse(ctx, nil, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
canList, err := ac.rankService.CheckOperationPermissions(ctx, req.UserID, []string{
|
||||||
|
permission.AnswerEdit,
|
||||||
|
permission.AnswerDelete,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
handler.HandleResponse(ctx, err, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
objectOwner := ac.rankService.CheckOperationObjectOwner(ctx, req.UserID, info.ID)
|
||||||
|
req.CanEdit = canList[0] || objectOwner
|
||||||
|
req.CanDelete = canList[1] || objectOwner
|
||||||
|
if !can {
|
||||||
|
handler.HandleResponse(ctx, errors.Forbidden(reason.RankFailToMeetTheCondition), nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
info.MemberActions = permission.GetAnswerPermission(ctx, req.UserID, info.UserID, req.CanEdit, req.CanDelete)
|
||||||
handler.HandleResponse(ctx, nil, gin.H{
|
handler.HandleResponse(ctx, nil, gin.H{
|
||||||
"info": info,
|
"info": info,
|
||||||
"question": questionInfo,
|
"question": questionInfo,
|
||||||
|
|
|
@ -24,6 +24,8 @@ type AnswerAddReq struct {
|
||||||
Content string `validate:"required,notblank,gte=6,lte=65535" json:"content"`
|
Content string `validate:"required,notblank,gte=6,lte=65535" json:"content"`
|
||||||
HTML string `json:"-"`
|
HTML string `json:"-"`
|
||||||
UserID string `json:"-"`
|
UserID string `json:"-"`
|
||||||
|
CanEdit bool `json:"-"`
|
||||||
|
CanDelete bool `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req *AnswerAddReq) Check() (errFields []*validator.FormErrorField, err error) {
|
func (req *AnswerAddReq) Check() (errFields []*validator.FormErrorField, err error) {
|
||||||
|
|
Loading…
Reference in New Issue