人员管理
人员相关下行接口。返回字段为 snake_case。名单上限 20000,超出返回 403(名单已达到上限)。
人员列表
POST
/Person/list
Base: http://<设备IP>:18081
Body
| 字段 | 类型 | 默认 | 说明 |
|---|---|---|---|
page | number | 1 | 页码,从 1 起 |
page_size | number | 50 | 每页条数,最大 500 |
is_blacklist | number | — | 不传=全部;0 仅白名单;1 仅黑名单 |
响应
{
"ok": true,
"data": {
"total": 20000,
"page": 1,
"page_size": 50,
"list": [
{
"id": 1,
"person_id": "P10086",
"name": "张三",
"department": "研发部",
"weigen_no": "00000001",
"create_time": 1710000000000,
"update_time": 1710001000000,
"face_expiry": "2050-01-01",
"time_period": "",
"time_segments": "[]",
"is_blacklist": 0,
"synced": 0,
"has_photo": true,
"photo_url": "/Person/photo?id=1"
}
]
}
}
| 字段 | 类型 | 说明 |
|---|---|---|
total | number | 总条数 |
page | number | 当前页 |
page_size | number | 每页大小 |
list[].id | number | 设备本地自增主键 |
list[].person_id | string | 业务唯一键 |
list[].name | string | 姓名 |
list[].department | string | 部门 |
list[].weigen_no | string | 韦根号 |
list[].create_time | number | 创建时间(毫秒) |
list[].update_time | number | 更新时间(毫秒) |
list[].face_expiry | string | 有效期,如 2050-01-01 |
list[].time_period | string | 时间段说明 |
list[].time_segments | string | 通行时段 JSON,见下 |
list[].is_blacklist | number | 0 白名单,1 黑名单 |
list[].synced | number | 0 / 1 |
list[].has_photo | boolean | 是否有人脸照片 |
list[].photo_url | string | /Person/photo?id=<id>,无照片为空串 |
time_segments:分钟数区间数组(自 0:00 起算)。[] 表示全天。示例:[{"start":540,"end":1080}] 为 09:00–18:00。
排序:update_time ASC, id ASC(与云端人员列表增量拉取一致)。
示例
curl -X POST "http://192.168.1.100:18081/Person/list" \
-H "Authorization: Bearer ${TOKEN}" \
-F "page=1" \
-F "page_size=50"
# 仅黑名单
curl -X POST "http://192.168.1.100:18081/Person/list" \
-H "Authorization: Bearer ${TOKEN}" \
-F "page=1" \
-F "page_size=50" \
-F "is_blacklist=1"
人员详情
POST
/Person/detail/<id>
Base: http://<设备IP>:18081
路径参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
id | number | 必填 | 设备本地数字 id(本路径仍只支持本机 id,不支持 person_id) |
Body
无。
data 结构同列表单条。
| HTTP | message |
|---|---|
| 400 | invalid person id |
| 404 | person not found |
示例
curl -X POST "http://192.168.1.100:18081/Person/detail/12" \
-H "Authorization: Bearer ${TOKEN}" \
-F "_="
新增人员
POST
/Person/add
Base: http://<设备IP>:18081
Body
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
name | string | 必填 | 姓名 |
person_id | string | 可选 | 业务唯一键;不传由设备生成;冲突报 409 |
department | string | 可选 | 部门 |
weigen_no | string | 可选 | 韦根号;空则自动生成 |
face_expiry | string | 可选 | 有效期,默认 2050-01-01 |
time_period | string | 可选 | 时间段说明 |
time_segments | string | 可选 | 时段 JSON,默认 [] |
is_blacklist | string | 可选 | 1 黑名单,否则白名单 |
photo 或 face | file | 可选 | 人脸图片(JPEG / PNG / WebP),优先 photo;不超过 1MB |
响应
{ "ok": true, "data": { "id": 15, "person_id": "P10086" } }
| HTTP | message |
|---|---|
| 400 | name is required |
| 400 | photo exceeds 1MB limit |
| 400 | no face detected or template extract failed |
| 403 | 名单已达到上限 |
| 409 | person id already registered |
| 500 | add person failed / multipart add failed |
示例
curl -X POST "http://192.168.1.100:18081/Person/add" \
-H "Authorization: Bearer ${TOKEN}" \
-F "name=张三" \
-F "department=研发部" \
-F "weigen_no=00000088" \
-F "face_expiry=2050-01-01" \
-F 'time_segments=[{"start":540,"end":1080}]' \
-F "is_blacklist=0" \
-F "photo=@/path/to/face.jpg"
编辑人员
POST
/Person/edit
Base: http://<设备IP>:18081
Body
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
id | string/number | 可选 | 设备本地主键;与 person_id 二选一(优先 id) |
person_id | string | 可选 | 业务唯一键;用于定位,不可改写已有人的业务编号 |
name | string | 必填 | 姓名 |
department | string | 可选 | 部门 |
weigen_no | string | 可选 | 韦根号;空则保留原值 |
face_expiry | string | 可选 | 有效期;空则默认 2050-01-01 |
time_period | string | 可选 | 时间段说明 |
time_segments | string | 可选 | 时段 JSON;空则 [] |
is_blacklist | string | 可选 | 1 黑名单 |
photo 或 face | file | 可选 | 人脸图片(JPEG / PNG / WebP);不超过 1MB |
有图时若与其他人脸重复,返回 409。
响应
{ "ok": true, "data": { "id": 15, "person_id": "P10086" } }
| HTTP | message |
|---|---|
| 400 | invalid person id / name is required / photo exceeds 1MB limit / 人脸检测失败 |
| 404 | person not found |
| 409 | face already registered |
示例
curl -X POST "http://192.168.1.100:18081/Person/edit" \
-H "Authorization: Bearer ${TOKEN}" \
-F "id=15" \
-F "name=张三丰" \
-F "department=研发部" \
-F "photo=@/path/to/new_face.jpg"
删除人员
POST
/Person/del
Base: http://<设备IP>:18081
Body
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
id | string/number | 可选 | 设备本地主键;与 person_id 二选一(优先 id) |
person_id | string | 可选 | 业务唯一键 |
响应
{ "ok": true, "data": { "id": 15, "person_id": "P10086" } }
示例
curl -X POST "http://192.168.1.100:18081/Person/del" \
-H "Authorization: Bearer ${TOKEN}" \
-F "id=15"
清空全部人员
POST
/Person/clear
Base: http://<设备IP>:18081
清空全部人员名单,并删除照片与特征模板文件。
Body
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
confirm | string | 必填 | 必须为 YES |
响应
{ "ok": true, "data": { "cleared": true, "deleted_count": 56 } }
| 字段 | 类型 | 说明 |
|---|---|---|
cleared | boolean | 是否已执行清空 |
deleted_count | number | 删除的人员行数 |
| HTTP | message |
|---|---|
| 400 | set confirm=YES to clear all persons and face files |
| 500 | clear failed / database error |
示例
curl -X POST "http://192.168.1.100:18081/Person/clear" \
-H "Authorization: Bearer ${TOKEN}" \
-F "confirm=YES"
人员照片
GET
/Person/photo?id=<id>
Base: http://<设备IP>:18081
Query
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
id | number | 必填 | 人员 ID |
响应
成功:图片二进制,Content-Type 为 image/jpeg 等。
| HTTP | message |
|---|---|
| 400 | invalid person id |
| 404 | person not found / no photo / photo file missing |
示例
curl -G "http://192.168.1.100:18081/Person/photo" \
-H "Authorization: Bearer ${TOKEN}" \
--data-urlencode "id=15" \
-o person_15.jpg
完整地址示例:http://192.168.1.100:18081/Person/photo?id=15