设备端上传人脸照片接口

POST /m/staff/saveFaceByDevice

Content-Type: multipart/form-data

登录校验: 不校验登录 token,设备端不需要登录。

链路: 图片压缩 -> 附件上传 -> 百度人脸注册 -> 写入 hardware_img -> 更新 staff -> 更新 staff_face -> MQ 同步设备

请求参数

参数类型必填说明
staff_uuidstring人员 uuid
face_imgfile人脸照片文件

成功响应

{
  "code": 0,
  "message": "上传成功",
  "data": {
    "uuid": "staff-uuid",
    "staff_uuid": "staff-uuid",
    "name": "张三",
    "nickname": "张三",
    "mobile": "13800000000",
    "face_img_url": "static/upload/sjtp/20260618/xxx.jpg",
    "face_img_full_url": "https://example.com/static/upload/sjtp/20260618/xxx.jpg",
    "hardware_img_uuid": "hardware-img-uuid",
    "hardware_uuid": "hardwareuuidwithoutdash",
    "hardware_time": "2026-06-18 12:00:00",
    "hardware_flag": 1
  }
}

失败响应

{
  "code": 1,
  "message": "失败原因",
  "data": []
}
message场景
参数错误staff_uuid 为空
人脸参数错误face_img 文件为空
人员参数错误按 staff_uuid 找不到人员
会员信息不存在人员存在但 is_show 无效
百度人脸识别失败:...百度注册或识别失败
修改人脸数据失败staff_face 更新/新增失败

curl 示例

curl -X POST 'http://127.0.0.1/m/staff/saveFaceByDevice' \
  -F 'staff_uuid=staff-uuid' \
  -F 'face_img=@/path/to/face.jpg'

注意事项

当前实现保持现有链路风格,未新增数据库事务。附件上传、百度注册、写库和 MQ 同步为串行执行;如后半段失败,前半段外部副作用不会自动回滚。