debug
This commit is contained in:
@@ -35,12 +35,7 @@ class ChapterModel extends MongoModel
|
||||
],
|
||||
'projection' => [
|
||||
'_id' => 0,
|
||||
'c_page_title' => 0,
|
||||
'c_page_keywords' => 0,
|
||||
'c_page_description' => 0,
|
||||
'c_source_uri' => 0,
|
||||
'c_source_id' => 0,
|
||||
'c_site_name' => 0,
|
||||
'c_site_code' => 0,
|
||||
'c_site_uuid' => 0,
|
||||
|
||||
|
||||
63
code/app/model/CountersModel.php
Normal file
63
code/app/model/CountersModel.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\model;
|
||||
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class CountersModel extends MongoModel
|
||||
{
|
||||
/**
|
||||
* Undocumented variable
|
||||
*
|
||||
* @var self
|
||||
*/
|
||||
static public $obj;
|
||||
|
||||
static public function getInstance(): self
|
||||
{
|
||||
if (self::$obj == NULL) {
|
||||
self::$obj = new self;
|
||||
}
|
||||
return self::$obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented variable
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $strCollection = 'counters';
|
||||
|
||||
static public $arrOptions = [
|
||||
'typeMap' => [
|
||||
'root' => 'array',
|
||||
'document' => 'array',
|
||||
'array' => 'array',
|
||||
],
|
||||
'projection' => [
|
||||
'_id' => 0,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* 获取下一个自增序列值
|
||||
* @param string $strSequenceName 序列名称
|
||||
* @return int 自增 ID
|
||||
*/
|
||||
public function getNextSequence(string $strSequenceName): int
|
||||
{
|
||||
$Result = $this->getCol()->findOneAndUpdate(
|
||||
['_id' => $strSequenceName],
|
||||
['$inc' => ['sequence_value' => 1]],
|
||||
[
|
||||
'upsert' => true,
|
||||
'returnDocument' => \MongoDB\Operation\FindOneAndUpdate::RETURN_DOCUMENT_AFTER
|
||||
]
|
||||
);
|
||||
return $Result->sequence_value ?? 1;
|
||||
}
|
||||
}
|
||||
@@ -129,4 +129,19 @@ abstract class MongoModel
|
||||
$Result = $this->getCol()->insertOne($arrData);
|
||||
return $Result->getInsertedId();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新单条数据
|
||||
* @param string $strColName 集合名称
|
||||
* @param array $arrFilter 查询条件
|
||||
* @param array $arrUpdate 更新内容
|
||||
* @param array $arrOptions 更新选项
|
||||
* @return int 受影响的文档数
|
||||
*/
|
||||
public function updateOne(array $arrFilter, array $arrUpdate, array $arrOptions = []): int
|
||||
{
|
||||
$Result = $this->getCol()->updateOne($arrFilter, $arrUpdate, $arrOptions);
|
||||
return $Result->getModifiedCount();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,17 +43,9 @@ class NovelModel extends MongoModel
|
||||
],
|
||||
'projection' => [
|
||||
'_id' => 0,
|
||||
'og_title' => 0,
|
||||
'n_site_name' => 0,
|
||||
'n_site_code' => 0,
|
||||
'n_site_uuid' => 0,
|
||||
'n_source_id' => 0,
|
||||
'n_page_title' => 0,
|
||||
'og_image' => 0,
|
||||
'og_novel_latest_chapter_url' => 0,
|
||||
'og_novel_read_url' => 0,
|
||||
'og_type' => 0,
|
||||
'og_url' => 0,
|
||||
],
|
||||
];
|
||||
|
||||
@@ -171,7 +163,7 @@ class NovelModel extends MongoModel
|
||||
$arrOptions = self::$arrOptions;
|
||||
}
|
||||
|
||||
$arrNovel = $this->getOne($arrFilter, $arrOptions);
|
||||
$arrNovel = $this->getOne($arrFilter, $arrOptions);
|
||||
|
||||
if (!empty($arrNovel)) {
|
||||
applyToKeys($arrNovel, ['created_at', 'updated_at'], 'formatMongoDate');
|
||||
|
||||
Reference in New Issue
Block a user