mirror of https://gitee.com/answerdev/answer.git
fix(answer): Only the admin and author can view the deleted answer.
This commit is contained in:
parent
88e11d117e
commit
c3d8d30892
|
@ -35,9 +35,11 @@ type Answer struct {
|
|||
|
||||
type AnswerSearch struct {
|
||||
Answer
|
||||
Order string `json:"order_by" ` // default or updated
|
||||
Page int `json:"page" form:"page"` // Query number of pages
|
||||
PageSize int `json:"page_size" form:"page_size"` // Search page size
|
||||
IncludeDeleted bool `json:"include_deleted"`
|
||||
LoginUserID string `json:"login_user_id"`
|
||||
Order string `json:"order_by"` // default or updated
|
||||
Page int `json:"page" form:"page"` // Query number of pages
|
||||
PageSize int `json:"page_size" form:"page_size"` // Search page size
|
||||
}
|
||||
|
||||
type AdminAnswerSearch struct {
|
||||
|
|
|
@ -206,7 +206,9 @@ func (ar *answerRepo) SearchList(ctx context.Context, search *entity.AnswerSearc
|
|||
default:
|
||||
session = session.OrderBy("adopted desc,vote_count desc,created_at asc")
|
||||
}
|
||||
session = session.And("status = ?", entity.AnswerStatusAvailable)
|
||||
if !search.IncludeDeleted {
|
||||
session = session.And("status = ? OR user_id = ?", entity.AnswerStatusAvailable, search.UserID)
|
||||
}
|
||||
|
||||
session = session.Limit(search.PageSize, offset)
|
||||
count, err = session.FindAndCount(&rows)
|
||||
|
|
|
@ -83,6 +83,7 @@ type AnswerInfo struct {
|
|||
VoteStatus string `json:"vote_status"`
|
||||
VoteCount int `json:"vote_count"`
|
||||
QuestionInfo *QuestionInfo `json:"question_info,omitempty"`
|
||||
Status int `json:"status"`
|
||||
|
||||
// MemberActions
|
||||
MemberActions []*PermissionMemberAction `json:"member_actions"`
|
||||
|
|
|
@ -73,6 +73,7 @@ func (as *AnswerCommon) ShowFormat(ctx context.Context, data *entity.Answer) *sc
|
|||
}
|
||||
info.UserID = data.UserID
|
||||
info.UpdateUserID = data.LastEditUserID
|
||||
info.Status = data.Status
|
||||
return &info
|
||||
}
|
||||
|
||||
|
|
|
@ -473,6 +473,7 @@ func (as *AnswerService) SearchList(ctx context.Context, req *schema.AnswerListR
|
|||
dbSearch.Page = req.Page
|
||||
dbSearch.PageSize = req.PageSize
|
||||
dbSearch.Order = req.Order
|
||||
dbSearch.IncludeDeleted = req.CanDelete
|
||||
answerOriginalList, count, err := as.answerRepo.SearchList(ctx, &dbSearch)
|
||||
if err != nil {
|
||||
return list, count, err
|
||||
|
|
Loading…
Reference in New Issue