mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-01 15:32:48 +08:00
fix: 处理联表查询排序没有处理表名的问题
This commit is contained in:
@@ -137,10 +137,28 @@ class AdminControllerBase extends BaseController
|
||||
public function initSort()
|
||||
{
|
||||
$sort = $this->request->param('sort');
|
||||
|
||||
if (!empty($sort)) {
|
||||
$this->sort = $sort;
|
||||
}
|
||||
if(is_array($sort)){
|
||||
// 只有是数组的时候,才是列表传输过来的,一般的表单中不是数组,而是字段
|
||||
// 把排序中的小驼峰表名改为蛇形
|
||||
$new_sort = [];
|
||||
foreach ($this->sort as $k => $v) {
|
||||
$table_name_array = explode('.', $k);
|
||||
if(count($table_name_array) == 2) {
|
||||
$table_name = $table_name_array[0];
|
||||
$field_name = $table_name_array[1];
|
||||
|
||||
$table_name = \think\helper\Str::snake($table_name);
|
||||
|
||||
$new_sort[$table_name. '.'. $field_name] = $v;
|
||||
}else{
|
||||
$new_sort[$k] = $v;
|
||||
}
|
||||
}
|
||||
$this->sort = $new_sort;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user