2024-10-24 09:04:38 +08:00

99 lines
2.1 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# -*- coding:utf-8 -*-
"""
@File : meian_model
@Author : xuxingchen
@Version : 1.0
@Contact : xuxingchen@sinochem.com
@Desc : Data Entity
"""
from pydantic import BaseModel
# 错误码
error_code = {
0: "成功",
-1: "图片下载超时",
-2: "图片下载失败",
-3: "用户ID不存在",
-4: "参数无效",
-5: "注册失败",
-6: "用户ID已存在",
-7: "无效人脸",
-8: "内部错误",
-9: "图片解码失败图像尺寸宽高像素应为540*960",
-10: "添加人脸失败",
-11: "人脸图像无特征",
-12: "查询离线通行记录失败",
-13: "设备忙",
-14: "rf_id_not_exist",
-15: "rf_id_existed",
-16: "add_rf_id_failed or rm_rf_id_failed",
-17: "get_rf_id_reader_mode_failed",
-18: "set_rf_id_reader_mode_failed",
-19: "添加人脸操作不支持",
}
class BaseInfo(BaseModel):
data_type: str = None
def check(self):
for attr in self.__dict__.keys():
# if property can be null, default value should not be set to None
if self.__dict__[attr] is None:
raise ValueError(f"{attr} not allowed to be set to None")
class BaseRequest(BaseInfo):
device_id: str = None
token: str = None
class BaseResponse(BaseInfo):
factory_id: str = None
error_code: int = None
token: str = None
class HeartBeat(BaseInfo):
device_id: str = None
factory_id: str = None
class PushRtAccessRecord(HeartBeat):
time: str = None
user_id: str = None
access_mode: str = None
class Register(BaseRequest):
factory_id: str = None # 厂商唯一标识
device_type: int = None # 0面板机1梯控机
device_position_code: str = None
device_position_desc: str = None
class FaceInfo(BaseModel):
dataType: str
deviceId: str
token: str
userId: str
faceUrl: str
floor: int
class QrCodeInfo(BaseModel):
dataType: str
deviceId: str
token: str
userId: str
qrCode: str
floor: int
class DeleteUser(BaseModel):
dataType: str
deviceId: str
token: str
userId: str