Newer
Older
CasicBioRecNew / dao / util / CacheManager.cpp
Tan Yue on 2 Jun 2022 882 bytes 20220602 人脸识别优化整合
#include "CacheManager.h"

CacheManager::CacheManager()
{
    deptCache = new QList<QVariantMap>();

    SysDictDao dictDao;
    genderName = dictDao.findChildDictByCode("gender");
}

QList<QVariantMap> * CacheManager::getDeptCachePtr()
{
    return deptCache;
}

QVariantMap CacheManager::getGenderName()
{
    return genderName;
}

void CacheManager::updateDeptCache()
{
    SysDeptDao deptDao;
    QVector<QVariantMap> deptList = deptDao.findRecordsByProperty("pid", "0");

    // 将之前的缓存清空
    if (deptCache->isEmpty() == false)
    {
        QMutex mutex;
        mutex.lock();
        deptCache->clear();
        mutex.unlock();
    }

    // 如果查询到数据则更新缓存
    if (deptList.isEmpty() == false)
    {
        for (int i = 0; i < deptList.size(); i++)
        {
            deptDao.appendChild(deptCache, deptList.at(i));
        }
    }
}