MCPcopy Create free account
hub / github.com/APIParkLab/APIPark / Save

Method Save

service/service-model-mapping/iml.go:55–75  ·  view source on GitHub ↗
(ctx context.Context, input *Save)

Source from the content-addressed store, hash-verified

53}
54
55func (i *imlServiceModelMappingService) Save(ctx context.Context, input *Save) error {
56 info, err := i.store.First(ctx, map[string]interface{}{"sid": input.Sid})
57 if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
58 return err
59 }
60 userID := utils.UserId(ctx)
61 if info != nil {
62 info.Content = input.Content
63 info.Updater = userID
64 info.UpdateAt = time.Now()
65 return i.store.Save(ctx, info)
66 }
67 return i.store.Insert(ctx, &service.ModelMapping{
68 Sid: input.Sid,
69 Content: input.Content,
70 CreateAt: time.Now(),
71 UpdateAt: time.Now(),
72 Creator: userID,
73 Updater: userID,
74 })
75}

Callers

nothing calls this directly

Calls 1

SaveMethod · 0.65

Tested by

no test coverage detected