Skip to content

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.

update tag error

aichy1260519b558b7a2
diff --git a/internal/service/tag_common/tag_common.go b/internal/service/tag_common/tag_common.go
index 95258987..6cd682b4 100644
--- a/internal/service/tag_common/tag_common.go
+++ b/internal/service/tag_common/tag_common.go
@@ -74,18 +74,36 @@ func (ts *TagCommonService) GetSiteWriteRecommendTag(ctx context.Context) (tags
return tags, nil
}
-func (ts *TagCommonService) SetSiteWriteRecommendTag(ctx context.Context, tags []string, required bool, userID string) (msg string, err error) {
- err = ts.UpdateTag(ctx, tags, userID)
+func (ts *TagCommonService) SetSiteWriteTag(ctx context.Context, recommendtags, reservedtags []string, required bool, userID string) (msg string, err error) {
+ recommenderr := ts.CheckTag(ctx, recommendtags, userID)
+ reservederr := ts.CheckTag(ctx, reservedtags, userID)
+ if recommenderr != nil || reservederr != nil {
+ return "", nil
+ }
+ err = ts.SetTagsAttribute(ctx, recommendtags, "recommend")
if err != nil {
- return err.Error(), err
+ return "", err
}
- err = ts.SetTagsAttribute(ctx, tags, "recommend", true)
+ err = ts.SetTagsAttribute(ctx, reservedtags, "reserved")
if err != nil {
return "", err
}
return "", nil
}
+// func (ts *TagCommonService) SetSiteWriteRecommendTag(ctx context.Context, tags []string, userID string) (msg string, err error) {
+// err = ts.UpdateTag(ctx, tags, userID)
+// if err != nil {
+// return err.Error(), err
+// }
+// err = ts.SetTagsAttribute(ctx, tags, "recommend")
+// if err != nil {
+// return "", err
+// }
+
+// return "", nil
+// }
+
func (ts *TagCommonService) GetSiteWriteReservedTag(ctx context.Context) (tags []string, err error) {
tags = make([]string, 0)
list, err := ts.tagRepo.GetReservedTagList(ctx)
@@ -95,20 +113,20 @@ func (ts *TagCommonService) GetSiteWriteReservedTag(ctx context.Context) (tags [
return tags, nil
}
-func (ts *TagCommonService) SetSiteWriteReservedTag(ctx context.Context, tags []string, userID string) (msg string, err error) {
- err = ts.UpdateTag(ctx, tags, userID)
- if err != nil {
- return err.Error(), err
- }
- err = ts.SetTagsAttribute(ctx, tags, "reserved", true)
- if err != nil {
- return "", err
- }
- return "", nil
-}
+// func (ts *TagCommonService) SetSiteWriteReservedTag(ctx context.Context, tags []string, userID string) (msg string, err error) {
+// err = ts.UpdateTag(ctx, tags, userID)
+// if err != nil {
+// return err.Error(), err
+// }
+// err = ts.SetTagsAttribute(ctx, tags, "reserved")
+// if err != nil {
+// return "", err
+// }
+// return "", nil
+// }
// SetTagsAttribute
-func (ts *TagCommonService) SetTagsAttribute(ctx context.Context, tags []string, attribute string, value bool) (err error) {
+func (ts *TagCommonService) SetTagsAttribute(ctx context.Context, tags []string, attribute string) (err error) {
var tagslist []string
switch attribute {
case "recommend":
@@ -122,7 +140,7 @@ func (ts *TagCommonService) SetTagsAttribute(ctx context.Context, tags []string,
if err != nil {
return err
}
- err = ts.tagRepo.UpdateTagsAttribute(ctx, tags, attribute, value)
+ err = ts.tagRepo.UpdateTagsAttribute(ctx, tags, attribute, true)
if err != nil {
return err
}
@@ -240,7 +258,7 @@ func (ts *TagCommonService) BatchGetObjectTag(ctx context.Context, objectIds []s
return objectIDTagMap, nil
}
-func (ts *TagCommonService) UpdateTag(ctx context.Context, tags []string, userID string) (err error) {
+func (ts *TagCommonService) CheckTag(ctx context.Context, tags []string, userID string) (err error) {
if len(tags) == 0 {
return nil
}