A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.
fix(tag): can not set synonym as tag itself
LinkinStarb9ed2e5050eb
diff --git a/i18n/en_US.yaml b/i18n/en_US.yamlindex d8471b0c..21f8a608 100644--- a/i18n/en_US.yaml+++ b/i18n/en_US.yaml@@ -109,6 +109,8 @@ backend:other: "Should not contain synonym tags."cannot_update:other: "No permission to update."+ cannot_set_synonym_as_itself:+ other: "You cannot set the synonym of the current tag as itself."theme:not_found:other: "Theme not found."diff --git a/i18n/zh_CN.yaml b/i18n/zh_CN.yamlindex 55b70b03..669d0422 100644--- a/i18n/zh_CN.yaml+++ b/i18n/zh_CN.yaml@@ -97,6 +97,8 @@ backend:other: "不应包含同义词标签。"cannot_update:other: "没有更新标签权限。"+ cannot_set_synonym_as_itself:+ other: "你无法将当前标签的同义词设置为当前标签自己"theme:not_found:other: "主题未找到"diff --git a/internal/base/reason/reason.go b/internal/base/reason/reason.goindex c3a5333c..f6b0c877 100644--- a/internal/base/reason/reason.go+++ b/internal/base/reason/reason.go@@ -58,4 +58,5 @@ const (RevisionReviewUnderway = "error.revision.review_underway"RevisionNoPermission = "error.revision.no_permission"UserCannotUpdateYourRole = "error.user.cannot_update_your_role"+ TagCannotSetSynonymAsItself = "error.tag.cannot_set_synonym_as_itself")diff --git a/internal/service/tag/tag_service.go b/internal/service/tag/tag_service.goindex 8ebe610c..c0bc6aca 100644--- a/internal/service/tag/tag_service.go+++ b/internal/service/tag/tag_service.go@@ -216,6 +216,9 @@ func (ts *TagService) UpdateTagSynonym(ctx context.Context, req *schema.UpdateTa// find all exist tagfor _, item := range req.SynonymTagList {+ if item.SlugName == mainTagInfo.SlugName {+ return errors.BadRequest(reason.TagCannotSetSynonymAsItself)+ }addSynonymTagList = append(addSynonymTagList, item.SlugName)}tagListInDB, err := ts.tagCommonService.GetTagListByNames(ctx, addSynonymTagList)