Commit 89afc6c1 by 杨树贤

去重

parent e011e0ac
Showing with 14 additions and 1 deletions
......@@ -115,8 +115,21 @@ func (ts *TagsService) GetLyTags(sku model.LySku) (goodsTags model.GoodsTag) {
tagNames = append(tagNames, tag.String())
}
}
//去重tagNames
tagNames = removeDuplicateString(tagNames)
goodsTags.GoodsTagNames = tagNames
goodsTags.GoodsTag = tags
return goodsTags
}
func removeDuplicateString(s []string) []string {
result := []string{}
temp := map[string]struct{}{}
for _, item := range s {
if _, ok := temp[item]; !ok {
temp[item] = struct{}{}
result = append(result, item)
}
}
return result
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment