多对多关系的API路径

时间:2019-08-07 14:39:05

标签: api asp.net-core api-design

我在Api上具有以下实体:

Organization > OrganizationId (PK), Name, ...

User > UserId (PK), Name, ...

OrganizationEnrolment > (OrganizationId, UserId) (PK), EnromentTypeId

因此OrganizationEnrolment具有组织中用户的注册。

每个组织的用户只能注册一个,因此PK (OrganizationId, UserId)

我有一些API端点,例如:

GET Organization = GET organizations/{organizationId}

Update Organization = PUT organizations/{organizationId}

Create User = POST users

Delete User = DELETE users/{userId}

问题是:

创建,删除和更新组织注册的API URL应该是什么?

我正在努力...

1 个答案:

答案 0 :(得分:2)

获取组织员工:GET organizations/{organizationId}/employees

将员工添加到组织中:PUT organizations/{organizationId}/employees

从组织中删除员工而不删除员工:DELETE organizations/{organizationId}/employees