Merge branch 'feat/0.5.0/timeline_ai' into test

This commit is contained in:
LinkinStar 2022-12-01 17:35:25 +08:00
commit 3878e47ab9
6 changed files with 23 additions and 8 deletions

View File

@ -188,9 +188,10 @@ func (ac *AnswerController) Update(ctx *gin.Context) {
handler.HandleResponse(ctx, nil, nil)
return
}
handler.HandleResponse(ctx, nil, gin.H{
"info": info,
"question": questionInfo,
handler.HandleResponse(ctx, nil, &schema.AnswerUpdateResp{
AnswerInfo: info,
QuestionInfo: questionInfo,
WaitForReview: !req.NoNeedReview,
})
}

View File

@ -108,7 +108,11 @@ func (tc *TagController) UpdateTag(ctx *gin.Context) {
req.NoNeedReview = canList[1]
err = tc.tagService.UpdateTag(ctx, req)
if err != nil {
handler.HandleResponse(ctx, err, nil)
} else {
handler.HandleResponse(ctx, err, &schema.UpdateTagResp{WaitForReview: !req.NoNeedReview})
}
}
// GetTagInfo get tag one

View File

@ -29,12 +29,18 @@ type AnswerUpdateReq struct {
Content string `json:"content"` // content
HTML string `json:"html" ` // html
EditSummary string `validate:"omitempty" json:"edit_summary"` // edit_summary
IsAdmin bool `json:"-"`
NoNeedReview bool `json:"-"`
// whether user can edit it
CanEdit bool `json:"-"`
}
// AnswerUpdateResp answer update resp
type AnswerUpdateResp struct {
AnswerInfo *AnswerInfo `json:"info"`
QuestionInfo *QuestionInfo `json:"question"`
WaitForReview bool `json:"wait_for_review"`
}
type AnswerListReq struct {
QuestionID string `json:"question_id" form:"question_id"` // question_id
Order string `json:"order" form:"order"` // 1 Default 2 time

View File

@ -157,7 +157,6 @@ type UpdateTagReq struct {
EditSummary string `validate:"omitempty" json:"edit_summary"`
// user id
UserID string `json:"-"`
IsAdmin bool `json:"-"`
NoNeedReview bool `json:"-"`
}
@ -168,6 +167,11 @@ func (r *UpdateTagReq) Check() (errFields []*validator.FormErrorField, err error
return nil, nil
}
// UpdateTagResp update tag response
type UpdateTagResp struct {
WaitForReview bool `json:"wait_for_review"`
}
// GetTagWithPageReq get tag list page request
type GetTagWithPageReq struct {
// page

View File

@ -246,7 +246,7 @@ func (as *AnswerService) Update(ctx context.Context, req *schema.AnswerUpdateReq
Log: req.EditSummary,
}
if req.NoNeedReview || req.IsAdmin || answerInfo.UserID == req.UserID {
if req.NoNeedReview || answerInfo.UserID == req.UserID {
canUpdate = true
}

View File

@ -657,7 +657,7 @@ func (ts *TagCommonService) UpdateTag(ctx context.Context, req *schema.UpdateTag
Log: req.EditSummary,
}
if req.IsAdmin || req.NoNeedReview {
if req.NoNeedReview {
canUpdate = true
err = ts.tagRepo.UpdateTag(ctx, tagInfo)
if err != nil {