new files

This commit is contained in:
panchengyong
2026-03-07 22:29:07 +08:00
parent cd7e80b502
commit 7acbf45ff7
12516 changed files with 1808447 additions and 194 deletions

View File

@@ -0,0 +1,86 @@
<?php
/**
* +----------------------------------------------------------------------
* | CRMEB [ CRMEB赋能开发者助力企业发展 ]
* +----------------------------------------------------------------------
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
* +----------------------------------------------------------------------
* | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
* +----------------------------------------------------------------------
* | Author: CRMEB Team <admin@crmeb.com>
* +----------------------------------------------------------------------
*/
namespace crmeb\topthink;
use Closure;
/**
* 远程一对多关联
* Class HasManyThrough
* @author 等风来
* @email 136327134@qq.com
* @date 2023/10/11
* @package crmeb\topthink
*/
class HasManyThrough extends \think\model\relation\HasManyThrough
{
/**
* @param array $where
* @param string $key
* @param array $subRelation
* @param Closure|null $closure
* @param array $cache
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author 等风来
* @email 136327134@qq.com
* @date 2023/10/11
*/
protected function eagerlyWhere(array $where, string $key, array $subRelation = [], Closure $closure = null, array $cache = []): array
{
// 预载入关联查询 支持嵌套预载入
$throughList = $this->through->where($where)->select();
$keys = $throughList->column($this->throughPk, $this->throughPk);
if ($closure) {
$this->baseQuery = true;
$closure($this->query);
}
$throughKey = $this->throughKey;
if ($this->baseQuery) {
$throughKey = $this->query->getTable() . '.' . $this->throughKey;
}
$withLimit = $this->query->getOptions('limit');
if ($withLimit) {
$this->query->removeOption('limit');
}
$list = $this->query
->where($throughKey, 'in', $keys)
->cache($cache[0] ?? false, $cache[1] ?? null, $cache[2] ?? null)
->select();
// 组装模型数据
$data = [];
$keys = $throughList->column($this->foreignKey, $this->throughPk);
foreach ($list as $set) {
$key = $keys[$set->{$this->throughKey}];
if ($withLimit && isset($data[$key]) && count($data[$key]) >= $withLimit) {
continue;
}
$data[$key][] = $set;
}
return $data;
}
}

View File

@@ -0,0 +1,32 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace crmeb\topthink;
use think\route\Url as UrlBuild;
class Route extends \think\Route
{
/**
* URL生成 支持路由反射
* @access public
* @param string $url 路由地址
* @param array $vars 参数 ['a'=>'val1', 'b'=>'val2']
* @return UrlBuild
*/
public function buildUrl(string $url = '', array $vars = []): UrlBuild
{
$str = substr($url, 0, 1);
if ($str != '/') $url = '/' . $url;
return parent::buildUrl($url, $vars);
}
}

View File

@@ -0,0 +1,54 @@
<?php
/**
* +----------------------------------------------------------------------
* | CRMEB [ CRMEB赋能开发者助力企业发展 ]
* +----------------------------------------------------------------------
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
* +----------------------------------------------------------------------
* | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
* +----------------------------------------------------------------------
* | Author: CRMEB Team <admin@crmeb.com>
* +----------------------------------------------------------------------
*/
namespace crmeb\topthink;
use think\event\LogWrite;
class TraceDebug extends \think\trace\TraceDebug
{
/**
* @param \think\Request $request
* @param \Closure $next
* @return mixed|void
* @author 等风来
* @email 136327134@qq.com
* @date 2023/10/9
*/
public function handle($request, \Closure $next)
{
$debug = $this->app->config->get('trace.enable');
// 注册日志监听
if ($debug) {
$this->log = [];
$this->app->event->listen(LogWrite::class, function ($event) {
if (empty($this->config['channel']) || $this->config['channel'] == $event->channel) {
$this->log = array_merge_recursive($this->log, $event->log);
}
});
}
$response = $next($request);
// Trace调试注入
if ($debug) {
$data = $response->getContent();
$this->traceDebug($response, $data);
$response->content($data);
}
return $response;
}
}