Compare commits
2 Commits
effde58a53
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 9b039b7abe | |||
| 0429cf62c4 |
@@ -581,6 +581,13 @@ class Crud extends Backend
|
|||||||
|
|
||||||
private function parseModelMethods($field, &$modelData): void
|
private function parseModelMethods($field, &$modelData): void
|
||||||
{
|
{
|
||||||
|
// MySQL bigint/int 时间戳字段:显式声明为 integer,避免 ThinkORM 自动时间戳写入 'now' 字符串
|
||||||
|
if (in_array($field['name'] ?? '', ['create_time', 'update_time', 'createtime', 'updatetime'], true)
|
||||||
|
&& in_array($field['type'] ?? '', ['int', 'bigint'], true)
|
||||||
|
) {
|
||||||
|
$modelData['fieldType'][$field['name']] = 'integer';
|
||||||
|
}
|
||||||
|
|
||||||
if (($field['designType'] ?? '') == 'array') {
|
if (($field['designType'] ?? '') == 'array') {
|
||||||
$modelData['fieldType'][$field['name']] = 'json';
|
$modelData['fieldType'][$field['name']] = 'json';
|
||||||
} elseif (!in_array($field['name'], ['create_time', 'update_time', 'updatetime', 'createtime'])
|
} elseif (!in_array($field['name'], ['create_time', 'update_time', 'updatetime', 'createtime'])
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
list($where, $alias, $limit, $order) = $this->queryBuilder();
|
list($where, $alias, $limit, $order) = $this->queryBuilder();
|
||||||
$res = $this->model
|
$res = $this->model
|
||||||
->withJoin($this->withJoinTable, $this->withJoinType)
|
->withJoin($this->withJoinTable, $this->withJoinType)
|
||||||
|
->with($this->withJoinTable)
|
||||||
{%relationVisibleFields%}
|
{%relationVisibleFields%}
|
||||||
->alias($alias)
|
->alias($alias)
|
||||||
->where($where)
|
->where($where)
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ trait Backend
|
|||||||
$res = $this->model
|
$res = $this->model
|
||||||
->field($this->indexField)
|
->field($this->indexField)
|
||||||
->withJoin($this->withJoinTable, $this->withJoinType)
|
->withJoin($this->withJoinTable, $this->withJoinType)
|
||||||
|
->with($this->withJoinTable)
|
||||||
->alias($alias)
|
->alias($alias)
|
||||||
->where($where)
|
->where($where)
|
||||||
->order($order)
|
->order($order)
|
||||||
|
|||||||
@@ -204,7 +204,24 @@ if (!function_exists('get_controller_path')) {
|
|||||||
if (count($parts) < 2) {
|
if (count($parts) < 2) {
|
||||||
return $parts[0] ?? null;
|
return $parts[0] ?? null;
|
||||||
}
|
}
|
||||||
return implode('/', array_slice($parts, 1, -1)) ?: $parts[1];
|
$segments = array_slice($parts, 1, -1);
|
||||||
|
if ($segments === []) {
|
||||||
|
return $parts[1] ?? null;
|
||||||
|
}
|
||||||
|
// ThinkPHP 风格段 game.Config -> game/config,与 $request->controller 解析结果一致(否则权限节点对不上)
|
||||||
|
$normalized = [];
|
||||||
|
foreach ($segments as $seg) {
|
||||||
|
if (str_contains($seg, '.')) {
|
||||||
|
$dotPos = strpos($seg, '.');
|
||||||
|
$mod = substr($seg, 0, $dotPos);
|
||||||
|
$ctrl = substr($seg, $dotPos + 1);
|
||||||
|
$normalized[] = strtolower($mod);
|
||||||
|
$normalized[] = strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $ctrl));
|
||||||
|
} else {
|
||||||
|
$normalized[] = strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $seg));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return implode('/', $normalized);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user