mirror of https://gitee.com/answerdev/answer.git
Merge branch 'feat/0.5.0/timeline_ai' of git.backyard.segmentfault.com:opensource/answer into feat/0.5.0/timeline_ai
This commit is contained in:
commit
2efc78cf30
|
@ -67,16 +67,18 @@ func (rc *RevisionController) GetUnreviewedRevisionList(ctx *gin.Context) {
|
|||
}
|
||||
|
||||
req.UserID = middleware.GetLoginUserIDFromContext(ctx)
|
||||
|
||||
can, err := rc.rankService.CheckOperationPermission(ctx, req.UserID, rank.UnreviewedRevisionListRank, "")
|
||||
canList, err := rc.rankService.CheckOperationPermissions(ctx, req.UserID, []string{
|
||||
rank.QuestionAuditRank,
|
||||
rank.AnswerAuditRank,
|
||||
rank.TagAuditRank,
|
||||
}, "")
|
||||
if err != nil {
|
||||
handler.HandleResponse(ctx, err, nil)
|
||||
return
|
||||
}
|
||||
if !can {
|
||||
handler.HandleResponse(ctx, errors.Forbidden(reason.RankFailToMeetTheCondition), nil)
|
||||
return
|
||||
}
|
||||
req.CanReviewQuestion = canList[0]
|
||||
req.CanReviewAnswer = canList[1]
|
||||
req.CanReviewTag = canList[2]
|
||||
|
||||
resp, count, err := rc.revisionListService.GetUnreviewedRevisionList(ctx, req)
|
||||
handler.HandleResponse(ctx, err, gin.H{
|
||||
|
@ -100,15 +102,18 @@ func (rc *RevisionController) RevisionAudit(ctx *gin.Context) {
|
|||
return
|
||||
}
|
||||
req.UserID = middleware.GetLoginUserIDFromContext(ctx)
|
||||
can, err := rc.rankService.CheckOperationPermission(ctx, req.UserID, rank.RevisionAuditRank, "")
|
||||
canList, err := rc.rankService.CheckOperationPermissions(ctx, req.UserID, []string{
|
||||
rank.QuestionAuditRank,
|
||||
rank.AnswerAuditRank,
|
||||
rank.TagAuditRank,
|
||||
}, "")
|
||||
if err != nil {
|
||||
handler.HandleResponse(ctx, err, nil)
|
||||
return
|
||||
}
|
||||
if !can {
|
||||
handler.HandleResponse(ctx, errors.Forbidden(reason.RankFailToMeetTheCondition), nil)
|
||||
return
|
||||
}
|
||||
req.CanReviewQuestion = canList[0]
|
||||
req.CanReviewAnswer = canList[1]
|
||||
req.CanReviewTag = canList[2]
|
||||
|
||||
err = rc.revisionListService.RevisionAudit(ctx, req)
|
||||
handler.HandleResponse(ctx, err, gin.H{})
|
||||
|
|
|
@ -31,15 +31,20 @@ const RevisionAuditReject = "reject"
|
|||
|
||||
type RevisionAuditReq struct {
|
||||
// object id
|
||||
ID string `validate:"required" comment:"id" form:"id"`
|
||||
Operation string `validate:"required" comment:"operation" form:"operation"` //approve or reject
|
||||
UserID string `json:"-" ` // user_id
|
||||
// IsAdmin bool `json:"-"`
|
||||
ID string `validate:"required" comment:"id" form:"id"`
|
||||
Operation string `validate:"required" comment:"operation" form:"operation"` //approve or reject
|
||||
UserID string `json:"-"`
|
||||
CanReviewQuestion bool `json:"-"`
|
||||
CanReviewAnswer bool `json:"-"`
|
||||
CanReviewTag bool `json:"-"`
|
||||
}
|
||||
|
||||
type RevisionSearch struct {
|
||||
Page int `json:"page" form:"page"` // Query number of pages
|
||||
UserID string `json:"-"`
|
||||
Page int `json:"page" form:"page"` // Query number of pages
|
||||
CanReviewQuestion bool `json:"-"`
|
||||
CanReviewAnswer bool `json:"-"`
|
||||
CanReviewTag bool `json:"-"`
|
||||
UserID string `json:"-"`
|
||||
}
|
||||
|
||||
type GetUnreviewedRevisionResp struct {
|
||||
|
|
|
@ -33,6 +33,8 @@ const (
|
|||
CommentAddRank = "rank.comment.add"
|
||||
CommentEditRank = "rank.comment.edit"
|
||||
CommentDeleteRank = "rank.comment.delete"
|
||||
CommentVoteUpRank = "rank.comment.vote_up"
|
||||
CommentVoteDownRank = "rank.comment.vote_down"
|
||||
ReportAddRank = "rank.report.add"
|
||||
TagAddRank = "rank.tag.add"
|
||||
TagEditRank = "rank.tag.edit"
|
||||
|
@ -41,8 +43,9 @@ const (
|
|||
TagSynonymRank = "rank.tag.synonym"
|
||||
LinkUrlLimitRank = "rank.link.url_limit"
|
||||
VoteDetailRank = "rank.vote.detail"
|
||||
RevisionAuditRank = "rank.revision.audit"
|
||||
UnreviewedRevisionListRank = "rank.revision.unreviewed_list"
|
||||
AnswerAuditRank = "rank.answer.audit"
|
||||
QuestionAuditRank = "rank.question.audit"
|
||||
TagAuditRank = "rank.tag.audit"
|
||||
)
|
||||
|
||||
type UserRankRepo interface {
|
||||
|
|
Loading…
Reference in New Issue