79 lines
3.4 KiB
Diff
79 lines
3.4 KiB
Diff
|
|
From bdb3eb90ad2ab0f08365b71fefb33c76b96c4359 Mon Sep 17 00:00:00 2001
|
|||
|
|
From: luoqing <luoqing@kylinsec.com.cn>
|
|||
|
|
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<QByteArray> 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<QByteArray> 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
|
|||
|
|
|