rest - 如何为特定情况设计rest uri?
问题描述
我有一个通过 EmployeeController 由 rest api 管理的员工列表。
很少的 URI——
/employees - Get all employees
/employees/1 - Get employee with id 1
Employee 有一个具有deptId的对象 Department 。
现在我想创建 URI 来获取所有具有 deptId = 30 和 dateofBirth > '01-01-1990' 的员工
为这种情况编写 URI 的最佳方法是什么?
解决方案
使用查询参数/employees
过滤将返回哪个员工的常见做法。
例如 :
/employees?deptId=30
只返回部门为 30 的员工/employees?dateofBirth=19900101
仅返回 DOB 为 1990 年 1 月 1 日的员工/employees?deptId=30&dateofBirth=19900101
同时满足上述条件的员工返岗。
推荐阅读
- javascript - 如何将对象显示到不同的选项卡中
- mysql - 无法使用 xampp 访问我的本地主机中的 phpmyadmind 文件
- python - 使用 Django 和 Mailchimp 的电子邮件订阅表单在部署后不起作用 (DigitalOcean)
- docker - 如何从单个 Docker 映像定位多个 .NET Core 版本?
- python - 显示来自 2 个表的数据并对其进行排序
- javascript - POST req:仅支持绝对 URL
- ios - 无法在 ios 上运行新的 kotlin 多平台应用程序
- unity3d - 启动 Unity 项目时如何解决此问题?
- c - 如何定义一个接受任意数量参数并扩展为仅给出偶数参数的宏?
- android - Android Chrome 自定义选项卡意图过滤器仅限于我的应用程序?