Anyon e7a8c05556 chore(repo): 统一 v8 仓库品牌名称
将 v8 重构分支中残留的 ThinkAdminDeveloper 文本统一调整为 ThinkAdmin,避免迁移到主仓库后继续暴露旧开发仓库名称。

主要内容:

- 更新 README 标题与项目描述。

- 统一 PHP 文件头注释中的项目标识。

- 同步调整测试、配置、插件与文档中的旧仓库名称文本。

- 保持旧包删除说明与架构边界测试语义不变,只清理品牌名称残留。
2026-05-08 16:15:24 +08:00

139 lines
4.2 KiB
PHP

<?php
declare(strict_types=1);
/**
* +----------------------------------------------------------------------
* | ThinkAdmin Plugin
* +----------------------------------------------------------------------
* | Copyright (c) 2014~2026 ThinkAdmin [ thinkadmin.top ]
* +----------------------------------------------------------------------
* | Official Website: https://thinkadmin.top
* +----------------------------------------------------------------------
* | Licensed: https://mit-license.org
* | Disclaimer: https://thinkadmin.top/disclaimer
* | Vip Rights: https://thinkadmin.top/vip-introduce
* +----------------------------------------------------------------------
* | Gitee Repository: https://gitee.com/zoujingli/ThinkAdmin
* | Github Repository: https://github.com/zoujingli/ThinkAdmin
* +----------------------------------------------------------------------
*/
namespace think\admin;
use think\admin\helper\QueryHelper;
use think\admin\model\QueryFactory;
use think\db\BaseQuery;
/**
* 基础模型类。
*
* @class Model
* @phpstan-consistent-constructor
* @mixin \think\db\Query
* @method static bool mSave(array $data = [], string $field = '', mixed $where = [])
* @method static bool mDelete(string $field = '', mixed $where = [])
* @method static bool|array mForm(string $template = '', string $field = '', mixed $where = [], array $data = [])
* @method static bool|int mUpdate(array $data = [], string $field = '', mixed $where = [])
* @method static QueryHelper mQuery($input = null, callable $callable = null)
* @method $this onAdminSave(string $changeIds)
* @method $this onAdminUpdate(string $changeIds)
* @method $this onAdminInsert(string $changeIds)
* @method $this onAdminDelete(string $changeIds)
*/
abstract class Model extends \think\Model
{
/**
* 日志过滤。
* @var callable
*/
public static $oplogCall;
protected string $autoWriteTimestamp = 'datetime';
protected $createTime = 'create_time';
protected $updateTime = 'update_time';
/**
* 日志类型。
* @var string
*/
protected $oplogType;
/**
* 日志名称。
* @var string
*/
protected $oplogName;
/**
* 静态魔术方法。
* @param string $method 方法名称
* @param array $args 调用参数
* @return false|int|mixed|QueryHelper
*/
public static function __callStatic($method, $args)
{
return QueryHelper::make(static::class, $method, $args, function ($method, $args) {
return parent::__callStatic($method, $args);
});
}
/**
* 调用魔术方法。
* @param string $method 方法名称
* @param array $args 调用参数
* @return $this|false|mixed
*/
public function __call($method, $args)
{
$oplogs = [
'onAdminSave' => '修改%s[%s]状态',
'onAdminUpdate' => '更新%s[%s]记录',
'onAdminInsert' => '增加%s[%s]成功',
'onAdminDelete' => '删除%s[%s]成功',
];
if (isset($oplogs[$method])) {
if ($this->oplogType && $this->oplogName) {
$changeIds = $args[0] ?? '';
if (is_callable(static::$oplogCall)) {
$changeIds = call_user_func(static::$oplogCall, $method, $changeIds, $this);
}
sysoplog($this->oplogType, lang($oplogs[$method], [lang($this->oplogName), $changeIds]));
}
return $this;
}
return parent::__call($method, $args);
}
/**
* 创建查询实例。
*/
public static function mq(array $data = []): BaseQuery
{
return QueryFactory::build(static::mk($data)->newQuery());
}
/**
* 创建模型实例。
*/
public static function mk(array $data = []): static
{
return new static($data);
}
/**
* 追加模型数据并标记为待持久化变更。
*/
public function appendData(array $data, bool $overwrite = false): static
{
foreach ($data as $name => $value) {
if ($overwrite || !$this->hasData($name)) {
$this->setAttr($name, $value);
}
}
return $this;
}
}