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

Method importCatalogues

controller/system/import.go:285–318  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

283}
284
285func (i *imlImportConfigController) importCatalogues(ctx context.Context) error {
286 data, err := unmarshal[catalogue_dto.ExportCatalogue]("catalogue")
287 if err != nil {
288 return err
289 }
290 for _, d := range data {
291 _, err = i.catalogueModule.Get(ctx, d.Id)
292 if err != nil {
293 if !errors.Is(err, gorm.ErrRecordNotFound) {
294 return err
295 }
296 err = i.catalogueModule.Create(ctx, &catalogue_dto.CreateCatalogue{
297 Id: d.Id,
298 Name: d.Name,
299 Parent: &d.Parent,
300 Sort: &d.Sort,
301 })
302 if err != nil {
303 return fmt.Errorf("create catalogue(%s) error: %v", d.Id, err)
304 }
305 continue
306 }
307 err = i.catalogueModule.Edit(ctx, d.Id, &catalogue_dto.EditCatalogue{
308 Name: &d.Name,
309 Parent: &d.Parent,
310 Sort: &d.Sort,
311 })
312 if err != nil {
313 return fmt.Errorf("update catalogue(%s) error: %v", d.Id, err)
314 }
315
316 }
317 return nil
318}
319
320func (i *imlImportConfigController) importUpstreams(ctx context.Context) error {
321 data, err := unmarshal[upstream_dto.ExportUpstream]("upstream")

Callers 1

ImportAllMethod · 0.95

Calls 3

GetMethod · 0.65
CreateMethod · 0.65
EditMethod · 0.65

Tested by

no test coverage detected