MCPcopy Index your code
hub / github.com/APIParkLab/APIPark / getTagUuids

Method getTagUuids

module/service/iml.go:960–993  ·  view source on GitHub ↗
(ctx context.Context, tags []string)

Source from the content-addressed store, hash-verified

958}
959
960func (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
995type imlServiceDocModule struct {
996 serviceService service.IServiceService `autowired:""`

Callers 2

CreateMethod · 0.95
EditMethod · 0.95

Calls 3

SearchMethod · 0.65
CreateMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected