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

Method Save

service/service-doc/iml.go:87–107  ·  view source on GitHub ↗
(ctx context.Context, input *SaveDoc)

Source from the content-addressed store, hash-verified

85}
86
87func (i *imlDocService) Save(ctx context.Context, input *SaveDoc) error {
88 info, err := i.store.First(ctx, map[string]interface{}{"sid": input.Sid})
89 if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
90 return err
91 }
92 userID := utils.UserId(ctx)
93 if info != nil {
94 info.Doc = input.Doc
95 info.Updater = userID
96 info.UpdateAt = time.Now()
97 return i.store.Save(ctx, info)
98 }
99 return i.store.Insert(ctx, &service.Doc{
100 Sid: input.Sid,
101 Doc: input.Doc,
102 CreateAt: time.Now(),
103 UpdateAt: time.Now(),
104 Creator: userID,
105 Updater: userID,
106 })
107}
108
109func (i *imlDocService) Get(ctx context.Context, sid string) (*Doc, error) {
110 doc, err := i.store.First(ctx, map[string]interface{}{"sid": sid})

Callers

nothing calls this directly

Calls 1

SaveMethod · 0.65

Tested by

no test coverage detected