| 958 | } |
| 959 | |
| 960 | func (i *imlServiceModule) getTagUuids(ctx context.Context, tags []string) ([]string, error) { |
| 961 | list, err := i.tagService.Search(ctx, "", map[string]interface{}{"name": tags}) |
| 962 | if err != nil { |
| 963 | return nil, err |
| 964 | } |
| 965 | tagMap := make(map[string]string) |
| 966 | for _, t := range list { |
| 967 | tagMap[t.Name] = t.Id |
| 968 | } |
| 969 | tagList := make([]string, 0, len(tags)) |
| 970 | repeatTag := make(map[string]struct{}) |
| 971 | for _, t := range tags { |
| 972 | if _, ok := repeatTag[t]; ok { |
| 973 | continue |
| 974 | } |
| 975 | repeatTag[t] = struct{}{} |
| 976 | v := &tag.CreateTag{ |
| 977 | Name: t, |
| 978 | } |
| 979 | id, ok := tagMap[t] |
| 980 | if !ok { |
| 981 | v.Id = uuid.New().String() |
| 982 | err = i.tagService.Create(ctx, v) |
| 983 | if err != nil { |
| 984 | return nil, err |
| 985 | } |
| 986 | tagMap[t] = v.Id |
| 987 | } else { |
| 988 | v.Id = id |
| 989 | } |
| 990 | tagList = append(tagList, v.Id) |
| 991 | } |
| 992 | return tagList, nil |
| 993 | } |
| 994 | |
| 995 | type imlServiceDocModule struct { |
| 996 | serviceService service.IServiceService `autowired:""` |