This commit is contained in:
Default
2025-04-27 20:25:57 +08:00
parent be68955929
commit d3bdb0ec9a
7 changed files with 1084 additions and 15 deletions

View File

@@ -131,16 +131,26 @@ class ConfigSubjectFomartModel extends MongoModel
}
/**
* 根据小说ID查询指定小说
* 根据CSFKEY 获取模板数据
*
* @param integer $intNId
* @param string $strCsfKey
* @return array
*/
public function getConfigSubjectFomartByCsfKey(string $intNId): null|array
public function getConfigSubjectFomartByCsfKey(string $strCsfKey): null|array
{
$arrFilter = ['csf_key' => $intNId];
$arrFilter = ['csf_key' => $strCsfKey];
return $this->findOne($arrFilter);
}
/**
* 根据CSFKEY 删除数据
*
* @param string $strCsfKey
* @return array
*/
public function delConfigSubjectFomartByCsfKey(string $strCsfKey): int
{
$arrFilter = ['csf_key' => $strCsfKey];
return $this->delete($arrFilter);
}
}

View File

@@ -106,7 +106,8 @@ class DomainModel extends BaseModel
$arrAllSubjectFomartModel = SubjectFomartModel::getAllSubjectFomartOnCacheBySfgId($intSfgId);
if (empty($arrAllSubjectFomartModel)) {
return '';
$strError = sprintf("subject fomart [%s] not found !", $strKey);
throw new \Exception($strError);
}
if ($boolJoin) {
@@ -136,9 +137,20 @@ class DomainModel extends BaseModel
break;
}
}
# FIX 补丁,用于修复站点配置发生修改但MONGO记录的数据无法找到MYSQL配置数据发生的异常
if ($SubjectFomartModel == NULL && count($arrAllSubjectFomartModel) > 0) {
ConfigSubjectFomartModel::getInstance()->delConfigSubjectFomartByCsfKey($strUUId);
return $this->getFomartSubjectEx($strKey, $strDomain, $strController, $strAction, $strDiff, $boolJoin);
}
}
return $SubjectFomartModel->sf_val ?? '';
if (empty($SubjectFomartModel)) {
$strError = sprintf("subject fomart [%s] not found !", $strKey);
throw new \Exception($strError);
}
return $SubjectFomartModel->sf_val;
}
/**

View File

@@ -133,7 +133,6 @@ abstract class MongoModel
/**
* 更新单条数据
* @param string $strColName 集合名称
* @param array $arrFilter 查询条件
* @param array $arrUpdate 更新内容
* @param array $arrOptions 更新选项
@@ -144,4 +143,27 @@ abstract class MongoModel
$Result = $this->getCol()->updateOne($arrFilter, $arrUpdate, $arrOptions);
return $Result->getModifiedCount();
}
/**
* 删除单条数据
* @param array $arrFilter 查询条件
* @return int 受影响的文档数
*/
public function deleteOne(array $arrFilter, array $arrOptions = []): int
{
$Result = $this->getCol()->deleteOne($arrFilter, $arrOptions);
return $Result->getDeletedCount();
}
/**
* 删除多条数据
* @param array $arrFilter 查询条件
* @return int 受影响的文档数
*/
public function delete(array $arrFilter, array $arrOptions = []): int
{
$Result = $this->getCol()->deleteMany($arrFilter, $arrOptions);
return $Result->getDeletedCount();
}
}

View File

@@ -79,7 +79,7 @@ class VideoModel extends MongoModel
/**
* 直接读库查询大量小说
*
* @param integer $intNId
* @param integer $intVId
* @return null|array
*/
public function findMany(array $arrFilter, int $intCount = 10, array $arrSort = [], array $arrOptions = []): null|array
@@ -170,12 +170,12 @@ class VideoModel extends MongoModel
/**
* 根据小说ID查询指定小说
*
* @param integer $intNId
* @param integer $intVId
* @return array
*/
public function getVideoByNId(int $intNId): null|array
public function getVideoByVId(int $intVId): null|array
{
$arrFilter = ['v_id' => $intNId];
$arrFilter = ['v_id' => $intVId];
return $this->findOne($arrFilter);
}
@@ -439,12 +439,12 @@ class VideoModel extends MongoModel
$Cursor = $VideoClicksModel->getCol()->find($arrFilter, $arrOptions);
$arrNId = [];
$arrVId = [];
foreach ($Cursor as $Doc) {
$arrNId[] = $Doc['v_id'];
$arrVId[] = $Doc['v_id'];
}
$arrFilter = ['v_id' => ['$in' => $arrNId]];
$arrFilter = ['v_id' => ['$in' => $arrVId]];
$arrOptions = self::$arrOptions;
unset($arrOptions['typeMap']);