1

I have a following structure.

Resources can have multiple endpoints.

Example: Resource tickets can be accessed on following endpoints:

  • /api/tickets
  • /api/agent/tickets
  • /api/group/5/tickets
  • /api/tickets/closed etc.

At first, this looks like aggregate, where Resource is AR, and endpoints are child entities.

I also have UserTypes. What I need is to build a relation between Usertypes and Endpoints, so each UserType can have a diferrent access for endpoints. Example for, UserType admin could access all endpoints for tickets resource, while user type agent could have access to only portion of endpoints for the same resource.

What would be a suggested way to connect EndPoints and UserTypes in terms of DDD?

enter image description here

gurghet
  • 7,591
  • 4
  • 36
  • 63
Robert
  • 3,353
  • 4
  • 32
  • 50
  • Possible duplicate of [Solve apparent need for outside reference to entity inside aggregate (DDD)](http://stackoverflow.com/questions/39255123/solve-apparent-need-for-outside-reference-to-entity-inside-aggregate-ddd) – tomliversidge Sep 01 '16 at 08:55

1 Answers1

1

Do you need anything else other than a collection of mapping a between Resources and Endpoints on a UserType? This would give you all usertypes their unique resource endpoint access rights

Also seems to be the same question as Solve apparent need for outside reference to entity inside aggregate (DDD)

I would probably create something like the following:

class ResourceEndpoint {
    Guid resourceId;
    Guid endpointId;
}

class UserType {
    List<ResourceEndpoint> ThingsICanAccess;
}
Community
  • 1
  • 1
tomliversidge
  • 2,339
  • 1
  • 15
  • 15
  • Maybe i modeled this wrong. Maybe Endpoint should be separate AR. When adding an endpoint, We must select to which resource he belongs. – Robert Sep 01 '16 at 08:54
  • Does the adding of the endpoint to the resource also need to be in the same transaction as adding the resource-endpoint mapping to the usertype? – tomliversidge Sep 01 '16 at 08:58
  • Alright, and where would you place UserTypeEndpoints? As a separate AR, As a list of value objects inside UserType, where each holds a reference to Endpoint? – Robert Sep 01 '16 at 08:59
  • "Does the adding of the endpoint to the resource also need to be in the same transaction as adding the resource-endpoint mapping to the usertype?" - No. You will be able to edit user type, and assign them existing endpoints later on. – Robert Sep 01 '16 at 09:00
  • 1
    What are they? if they are just a mapping from usertype to ResourceEndpoint (which sounds like a new object that is just the identifiers of a Resource and an Endpoint) then they would be a collection on the UserType. – tomliversidge Sep 01 '16 at 09:03
  • why resourceID inside ResourceEndpointClass? All i needed was endpointID. – Robert Sep 01 '16 at 09:17
  • How do you know what resource the endpoint is related to? Is it on the Endpoint object already? – tomliversidge Sep 01 '16 at 09:18
  • Endpoint is part of the resource. Resource can have multiple endpoints. – Robert Sep 01 '16 at 09:20