From fe4d374448064b80a9b8a26dbea1c69958e21382 Mon Sep 17 00:00:00 2001 From: luoqing Date: Fri, 2 Jun 2023 20:29:40 +0800 Subject: [PATCH] fix(feature-db):Fix the issue of not obtaining features from the database when deviceSerialNumber is empty MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复deviceSerialNumber为空时,从数据库获取不到feature的问题 --- ...ix-the-issue-of-not-obtaining-featur.patch | 78 +++++++++++++++++++ kiran-authentication-devices.spec | 6 +- 2 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 0001-fix-feature-db-Fix-the-issue-of-not-obtaining-featur.patch diff --git a/0001-fix-feature-db-Fix-the-issue-of-not-obtaining-featur.patch b/0001-fix-feature-db-Fix-the-issue-of-not-obtaining-featur.patch new file mode 100644 index 0000000..d0b704d --- /dev/null +++ b/0001-fix-feature-db-Fix-the-issue-of-not-obtaining-featur.patch @@ -0,0 +1,78 @@ +From bdb3eb90ad2ab0f08365b71fefb33c76b96c4359 Mon Sep 17 00:00:00 2001 +From: luoqing +Date: Fri, 2 Jun 2023 19:09:11 +0800 +Subject: [PATCH] fix(feature-db):Fix the issue of not obtaining features from + the database when deviceSerialNumber is empty +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +- 修复deviceSerialNumber为空时,从数据库获取不到feature的问题 +--- + src/device/fingerprint/fp-zk-device.cpp | 1 + + src/feature-db.cpp | 18 +++++++++++++++--- + 2 files changed, 16 insertions(+), 3 deletions(-) + +diff --git a/src/device/fingerprint/fp-zk-device.cpp b/src/device/fingerprint/fp-zk-device.cpp +index 4d8abc0..16ceb37 100644 +--- a/src/device/fingerprint/fp-zk-device.cpp ++++ b/src/device/fingerprint/fp-zk-device.cpp +@@ -398,6 +398,7 @@ QString FPZKDevice::identifyFeature(QByteArray fpTemplate, QStringList featureID + + if (saveList.count() == 0) + { ++ KLOG_DEBUG() << "no found feature"; + return QString(); + } + +diff --git a/src/feature-db.cpp b/src/feature-db.cpp +index ee0a4bd..a8aa883 100644 +--- a/src/feature-db.cpp ++++ b/src/feature-db.cpp +@@ -92,7 +92,7 @@ bool FeatureDB::addFeature(const QString &featureID, QByteArray feature, DeviceI + query.bindValue(":idVendor", deviceInfo.idVendor); + query.bindValue(":idProduct", deviceInfo.idProduct); + query.bindValue(":deviceType", (int)deviceType); +- query.bindValue(":deviceSerialNumber", deviceSerialNumber); ++ query.bindValue(":deviceSerialNumber", deviceSerialNumber.isEmpty() ? QVariant(QVariant::String) : deviceSerialNumber); + return query.exec(); + } + +@@ -121,12 +121,19 @@ QByteArray FeatureDB::getFeature(const QString &featureID) + QList FeatureDB::getFeatures(const QString &idVendor, const QString &idProduct, DeviceType deviceType, const QString &deviceSerialNumber) + { + QSqlQuery query(m_database); +- query.prepare("SELECT feature FROM feature WHERE idVendor = :Vid AND idProduct = :Pid AND deviceType = :devType AND deviceSerialNumber = :serialNumber"); ++ QString sql = "SELECT feature FROM feature WHERE idVendor = :Vid AND idProduct = :Pid AND deviceType = :devType"; ++ if (!deviceSerialNumber.isEmpty()) ++ { ++ sql.append(" AND deviceSerialNumber = :serialNumber"); ++ } ++ ++ query.prepare(sql); + query.bindValue(":Vid", idVendor); + query.bindValue(":Pid", idProduct); + query.bindValue(":devType", (int)deviceType); + query.bindValue(":serialNumber", deviceSerialNumber); + query.exec(); ++ + QByteArrayList featuresList; + while (query.next()) + { +@@ -153,7 +160,12 @@ QList FeatureDB::getAllFeatures() + QStringList FeatureDB::getFeatureIDs(const QString &idVendor, const QString &idProduct, DeviceType deviceType, const QString &deviceSerialNumber) + { + QSqlQuery query(m_database); +- query.prepare("SELECT featureID FROM feature WHERE idVendor = :Vid AND idProduct = :Pid AND deviceType = :devType AND deviceSerialNumber = :serialNumber"); ++ QString sql = "SELECT featureID FROM feature WHERE idVendor = :Vid AND idProduct = :Pid AND deviceType = :devType"; ++ if (!deviceSerialNumber.isEmpty()) ++ { ++ sql.append(" AND deviceSerialNumber = :serialNumber"); ++ } ++ + query.bindValue(":Vid", idVendor); + query.bindValue(":Pid", idProduct); + query.bindValue(":devType", (int)deviceType); +-- +2.33.0 + diff --git a/kiran-authentication-devices.spec b/kiran-authentication-devices.spec index bd24bba..a7a1978 100644 --- a/kiran-authentication-devices.spec +++ b/kiran-authentication-devices.spec @@ -1,7 +1,7 @@ Name: kiran-authentication-devices Version: 2.5.1 -Release: 3 +Release: 4 Summary: Kiran Authentication Devices License: MulanPSL-2.0 @@ -9,6 +9,7 @@ Source0: %{name}-%{version}.tar.gz Patch0001: 0001-fix-mf-iristar-driver-Fix-compilation-issues-with-st.patch Patch0002: 0001-fix-ukey-Fix-the-issue-where-only-one-ukey-can-be-bo.patch +Patch0003: 0001-fix-feature-db-Fix-the-issue-of-not-obtaining-featur.patch BuildRequires: cmake BuildRequires: gcc-c++ @@ -66,6 +67,9 @@ systemctl enable kiran-authentication-devices.service rm -rf ${buildroot} %changelog +* Fri Jun 2 2023 luoqing - 2.5.1-4 +- KYOS-F: Fix the issue of not obtaining features from the database when deviceSerialNumber is empty + * Fri Jun 2 2023 luoqing - 2.5.1-3 - KYOS-F: Fix the issue where only one ukey can be bound to a device, some self-test bugs.(#I78P3F)