User 接口
源码:src/business/controller/user/index.ts
前缀:/api/user
接口一览
| 方法 | 路径 | 鉴权 | 说明 |
|---|---|---|---|
| POST | /login | ignore | 登录,返回 token 等 |
| POST | /logout | ignore | 退出 |
| GET | /check_login | ignore | 检查登录态 |
| GET | /profile | 登录 | 当前用户资料 |
| POST | /profile/update | 登录 + RepeatSubmit | 改资料 |
| POST | /profile/password | 登录 + RepeatSubmit | 改密码 |
| POST | /page | 登录 | 用户分页 |
| POST | /create | ROLE_admin + system:user:create + RepeatSubmit | 创建 |
| POST | /update | ROLE_admin + system:user:update + RepeatSubmit | 修改 |
| POST | /get/:id | system:user:read + RateLimiter(IP) | 详情 |
| GET | /get_role/:id | 登录 | 用户角色 |
| POST | /bind_role | ROLE_admin | 绑定角色 |
| POST | /delete/:id | ROLE_admin + system:user:delete | 删除 |
写操作多带 @Log;创建接口示例使用 @Validate() + CreateUserDTO;详情接口示例限流:time=10, count=3, type=IP。
登录示例
http
POST /api/user/login
Content-Type: application/json
{
"username": "admin",
"password": "******"
}后续请求:
http
Authorization: <token>(也可使用 Bearer <token>,取决于 Auth 的 tokenPrefix;当前入口默认空前缀。)
分层文件
| 层 | 路径 |
|---|---|
| Controller | business/controller/user |
| Service | business/service/user.ts |
| Mapper / Entity | business/mapper/user*、entity/user* |