refactor: banner|navigation
All checks were successful
Gitea Actions Official-website / deploy-dev (push) Successful in 4s
All checks were successful
Gitea Actions Official-website / deploy-dev (push) Successful in 4s
This commit is contained in:
@@ -67,6 +67,8 @@ class NavigationItem
|
||||
'id',
|
||||
'pid',
|
||||
'name',
|
||||
'desc',
|
||||
'image',
|
||||
'nav_id',
|
||||
'sort',
|
||||
'status',
|
||||
@@ -93,7 +95,9 @@ class NavigationItem
|
||||
'pid',
|
||||
'nav_id',
|
||||
'name',
|
||||
'desc',
|
||||
'icon',
|
||||
'image',
|
||||
'link_to' => 'custom',
|
||||
'link',
|
||||
'sort',
|
||||
@@ -121,7 +125,9 @@ class NavigationItem
|
||||
'pid',
|
||||
'nav_id',
|
||||
'name',
|
||||
'desc',
|
||||
'icon',
|
||||
'image',
|
||||
'link_to',
|
||||
'link',
|
||||
'sort',
|
||||
@@ -172,7 +178,7 @@ class NavigationItem
|
||||
if (empty($nav)) {
|
||||
return error('请确认要操作对象是否存在');
|
||||
}
|
||||
|
||||
|
||||
if (!$nav->delete()) {
|
||||
return error('操作失败');
|
||||
}
|
||||
|
||||
@@ -20,7 +20,9 @@ class NavigationItemValidate extends Validate
|
||||
'nav_id' => 'require|integer',
|
||||
'pid' => 'integer|different:id|checkPidNotBeChildren',
|
||||
'name' => 'require|max:64',
|
||||
'desc' => 'max:255',
|
||||
'icon' => 'max:64',
|
||||
'image' => 'max:255',
|
||||
'link_to' => 'require|max:64|in:article,article_category,product,product_category,system_page,custom',
|
||||
'link' => 'max:255',
|
||||
'sort' => 'integer',
|
||||
@@ -44,7 +46,9 @@ class NavigationItemValidate extends Validate
|
||||
'pid.checkPidNotBeChildren' => '父级ID不能为自身的子导航',
|
||||
'name.require' => '导航名称不能为空',
|
||||
'name.max' => '导航名称最多不能超过64个字符',
|
||||
'desc.max' => '导航名称最多不能超过:rule个字符',
|
||||
'icon.max' => '图标最多不能超过64个字符',
|
||||
'image.max' => '图标最多不能超过:rule个字符',
|
||||
'link_to.require' => '链接类型不能为空',
|
||||
'link_to.max' => '链接类型最多不能超过64个字符',
|
||||
'link_to.in' => '链接类型必须是article,article_category,product_category,product,system_page,custom中之一',
|
||||
@@ -67,7 +71,7 @@ class NavigationItemValidate extends Validate
|
||||
if (env('DB_VERSION', '5') == '8') {
|
||||
$children = Db::query(
|
||||
preg_replace(
|
||||
'/\s+/u',
|
||||
'/\s+/u',
|
||||
' ',
|
||||
"WITH RECURSIVE tree_by AS (
|
||||
SELECT a.id, a.pid FROM $table_name a WHERE a.id = {$data['id']}
|
||||
@@ -80,13 +84,13 @@ class NavigationItemValidate extends Validate
|
||||
} else {
|
||||
$children = \think\facade\Db::query("
|
||||
SELECT t2.id
|
||||
FROM (
|
||||
SELECT
|
||||
FROM (
|
||||
SELECT
|
||||
@r AS _id, (SELECT @r := GROUP_CONCAT(id) FROM $table_name WHERE FIND_IN_SET(pid, _id)) AS parent_id
|
||||
FROM
|
||||
(SELECT @r := {$data['id']}) vars, $table_name h
|
||||
WHERE @r <> 0) t1
|
||||
JOIN $table_name t2
|
||||
FROM
|
||||
(SELECT @r := {$data['id']}) vars, $table_name h
|
||||
WHERE @r <> 0) t1
|
||||
JOIN $table_name t2
|
||||
ON FIND_IN_SET(t2.pid, t1._id)
|
||||
ORDER BY t2.id;
|
||||
");
|
||||
|
||||
@@ -21,7 +21,9 @@ class SysNavigationItemBaseModel extends BaseModel
|
||||
'nav_id' => 'int',
|
||||
'pid' => 'int',
|
||||
'name' => 'string',
|
||||
'desc' => 'string',
|
||||
'icon' => 'string',
|
||||
'image' => 'string',
|
||||
'link_to' => 'string',
|
||||
'link' => 'string',
|
||||
'sort' => 'int',
|
||||
|
||||
Reference in New Issue
Block a user