feat:增加人脸参数校验
This commit is contained in:
parent
740f90b756
commit
5ff97e0629
@ -3,7 +3,7 @@ import {cmdIds, Result, subCmdIds} from '../constant'
|
|||||||
import {convertWeekdaysToNumber, createPackageEnd, md5Encrypt, parseTimeToList, timestampToArray} from "../format.js";
|
import {convertWeekdaysToNumber, createPackageEnd, md5Encrypt, parseTimeToList, timestampToArray} from "../format.js";
|
||||||
import {sm4} from "sm-crypto";
|
import {sm4} from "sm-crypto";
|
||||||
import {
|
import {
|
||||||
checkRepeatCardName, checkRepeatFingerprintName,
|
checkRepeatCardName, checkRepeatFaceName, checkRepeatFingerprintName,
|
||||||
clearAllIcCard,
|
clearAllIcCard,
|
||||||
deleteIcCardRequest, getFingerprintListRequest,
|
deleteIcCardRequest, getFingerprintListRequest,
|
||||||
getIcCardListRequest,
|
getIcCardListRequest,
|
||||||
@ -31,7 +31,7 @@ function _checkRequiredFields(params, requiredFields) {
|
|||||||
* 注册扩展产品(卡片、指纹等)
|
* 注册扩展产品(卡片、指纹等)
|
||||||
*
|
*
|
||||||
* @param {Object} params - 所需参数
|
* @param {Object} params - 所需参数
|
||||||
* @param {string} params.type - 产品类型,['card','fingerprint']
|
* @param {string} params.type - 产品类型,['card','fingerprint','face']
|
||||||
* @param {string} params.keyId - 钥匙 ID
|
* @param {string} params.keyId - 钥匙 ID
|
||||||
* @param {string} params.uid - 用户 ID
|
* @param {string} params.uid - 用户 ID
|
||||||
* @param {number} params.userCountLimit - 使用次数限制,整型,0xFFFF 表示不限次数
|
* @param {number} params.userCountLimit - 使用次数限制,整型,0xFFFF 表示不限次数
|
||||||
@ -40,8 +40,8 @@ function _checkRequiredFields(params, requiredFields) {
|
|||||||
* @param {number} params.isForce - 是否胁迫,整型,1 表示是,0 表示否
|
* @param {number} params.isForce - 是否胁迫,整型,1 表示是,0 表示否
|
||||||
* @param {number} params.isRound - 是否循环,整型,1 表示是,0 表示否
|
* @param {number} params.isRound - 是否循环,整型,1 表示是,0 表示否
|
||||||
* @param {array} params.weekDays - 循环周期,数组,Bit0 -- 6 置位分别代表周日 -- 周六,例如:循环星期一、星期二、星期四,对应为:[1,2,4]
|
* @param {array} params.weekDays - 循环周期,数组,Bit0 -- 6 置位分别代表周日 -- 周六,例如:循环星期一、星期二、星期四,对应为:[1,2,4]
|
||||||
* @param {number} params.startDate - 生效日期,时间戳
|
* @param {number} params.startDate - 生效日期,时间戳,永久则填0
|
||||||
* @param {number} params.endDate - 失效日期,时间戳
|
* @param {number} params.endDate - 失效日期,时间戳,永久则填0
|
||||||
* @param {string} params.startTime - 生效时间,字符串,例如:'00:00'
|
* @param {string} params.startTime - 生效时间,字符串,例如:'00:00'
|
||||||
* @param {string} params.endTime - 失效时间,字符串,例如:'00:00'
|
* @param {string} params.endTime - 失效时间,字符串,例如:'00:00'
|
||||||
* @param {number} params.cardId - 卡片Id,仅当 type 为 'card' 且operate=1 时需要
|
* @param {number} params.cardId - 卡片Id,仅当 type 为 'card' 且operate=1 时需要
|
||||||
@ -53,13 +53,17 @@ function _checkRequiredFields(params, requiredFields) {
|
|||||||
* @param {string} params.fingerprintNumber - 指纹序号,仅当 type 为 'fingerprint' 时需要
|
* @param {string} params.fingerprintNumber - 指纹序号,仅当 type 为 'fingerprint' 时需要
|
||||||
* @param {number} params.fingerprintType - 指纹类型,1:永久,2:期限,3:单次,4:循环,仅当 type 为 'fingerprint' 时需要
|
* @param {number} params.fingerprintType - 指纹类型,1:永久,2:期限,3:单次,4:循环,仅当 type 为 'fingerprint' 时需要
|
||||||
* @param {number} params.fingerprintUserNo - 指纹UserNo,仅当 type 为 'fingerprint' 时需要 (选填)
|
* @param {number} params.fingerprintUserNo - 指纹UserNo,仅当 type 为 'fingerprint' 时需要 (选填)
|
||||||
|
* @param {number} params.faceName - 人脸名,仅当 type 为 'face' 时需要
|
||||||
|
* @param {string} params.faceNumber - 指纹序号,仅当 type 为 'face' 时需要
|
||||||
|
* @param {number} params.faceType - 指纹类型,1:永久,2:期限,4:循环,仅当 type 为 'face' 时需要
|
||||||
|
* @param {number} params.faceUserNo - 指纹UserNo,仅当 type 为 'face' 时需要 (选填)
|
||||||
* @returns {Promise<Result>} - 返回注册结果的 Promise 对象
|
* @returns {Promise<Result>} - 返回注册结果的 Promise 对象
|
||||||
*/
|
*/
|
||||||
export async function registerExtendedProducts(params) {
|
export async function registerExtendedProducts(params) {
|
||||||
|
|
||||||
// 确认产品类型存在
|
// 确认产品类型存在
|
||||||
if (!params.type) {
|
if (!params.type) {
|
||||||
return new Result(Result.NotMoreData, null, '注册扩展产品类型不能为空');
|
return new Result(Result.NotMoreData, null, '注册扩展产品类型type不能为空');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果是卡片的话需要增加的参数
|
// 如果是卡片的话需要增加的参数
|
||||||
@ -106,12 +110,12 @@ export async function registerExtendedProducts(params) {
|
|||||||
return new Result(Result.NotMoreData, null, `指纹信息不完整: ${missingField}`);
|
return new Result(Result.NotMoreData, null, `指纹信息不完整: ${missingField}`);
|
||||||
}
|
}
|
||||||
// 检查卡昵称是否重复
|
// 检查卡昵称是否重复
|
||||||
const checkRepeatCardNameResult = await checkRepeatFingerprintName({
|
const checkRepeatFingerprintNameResult = await checkRepeatFingerprintName({
|
||||||
lockId: this.lockInfo.lockId,
|
lockId: this.lockInfo.lockId,
|
||||||
fingerprintName: params.fingerprintName
|
fingerprintName: params.fingerprintName
|
||||||
})
|
})
|
||||||
if (checkRepeatCardNameResult.code !== Result.Success.code) {
|
if (checkRepeatFingerprintNameResult.code !== Result.Success.code) {
|
||||||
return checkRepeatCardNameResult
|
return checkRepeatFingerprintNameResult
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,6 +135,40 @@ export async function registerExtendedProducts(params) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 如果是人脸的话需要增加的参数
|
||||||
|
if (params.type === 'face') {
|
||||||
|
if (params.operate === 0) {
|
||||||
|
const cardRequiredFields = ['faceName', 'faceNumber', 'faceType'];
|
||||||
|
const missingField = _checkRequiredFields(params, cardRequiredFields);
|
||||||
|
if (missingField) {
|
||||||
|
return new Result(Result.NotMoreData, null, `人脸信息不完整: ${missingField}`);
|
||||||
|
}
|
||||||
|
// 检查卡昵称是否重复
|
||||||
|
const checkRepeatFaceNameResult = await checkRepeatFaceName({
|
||||||
|
lockId: this.lockInfo.lockId,
|
||||||
|
faceName: params.faceName
|
||||||
|
})
|
||||||
|
if (checkRepeatFaceNameResult.code !== Result.Success.code) {
|
||||||
|
return checkRepeatFaceNameResult
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改指纹时的参数校验
|
||||||
|
if (params.operate === 1 || params.operate === 2) {
|
||||||
|
let cardRequiredFields = ['faceId'];
|
||||||
|
if (params.operate === 1) {
|
||||||
|
cardRequiredFields.push('faceType')
|
||||||
|
}
|
||||||
|
if (params.operate === 2) {
|
||||||
|
cardRequiredFields.push('faceNumber')
|
||||||
|
}
|
||||||
|
const missingField = _checkRequiredFields(params, cardRequiredFields);
|
||||||
|
if (missingField) {
|
||||||
|
return new Result(Result.NotMoreData, null, `人脸信息不完整: ${missingField}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 添加类型:1蓝牙,2远程,3发卡器
|
// 添加类型:1蓝牙,2远程,3发卡器
|
||||||
params.addType = 1;
|
params.addType = 1;
|
||||||
// 操作后不断开蓝牙
|
// 操作后不断开蓝牙
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user