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',
|
'id',
|
||||||
'pid',
|
'pid',
|
||||||
'name',
|
'name',
|
||||||
|
'desc',
|
||||||
|
'image',
|
||||||
'nav_id',
|
'nav_id',
|
||||||
'sort',
|
'sort',
|
||||||
'status',
|
'status',
|
||||||
@@ -93,7 +95,9 @@ class NavigationItem
|
|||||||
'pid',
|
'pid',
|
||||||
'nav_id',
|
'nav_id',
|
||||||
'name',
|
'name',
|
||||||
|
'desc',
|
||||||
'icon',
|
'icon',
|
||||||
|
'image',
|
||||||
'link_to' => 'custom',
|
'link_to' => 'custom',
|
||||||
'link',
|
'link',
|
||||||
'sort',
|
'sort',
|
||||||
@@ -121,7 +125,9 @@ class NavigationItem
|
|||||||
'pid',
|
'pid',
|
||||||
'nav_id',
|
'nav_id',
|
||||||
'name',
|
'name',
|
||||||
|
'desc',
|
||||||
'icon',
|
'icon',
|
||||||
|
'image',
|
||||||
'link_to',
|
'link_to',
|
||||||
'link',
|
'link',
|
||||||
'sort',
|
'sort',
|
||||||
@@ -172,7 +178,7 @@ class NavigationItem
|
|||||||
if (empty($nav)) {
|
if (empty($nav)) {
|
||||||
return error('请确认要操作对象是否存在');
|
return error('请确认要操作对象是否存在');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$nav->delete()) {
|
if (!$nav->delete()) {
|
||||||
return error('操作失败');
|
return error('操作失败');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,9 @@ class NavigationItemValidate extends Validate
|
|||||||
'nav_id' => 'require|integer',
|
'nav_id' => 'require|integer',
|
||||||
'pid' => 'integer|different:id|checkPidNotBeChildren',
|
'pid' => 'integer|different:id|checkPidNotBeChildren',
|
||||||
'name' => 'require|max:64',
|
'name' => 'require|max:64',
|
||||||
|
'desc' => 'max:255',
|
||||||
'icon' => 'max:64',
|
'icon' => 'max:64',
|
||||||
|
'image' => 'max:255',
|
||||||
'link_to' => 'require|max:64|in:article,article_category,product,product_category,system_page,custom',
|
'link_to' => 'require|max:64|in:article,article_category,product,product_category,system_page,custom',
|
||||||
'link' => 'max:255',
|
'link' => 'max:255',
|
||||||
'sort' => 'integer',
|
'sort' => 'integer',
|
||||||
@@ -44,7 +46,9 @@ class NavigationItemValidate extends Validate
|
|||||||
'pid.checkPidNotBeChildren' => '父级ID不能为自身的子导航',
|
'pid.checkPidNotBeChildren' => '父级ID不能为自身的子导航',
|
||||||
'name.require' => '导航名称不能为空',
|
'name.require' => '导航名称不能为空',
|
||||||
'name.max' => '导航名称最多不能超过64个字符',
|
'name.max' => '导航名称最多不能超过64个字符',
|
||||||
|
'desc.max' => '导航名称最多不能超过:rule个字符',
|
||||||
'icon.max' => '图标最多不能超过64个字符',
|
'icon.max' => '图标最多不能超过64个字符',
|
||||||
|
'image.max' => '图标最多不能超过:rule个字符',
|
||||||
'link_to.require' => '链接类型不能为空',
|
'link_to.require' => '链接类型不能为空',
|
||||||
'link_to.max' => '链接类型最多不能超过64个字符',
|
'link_to.max' => '链接类型最多不能超过64个字符',
|
||||||
'link_to.in' => '链接类型必须是article,article_category,product_category,product,system_page,custom中之一',
|
'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') {
|
if (env('DB_VERSION', '5') == '8') {
|
||||||
$children = Db::query(
|
$children = Db::query(
|
||||||
preg_replace(
|
preg_replace(
|
||||||
'/\s+/u',
|
'/\s+/u',
|
||||||
' ',
|
' ',
|
||||||
"WITH RECURSIVE tree_by AS (
|
"WITH RECURSIVE tree_by AS (
|
||||||
SELECT a.id, a.pid FROM $table_name a WHERE a.id = {$data['id']}
|
SELECT a.id, a.pid FROM $table_name a WHERE a.id = {$data['id']}
|
||||||
@@ -80,13 +84,13 @@ class NavigationItemValidate extends Validate
|
|||||||
} else {
|
} else {
|
||||||
$children = \think\facade\Db::query("
|
$children = \think\facade\Db::query("
|
||||||
SELECT t2.id
|
SELECT t2.id
|
||||||
FROM (
|
FROM (
|
||||||
SELECT
|
SELECT
|
||||||
@r AS _id, (SELECT @r := GROUP_CONCAT(id) FROM $table_name WHERE FIND_IN_SET(pid, _id)) AS parent_id
|
@r AS _id, (SELECT @r := GROUP_CONCAT(id) FROM $table_name WHERE FIND_IN_SET(pid, _id)) AS parent_id
|
||||||
FROM
|
FROM
|
||||||
(SELECT @r := {$data['id']}) vars, $table_name h
|
(SELECT @r := {$data['id']}) vars, $table_name h
|
||||||
WHERE @r <> 0) t1
|
WHERE @r <> 0) t1
|
||||||
JOIN $table_name t2
|
JOIN $table_name t2
|
||||||
ON FIND_IN_SET(t2.pid, t1._id)
|
ON FIND_IN_SET(t2.pid, t1._id)
|
||||||
ORDER BY t2.id;
|
ORDER BY t2.id;
|
||||||
");
|
");
|
||||||
|
|||||||
@@ -21,7 +21,9 @@ class SysNavigationItemBaseModel extends BaseModel
|
|||||||
'nav_id' => 'int',
|
'nav_id' => 'int',
|
||||||
'pid' => 'int',
|
'pid' => 'int',
|
||||||
'name' => 'string',
|
'name' => 'string',
|
||||||
|
'desc' => 'string',
|
||||||
'icon' => 'string',
|
'icon' => 'string',
|
||||||
|
'image' => 'string',
|
||||||
'link_to' => 'string',
|
'link_to' => 'string',
|
||||||
'link' => 'string',
|
'link' => 'string',
|
||||||
'sort' => 'int',
|
'sort' => 'int',
|
||||||
|
|||||||
@@ -31,7 +31,9 @@ class CreateSysNavigationItem extends Migrator
|
|||||||
$table->addColumn('nav_id', 'string', ['limit' => 64, 'null' => false, 'comment' => '所属导航ID'])
|
$table->addColumn('nav_id', 'string', ['limit' => 64, 'null' => false, 'comment' => '所属导航ID'])
|
||||||
->addColumn('pid', 'integer', ['null' => false, 'default' => 0, 'comment' => '父级ID'])
|
->addColumn('pid', 'integer', ['null' => false, 'default' => 0, 'comment' => '父级ID'])
|
||||||
->addColumn('name', 'string', ['limit' => 64, 'null' => false, 'comment' => '名称'])
|
->addColumn('name', 'string', ['limit' => 64, 'null' => false, 'comment' => '名称'])
|
||||||
|
->addColumn('desc', 'string', ['limit' => 255, 'null' => true, 'default' => null, 'comment' => '描述'])
|
||||||
->addColumn('icon', 'string', ['limit' => 64, 'null' => true, 'default' => null, 'comment' => '图标'])
|
->addColumn('icon', 'string', ['limit' => 64, 'null' => true, 'default' => null, 'comment' => '图标'])
|
||||||
|
->addColumn('image', 'string', ['limit' => 255, 'null' => true, 'default' => null, 'comment' => '图片'])
|
||||||
->addColumn('link_to', 'string', ['limit' => 64, 'null' => true, 'default' => null, 'comment' => '链接到(类型): article:文章, article_category:文章分类, product:产品, product_category:产品分类, custom:自定义链接'])
|
->addColumn('link_to', 'string', ['limit' => 64, 'null' => true, 'default' => null, 'comment' => '链接到(类型): article:文章, article_category:文章分类, product:产品, product_category:产品分类, custom:自定义链接'])
|
||||||
->addColumn('link', 'string', ['limit' => 255, 'null' => true, 'default' => null, 'comment' => '链接'])
|
->addColumn('link', 'string', ['limit' => 255, 'null' => true, 'default' => null, 'comment' => '链接'])
|
||||||
->addColumn('sort', 'integer', ['limit' => 11, 'null' => false, 'default' => 0, 'comment' => '排序'])
|
->addColumn('sort', 'integer', ['limit' => 11, 'null' => false, 'default' => 0, 'comment' => '排序'])
|
||||||
|
|||||||
Reference in New Issue
Block a user