diff --git a/internal/controller/answer_controller.go b/internal/controller/answer_controller.go index c1b658e0..94105ba4 100644 --- a/internal/controller/answer_controller.go +++ b/internal/controller/answer_controller.go @@ -189,9 +189,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, }) } diff --git a/internal/controller/tag_controller.go b/internal/controller/tag_controller.go index 1a64962d..1164f1d4 100644 --- a/internal/controller/tag_controller.go +++ b/internal/controller/tag_controller.go @@ -108,7 +108,11 @@ func (tc *TagController) UpdateTag(ctx *gin.Context) { req.NoNeedReview = canList[1] err = tc.tagService.UpdateTag(ctx, req) - handler.HandleResponse(ctx, err, nil) + if err != nil { + handler.HandleResponse(ctx, err, nil) + } else { + handler.HandleResponse(ctx, err, &schema.UpdateTagResp{WaitForReview: !req.NoNeedReview}) + } } // GetTagInfo get tag one diff --git a/internal/schema/answer_schema.go b/internal/schema/answer_schema.go index 4527357b..71e8a7f6 100644 --- a/internal/schema/answer_schema.go +++ b/internal/schema/answer_schema.go @@ -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 diff --git a/internal/schema/tag_schema.go b/internal/schema/tag_schema.go index 900bbf05..bf79d5aa 100644 --- a/internal/schema/tag_schema.go +++ b/internal/schema/tag_schema.go @@ -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 diff --git a/internal/service/answer_service.go b/internal/service/answer_service.go index 78d727dc..5011b4da 100644 --- a/internal/service/answer_service.go +++ b/internal/service/answer_service.go @@ -241,7 +241,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 } diff --git a/internal/service/tag_common/tag_common.go b/internal/service/tag_common/tag_common.go index 5a2d59fe..d9d97423 100644 --- a/internal/service/tag_common/tag_common.go +++ b/internal/service/tag_common/tag_common.go @@ -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 {