(c *gin.Context)
| 473 | ) |
| 474 | |
| 475 | func (s *SingleEntityService) Get(c *gin.Context) (*GetEntityResponse, error) { |
| 476 | dep := dependency.FromContext(c) |
| 477 | fileClient := dep.FileClient() |
| 478 | hasher := dep.HashIDEncoder() |
| 479 | |
| 480 | ctx := context.WithValue(c, inventory.LoadEntityUser{}, true) |
| 481 | ctx = context.WithValue(ctx, inventory.LoadEntityStoragePolicy{}, true) |
| 482 | ctx = context.WithValue(ctx, inventory.LoadEntityFile{}, true) |
| 483 | ctx = context.WithValue(ctx, inventory.LoadFileUser{}, true) |
| 484 | |
| 485 | userHashIDMap := make(map[int]string) |
| 486 | entity, err := fileClient.GetEntityByID(ctx, s.ID) |
| 487 | if err != nil { |
| 488 | if ent.IsNotFound(err) { |
| 489 | return nil, serializer.NewError(serializer.CodeNotFound, "Entity not found", nil) |
| 490 | } |
| 491 | return nil, serializer.NewError(serializer.CodeDBError, "Failed to get entity", err) |
| 492 | } |
| 493 | |
| 494 | for _, file := range entity.Edges.File { |
| 495 | userHashIDMap[file.OwnerID] = hashid.EncodeUserID(hasher, file.OwnerID) |
| 496 | } |
| 497 | |
| 498 | return &GetEntityResponse{ |
| 499 | Entity: entity, |
| 500 | UserHashID: hashid.EncodeUserID(hasher, entity.CreatedBy), |
| 501 | UserHashIDMap: userHashIDMap, |
| 502 | }, nil |
| 503 | } |
| 504 | |
| 505 | type ( |
| 506 | BatchEntityService struct { |
nothing calls this directly
no test coverage detected