mirror of https://gitee.com/answerdev/answer.git
Merge branch 'ai/0.4.0/fix/tag' into test
This commit is contained in:
commit
e3e9ee0663
|
@ -78,6 +78,12 @@ backend:
|
|||
tag:
|
||||
not_found:
|
||||
other: "Tag not found."
|
||||
recommend_tag_not_found:
|
||||
other: "Recommend Tag is not exist."
|
||||
recommend_tag_enter:
|
||||
other: "Please enter at least one required tag."
|
||||
not_contain_synonym_tags:
|
||||
other: "Should not contain synonym tags."
|
||||
theme:
|
||||
not_found:
|
||||
other: "Theme not found."
|
||||
|
|
|
@ -50,4 +50,5 @@ const (
|
|||
SiteInfoNotFound = "error.site_info.not_found"
|
||||
UploadFileSourceUnsupported = "error.upload.source_unsupported"
|
||||
RecommendTagNotExist = "error.tag.recommend_tag_not_found"
|
||||
RecommendTagEnter = "error.tag.recommend_tag_enter"
|
||||
)
|
||||
|
|
|
@ -227,6 +227,15 @@ func (qs *QuestionService) UpdateQuestion(ctx context.Context, req *schema.Quest
|
|||
return
|
||||
}
|
||||
|
||||
recommendExist, err := qs.tagCommon.ExistRecommend(ctx, req.Tags)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if !recommendExist {
|
||||
err = errors.BadRequest(reason.RecommendTagEnter).WithError(err).WithStack()
|
||||
return
|
||||
}
|
||||
|
||||
//CheckChangeTag
|
||||
oldTags, err := qs.tagCommon.GetObjectEntityTag(ctx, question.ID)
|
||||
if err != nil {
|
||||
|
@ -240,9 +249,10 @@ func (qs *QuestionService) UpdateQuestion(ctx context.Context, req *schema.Quest
|
|||
if err != nil {
|
||||
return
|
||||
}
|
||||
CheckTag, CheckTaglist := qs.CheckChangeTag(ctx, oldTags, Tags)
|
||||
|
||||
CheckTag, CheckTaglist := qs.CheckChangeReservedTag(ctx, oldTags, Tags)
|
||||
if !CheckTag {
|
||||
err = errors.BadRequest(reason.UnauthorizedError).WithMsg(fmt.Sprintf("tag [%s] cannot be modified",
|
||||
err = errors.BadRequest(reason.RequestFormatError).WithMsg(fmt.Sprintf("The reserved tag \"%s\" must be present.",
|
||||
strings.Join(CheckTaglist, ",")))
|
||||
return
|
||||
}
|
||||
|
@ -299,8 +309,8 @@ func (qs *QuestionService) ChangeTag(ctx context.Context, objectTagData *schema.
|
|||
return qs.tagCommon.ObjectChangeTag(ctx, objectTagData)
|
||||
}
|
||||
|
||||
func (qs *QuestionService) CheckChangeTag(ctx context.Context, oldobjectTagData, objectTagData []*entity.Tag) (bool, []string) {
|
||||
return qs.tagCommon.ObjectCheckChangeTag(ctx, oldobjectTagData, objectTagData)
|
||||
func (qs *QuestionService) CheckChangeReservedTag(ctx context.Context, oldobjectTagData, objectTagData []*entity.Tag) (bool, []string) {
|
||||
return qs.tagCommon.CheckChangeReservedTag(ctx, oldobjectTagData, objectTagData)
|
||||
}
|
||||
|
||||
func (qs *QuestionService) SearchUserList(ctx context.Context, userName, order string, page, pageSize int, loginUserID string) ([]*schema.UserQuestionInfo, int64, error) {
|
||||
|
|
|
@ -403,7 +403,7 @@ func (ts *TagCommonService) CheckTag(ctx context.Context, tags []string, userID
|
|||
return nil
|
||||
}
|
||||
|
||||
func (ts *TagCommonService) ObjectCheckChangeTag(ctx context.Context, oldobjectTagData, objectTagData []*entity.Tag) (bool, []string) {
|
||||
func (ts *TagCommonService) CheckChangeReservedTag(ctx context.Context, oldobjectTagData, objectTagData []*entity.Tag) (bool, []string) {
|
||||
reservedTagsMap := make(map[string]bool)
|
||||
needTagsMap := make([]string, 0)
|
||||
for _, tag := range objectTagData {
|
||||
|
|
Loading…
Reference in New Issue