Files
biz_xfj_cloud/lib/common/models/api/user_api_models.dart
T
dzc d3b818a660 feat:增加预约统计的导出
feat:人脸审核、人脸质量的查询
feat:app购物车严格限制
2026-09-01 14:27:10 +08:00

386 lines
10 KiB
Dart
Raw 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.
import 'package:json_annotation/json_annotation.dart';
import 'package:pj_supermarket_cloud/common/index.dart';
part 'user_api_models.g.dart';
@JsonSerializable()
class ServiceUser {
/// 用户ID
String? userId;
/// 用户昵称
String? username;
/// 部门ID
String? deptId;
/// 手机号码
String? userMobile;
/// 用户头像
String? userAvatar;
/// 钱包id
String? walletId;
/// 钱包类型id
String? walletTypeId;
/// 钱包余额
int? walletBalance;
/// 是否冻结饭卡
@JsonKey(fromJson: JsonTool.stringToBoolean, toJson: JsonTool.booleanToString)
bool? walletIsFreeze;
/// 卡号
String? walletCardNumber;
/// 查询用户食堂信息
String? canteenId;
/// 构造函数
ServiceUser({
this.userId,
this.username,
this.deptId,
this.userMobile,
this.userAvatar,
this.walletId,
this.walletTypeId,
this.walletBalance,
this.walletIsFreeze,
this.walletCardNumber,
this.canteenId,
});
factory ServiceUser.fromJson(Map<String, dynamic> json) =>
_$ServiceUserFromJson(json);
Map<String, dynamic> toJson() => _$ServiceUserToJson(this);
}
@JsonSerializable()
class ServiceAuth {
/// 用户编号
final int? userId;
/// 访问令牌
final String? accessToken;
/// 刷新令牌
final String? refreshToken;
/// 过期时间
final int? expiresTime;
ServiceAuth({
required this.userId,
required this.accessToken,
required this.refreshToken,
required this.expiresTime,
});
factory ServiceAuth.fromJson(Map<String, dynamic> json) =>
_$ServiceAuthFromJson(json);
Map<String, dynamic> toJson() => _$ServiceAuthToJson(this);
}
@JsonSerializable()
class ServiceAsyncFace {
/// 编号
final String? id;
/// 人脸编号
final String? autoCode;
/// 人脸图片
final String? faceImg;
/// 用户id
final String? userId;
/// 用户名
final String? username;
/// 用户头像
final String? userAvatar;
/// 部门id
final String? deptId;
/// 部门名
final String? deptName;
/// 删除标志
@JsonKey(fromJson: JsonTool.stringToBoolean, toJson: JsonTool.booleanToString)
final bool? delFlag;
ServiceAsyncFace({
this.id,
this.autoCode,
this.faceImg,
this.userId,
this.username,
this.userAvatar,
this.deptId,
this.deptName,
this.delFlag,
});
factory ServiceAsyncFace.fromJson(Map<String, dynamic> json) =>
_$ServiceAsyncFaceFromJson(json);
Map<String, dynamic> toJson() => _$ServiceAsyncFaceToJson(this);
}
/// V3 部门人脸快照中的单条服务端权威记录。
@JsonSerializable()
class ServiceFaceSyncRecord {
/// 人脸记录数据库主键,作为分页顺序和快照范围的稳定标识。
@JsonKey(
fromJson: JsonTool.anyToRequiredString,
toJson: JsonTool.stringToInt,
)
final String id;
/// 虹软 32 位搜索标识,来源于服务端 autoCode。
@JsonKey(
fromJson: JsonTool.anyToRequiredString,
toJson: JsonTool.stringToInt,
)
final String sampleId;
/// 人脸所属用户主键,MQ 增量按该字段回查同一用户的全部人脸。
@JsonKey(
fromJson: JsonTool.anyToRequiredString,
toJson: JsonTool.stringToInt,
)
final String userId;
/// 用户姓名,用于本地识别结果和设置页展示。
final String? username;
/// 用户当前部门主键,保证终端只维护绑定部门及其子部门人脸。
@JsonKey(
fromJson: JsonTool.anyToRequiredString,
toJson: JsonTool.stringToInt,
)
final String deptId;
/// 用户当前部门名称,用于本地展示。
final String? deptName;
/// 服务端人脸图片地址,地址变化会触发重新下载与特征提取。
final String? faceImg;
/// 服务端人脸图片版本时间;未修改的历史记录由服务端回退为创建时间。
final DateTime? sourceUpdatedAt;
/// 创建一条 V3 人脸快照记录。
const ServiceFaceSyncRecord({
required this.id,
required this.sampleId,
required this.userId,
this.username,
required this.deptId,
this.deptName,
this.faceImg,
this.sourceUpdatedAt,
});
/// 从统一网络层返回的 JSON 创建快照记录。
factory ServiceFaceSyncRecord.fromJson(Map<String, dynamic> json) =>
_$ServiceFaceSyncRecordFromJson(json);
/// 将快照记录转换为 JSON,主要供模型测试和诊断使用。
Map<String, dynamic> toJson() => _$ServiceFaceSyncRecordToJson(this);
}
/// V3 部门人脸同步的固定上界游标页面。
@JsonSerializable()
class ServiceFaceSyncSnapshot {
/// 当前页面记录,服务端保证按数据库主键严格升序返回。
final List<ServiceFaceSyncRecord> records;
/// 下一页排他游标;末页仅用于终端完成连续性校验。
@JsonKey(
fromJson: JsonTool.anyToRequiredString,
toJson: JsonTool.stringToInt,
)
final String nextAfterId;
/// 是否还有位于固定快照上界内的下一页。
final bool hasMore;
/// 首次请求固定的人脸数据库主键上界,后续请求必须原样携带。
@JsonKey(
fromJson: JsonTool.anyToRequiredString,
toJson: JsonTool.stringToInt,
)
final String snapshotMaxId;
/// 创建一个固定上界游标页面。
const ServiceFaceSyncSnapshot({
required this.records,
required this.nextAfterId,
required this.hasMore,
required this.snapshotMaxId,
});
/// 从统一网络层返回的 JSON 创建快照页面。
factory ServiceFaceSyncSnapshot.fromJson(Map<String, dynamic> json) =>
_$ServiceFaceSyncSnapshotFromJson(json);
/// 将快照页面转换为 JSON,主要供模型测试使用。
Map<String, dynamic> toJson() => _$ServiceFaceSyncSnapshotToJson(this);
}
/// 终端批量删除服务端人脸后的幂等确认结果。
@JsonSerializable()
class ServiceTerminalFaceDeleteResult {
/// 本次实际逻辑删除的人脸样本编号。
final List<String> deletedSampleIds;
/// 请求前已经不存在的样本编号,本机可继续执行本地清理。
final List<String> alreadyAbsentSampleIds;
/// 创建一份服务端删除确认结果。
const ServiceTerminalFaceDeleteResult({
required this.deletedSampleIds,
required this.alreadyAbsentSampleIds,
});
/// 从统一网络层返回的 JSON 创建删除结果。
factory ServiceTerminalFaceDeleteResult.fromJson(Map<String, dynamic> json) =>
_$ServiceTerminalFaceDeleteResultFromJson(json);
/// 将删除结果转换为 JSON,主要供协议测试使用。
Map<String, dynamic> toJson() =>
_$ServiceTerminalFaceDeleteResultToJson(this);
/// 服务端允许本机清理的全部样本编号。
Set<String> get confirmedSampleIds => {
...deletedSampleIds,
...alreadyAbsentSampleIds,
};
}
/// 终端提交给服务端的一条在库人脸静态图片质量结果。
@JsonSerializable(createFactory: false)
class ServiceFaceQualityReportItem {
/// 创建一条符合 Hardware 批量上报协议的质量结果。
const ServiceFaceQualityReportItem({
required this.sampleId,
required this.status,
required this.sourceUpdatedAt,
required this.checkedAt,
this.score,
this.errorCode,
});
/// 虹软 32 位搜索样本编号,对应服务端人脸记录的 autoCode。
final String sampleId;
/// 检测状态,跨端协议值仅使用 detected 或 failed。
final String status;
/// 虹软静态图片质量分,detected 时范围为 0 到 1,failed 时为空。
final double? score;
/// 本次检测所依据的服务端人脸图片版本,来自 V3 快照 sourceUpdatedAt。
@JsonKey(toJson: JsonTool.dateTimeToServiceString)
final DateTime sourceUpdatedAt;
/// 终端完成本次检测的本地时间,用于阻止旧结果覆盖服务端新结果。
@JsonKey(toJson: JsonTool.dateTimeToServiceString)
final DateTime checkedAt;
/// 虹软 SDK 或终端插件错误码,检测成功时为空。
final int? errorCode;
/// 转换为统一 Dio 可直接发送的 JSON 请求条目。
Map<String, dynamic> toJson() => _$ServiceFaceQualityReportItemToJson(this);
}
/// 当前设备竞争商户部门人脸质量上报资格的结果。
@JsonSerializable()
class ServiceFaceQualityLease {
/// 创建一份租约竞争结果。
const ServiceFaceQualityLease({
required this.granted,
required this.remainingSeconds,
});
/// 当前设备是否取得租约;为 false 时本轮不发送质量批次。
final bool granted;
/// 当前租约剩余秒数,仅用于终端诊断日志。
final int remainingSeconds;
/// 从 Hardware 返回的 JSON 创建租约结果。
factory ServiceFaceQualityLease.fromJson(Map<String, dynamic> json) =>
_$ServiceFaceQualityLeaseFromJson(json);
/// 将租约结果转换为 JSON,主要供协议测试使用。
Map<String, dynamic> toJson() => _$ServiceFaceQualityLeaseToJson(this);
}
/// 服务端批量接收终端人脸质量后的幂等处理结果。
@JsonSerializable()
class ServiceFaceQualityReportResult {
/// 创建一份服务端质量上报确认结果。
const ServiceFaceQualityReportResult({
required this.updatedSampleIds,
required this.ignoredStaleSampleIds,
required this.alreadyAbsentSampleIds,
});
/// 本次成功写入服务端的样本编号。
final List<String> updatedSampleIds;
/// 因图片版本不一致、已有 detected 或检测时间较旧而忽略的样本编号。
final List<String> ignoredStaleSampleIds;
/// 请求时服务端已经不存在的样本编号。
final List<String> alreadyAbsentSampleIds;
/// 从统一网络层返回的 JSON 创建上报确认结果。
factory ServiceFaceQualityReportResult.fromJson(Map<String, dynamic> json) =>
_$ServiceFaceQualityReportResultFromJson(json);
/// 将确认结果转换为 JSON,主要供协议测试使用。
Map<String, dynamic> toJson() => _$ServiceFaceQualityReportResultToJson(this);
}
@JsonSerializable()
class ServiceTenant {
/// id
final String? id;
/// 编号
final String? code;
/// 编号
final String? name;
final String? menuId;
final String? miniQr;
ServiceTenant({
this.id,
this.code,
this.name,
this.menuId,
this.miniQr,
});
factory ServiceTenant.fromJson(Map<String, dynamic> json) =>
_$ServiceTenantFromJson(json);
Map<String, dynamic> toJson() => _$ServiceTenantToJson(this);
}