人员管理

人员相关下行接口。返回字段为 snake_case。名单上限 20000,超出返回 403(名单已达到上限)。

人员列表

POST /Person/list Base: http://<设备IP>:18081

Body

字段类型默认说明
pagenumber1页码,从 1 起
page_sizenumber50每页条数,最大 500
is_blacklistnumber—不传=全部;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"
      }
    ]
  }
}
字段类型说明
totalnumber总条数
pagenumber当前页
page_sizenumber每页大小
list[].idnumber设备本地自增主键
list[].person_idstring业务唯一键
list[].namestring姓名
list[].departmentstring部门
list[].weigen_nostring韦根号
list[].create_timenumber创建时间(毫秒)
list[].update_timenumber更新时间(毫秒)
list[].face_expirystring有效期,如 2050-01-01
list[].time_periodstring时间段说明
list[].time_segmentsstring通行时段 JSON,见下
list[].is_blacklistnumber0 白名单,1 黑名单
list[].syncednumber0 / 1
list[].has_photoboolean是否有人脸照片
list[].photo_urlstring/Person/photo?id=<id>,无照片为空串
i

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

路径参数

参数类型必填说明
idnumber必填设备本地数字 id(本路径仍只支持本机 id,不支持 person_id)

Body

无。

data 结构同列表单条。

HTTPmessage
400invalid person id
404person 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

字段类型必填说明
namestring必填姓名
person_idstring可选业务唯一键;不传由设备生成;冲突报 409
departmentstring可选部门
weigen_nostring可选韦根号;空则自动生成
face_expirystring可选有效期,默认 2050-01-01
time_periodstring可选时间段说明
time_segmentsstring可选时段 JSON,默认 []
is_blackliststring可选1 黑名单,否则白名单
photo 或 facefile可选人脸图片(JPEG / PNG / WebP),优先 photo;不超过 1MB

响应

{ "ok": true, "data": { "id": 15, "person_id": "P10086" } }
HTTPmessage
400name is required
400photo exceeds 1MB limit
400no face detected or template extract failed
403名单已达到上限
409person id already registered
500add 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

字段类型必填说明
idstring/number可选设备本地主键;与 person_id 二选一(优先 id)
person_idstring可选业务唯一键;用于定位,不可改写已有人的业务编号
namestring必填姓名
departmentstring可选部门
weigen_nostring可选韦根号;空则保留原值
face_expirystring可选有效期;空则默认 2050-01-01
time_periodstring可选时间段说明
time_segmentsstring可选时段 JSON;空则 []
is_blackliststring可选1 黑名单
photo 或 facefile可选人脸图片(JPEG / PNG / WebP);不超过 1MB
!

有图时若与其他人脸重复,返回 409。

响应

{ "ok": true, "data": { "id": 15, "person_id": "P10086" } }
HTTPmessage
400invalid person id / name is required / photo exceeds 1MB limit / 人脸检测失败
404person not found
409face 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

字段类型必填说明
idstring/number可选设备本地主键;与 person_id 二选一(优先 id)
person_idstring可选业务唯一键

响应

{ "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

字段类型必填说明
confirmstring必填必须为 YES

响应

{ "ok": true, "data": { "cleared": true, "deleted_count": 56 } }
字段类型说明
clearedboolean是否已执行清空
deleted_countnumber删除的人员行数
HTTPmessage
400set confirm=YES to clear all persons and face files
500clear 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

参数类型必填说明
idnumber必填人员 ID

响应

成功:图片二进制,Content-Type 为 image/jpeg 等。

HTTPmessage
400invalid person id
404person 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