mirror of https://gitee.com/answerdev/answer.git
fix question tags update error
This commit is contained in:
parent
6b983d472d
commit
0df1ab82fa
|
@ -9,6 +9,7 @@ import (
|
|||
"github.com/answerdev/answer/internal/base/constant"
|
||||
"github.com/answerdev/answer/internal/base/reason"
|
||||
"github.com/answerdev/answer/internal/base/translator"
|
||||
"github.com/answerdev/answer/internal/base/validator"
|
||||
"github.com/answerdev/answer/internal/entity"
|
||||
"github.com/answerdev/answer/internal/schema"
|
||||
"github.com/answerdev/answer/internal/service/activity"
|
||||
|
@ -206,7 +207,7 @@ func (qs *QuestionService) RemoveQuestion(ctx context.Context, req *schema.Remov
|
|||
}
|
||||
|
||||
// UpdateQuestion update question
|
||||
func (qs *QuestionService) UpdateQuestion(ctx context.Context, req *schema.QuestionUpdate) (questionInfo *schema.QuestionInfo, err error) {
|
||||
func (qs *QuestionService) UpdateQuestion(ctx context.Context, req *schema.QuestionUpdate) (questionInfo any, err error) {
|
||||
questionInfo = &schema.QuestionInfo{}
|
||||
now := time.Now()
|
||||
question := &entity.Question{}
|
||||
|
@ -252,9 +253,15 @@ func (qs *QuestionService) UpdateQuestion(ctx context.Context, req *schema.Quest
|
|||
|
||||
CheckTag, CheckTaglist := qs.CheckChangeReservedTag(ctx, oldTags, Tags)
|
||||
if !CheckTag {
|
||||
err = errors.BadRequest(reason.RequestFormatError).WithMsg(fmt.Sprintf("The reserved tag \"%s\" must be present.",
|
||||
strings.Join(CheckTaglist, ",")))
|
||||
return
|
||||
errMsg := fmt.Sprintf(`The reserved tag %s must be present.`,
|
||||
strings.Join(CheckTaglist, ","))
|
||||
errorlist := make([]*validator.FormErrorField, 0)
|
||||
errorlist = append(errorlist, &validator.FormErrorField{
|
||||
ErrorField: "tags",
|
||||
ErrorMsg: errMsg,
|
||||
})
|
||||
err = errors.BadRequest(reason.RequestFormatError).WithMsg(errMsg)
|
||||
return errorlist, err
|
||||
}
|
||||
|
||||
//update question to db
|
||||
|
|
Loading…
Reference in New Issue