refactor: 修改导航项链接类型字段
This commit is contained in:
@@ -79,7 +79,7 @@ class BannerItem
|
|||||||
'type',
|
'type',
|
||||||
'image',
|
'image',
|
||||||
'video',
|
'video',
|
||||||
'link_to',
|
'link_to' => 'custom',
|
||||||
'link',
|
'link',
|
||||||
'sort',
|
'sort',
|
||||||
'status'
|
'status'
|
||||||
|
|||||||
@@ -12,16 +12,6 @@ use app\admin\validate\v1\NavigationItemValidate;
|
|||||||
*/
|
*/
|
||||||
class NavigationItem
|
class NavigationItem
|
||||||
{
|
{
|
||||||
// 导航链接类型
|
|
||||||
public function linkType()
|
|
||||||
{
|
|
||||||
$types = SysNavigationLinkTypeModel::withoutField(['sort'])
|
|
||||||
->order(['sort' => 'asc', 'id' => 'asc'])
|
|
||||||
->select();
|
|
||||||
|
|
||||||
return success('获取成功', $types);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 导航列表树
|
// 导航列表树
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
@@ -70,7 +60,7 @@ class NavigationItem
|
|||||||
'sort',
|
'sort',
|
||||||
'status',
|
'status',
|
||||||
'blank',
|
'blank',
|
||||||
'link_type',
|
'link_to',
|
||||||
'link'
|
'link'
|
||||||
])
|
])
|
||||||
->bypk($id)
|
->bypk($id)
|
||||||
@@ -90,7 +80,7 @@ class NavigationItem
|
|||||||
'nav_id',
|
'nav_id',
|
||||||
'name',
|
'name',
|
||||||
'icon',
|
'icon',
|
||||||
'link_type',
|
'link_to' => 'custom',
|
||||||
'link',
|
'link',
|
||||||
'sort',
|
'sort',
|
||||||
'blank' => 0,
|
'blank' => 0,
|
||||||
@@ -118,7 +108,7 @@ class NavigationItem
|
|||||||
'nav_id',
|
'nav_id',
|
||||||
'name',
|
'name',
|
||||||
'icon',
|
'icon',
|
||||||
'link_type',
|
'link_to',
|
||||||
'link',
|
'link',
|
||||||
'sort',
|
'sort',
|
||||||
'blank' => 0,
|
'blank' => 0,
|
||||||
|
|||||||
@@ -490,9 +490,6 @@ Route::group('v1', function () {
|
|||||||
Route::delete('delete/:id', 'Navigation/delete');
|
Route::delete('delete/:id', 'Navigation/delete');
|
||||||
|
|
||||||
Route::group('items', function() {
|
Route::group('items', function() {
|
||||||
// 导航数据类型
|
|
||||||
Route::get('link/type', 'NavigationItem/linkType');
|
|
||||||
|
|
||||||
// 导航分页
|
// 导航分页
|
||||||
Route::get('index', 'NavigationItem/index');
|
Route::get('index', 'NavigationItem/index');
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class NavigationItemValidate extends Validate
|
|||||||
'pid' => 'integer|different:id|checkPidNotBeChildren',
|
'pid' => 'integer|different:id|checkPidNotBeChildren',
|
||||||
'name' => 'require|max:64',
|
'name' => 'require|max:64',
|
||||||
'icon' => 'max:64',
|
'icon' => 'max:64',
|
||||||
'link_type' => 'require|integer',
|
'link_to' => 'require|max:64|in:article,article_category,product,product_category,custom',
|
||||||
'link' => 'max:255',
|
'link' => 'max:255',
|
||||||
'sort' => 'integer',
|
'sort' => 'integer',
|
||||||
'blank' => 'in:0,1',
|
'blank' => 'in:0,1',
|
||||||
@@ -45,8 +45,9 @@ class NavigationItemValidate extends Validate
|
|||||||
'name.require' => '导航名称不能为空',
|
'name.require' => '导航名称不能为空',
|
||||||
'name.max' => '导航名称最多不能超过64个字符',
|
'name.max' => '导航名称最多不能超过64个字符',
|
||||||
'icon.max' => '图标最多不能超过64个字符',
|
'icon.max' => '图标最多不能超过64个字符',
|
||||||
'link_type.require' => '链接类型不能为空',
|
'link_to.require' => '链接类型不能为空',
|
||||||
'link_type.integer' => '链接类型必须为整数',
|
'link_to.max' => '链接类型最多不能超过64个字符',
|
||||||
|
'link_to.in' => '链接类型必须是article,goods_category,goods,custom中之一',
|
||||||
'link.max' => '链接最多不能超过255个字符',
|
'link.max' => '链接最多不能超过255个字符',
|
||||||
'sort.integer' => '排序必须为整数',
|
'sort.integer' => '排序必须为整数',
|
||||||
'blank.in' => '是否新窗口打开只能是0或1',
|
'blank.in' => '是否新窗口打开只能是0或1',
|
||||||
@@ -83,12 +84,12 @@ class NavigationItemValidate extends Validate
|
|||||||
// 新增场景
|
// 新增场景
|
||||||
public function sceneAdd()
|
public function sceneAdd()
|
||||||
{
|
{
|
||||||
return $this->only(['nav_id', 'pid', 'name', 'icon', 'link_type', 'link', 'sort', 'blank', 'status'])->remove('pid', 'different|checkPidNotBeChildren');
|
return $this->only(['nav_id', 'pid', 'name', 'icon', 'link_to', 'link', 'sort', 'blank', 'status'])->remove('pid', 'different|checkPidNotBeChildren');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新场景
|
// 更新场景
|
||||||
public function sceneEdit()
|
public function sceneEdit()
|
||||||
{
|
{
|
||||||
return $this->only(['id', 'nav_id', 'pid', 'name', 'icon', 'link_type', 'link', 'sort', 'blank', 'status']);
|
return $this->only(['id', 'nav_id', 'pid', 'name', 'icon', 'link_to', 'link', 'sort', 'blank', 'status']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class SysBannerItemValidate extends Validate
|
|||||||
'type' => 'in:image,video',
|
'type' => 'in:image,video',
|
||||||
'image' => 'max:255',
|
'image' => 'max:255',
|
||||||
'video' => 'max:255',
|
'video' => 'max:255',
|
||||||
'link_to' => 'max:64|in:article,goods_category,goods,custom',
|
'link_to' => 'require|max:64|in:article,article_category,product,product_category,custom',
|
||||||
'link' => 'max:255',
|
'link' => 'max:255',
|
||||||
'sort' => 'integer',
|
'sort' => 'integer',
|
||||||
'status' => 'in:-1,1'
|
'status' => 'in:-1,1'
|
||||||
@@ -48,8 +48,9 @@ class SysBannerItemValidate extends Validate
|
|||||||
'type.in' => '显示类型必须是image或video',
|
'type.in' => '显示类型必须是image或video',
|
||||||
'image.max' => '图片地址最多不能超过255个字符',
|
'image.max' => '图片地址最多不能超过255个字符',
|
||||||
'video.max' => '视频地址最多不能超过255个字符',
|
'video.max' => '视频地址最多不能超过255个字符',
|
||||||
|
'link_to.require' => '连接类型不能为空',
|
||||||
'link_to.max' => '连接类型最多不能超过64个字符',
|
'link_to.max' => '连接类型最多不能超过64个字符',
|
||||||
'link_to.in' => '连接类型必须是article,goods_category,goods,custom中之一',
|
'link_to.in' => '连接类型必须是article,article_category,product,product_category,custom中之一',
|
||||||
'link.max' => '连接最多不能超过255个字符',
|
'link.max' => '连接最多不能超过255个字符',
|
||||||
'sort.integer' => '排序值必须是整数',
|
'sort.integer' => '排序值必须是整数',
|
||||||
'status.in' => '状态必须是-1或1'
|
'status.in' => '状态必须是-1或1'
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class SysNavigationItemBaseModel extends BaseModel
|
|||||||
'pid' => 'int',
|
'pid' => 'int',
|
||||||
'name' => 'string',
|
'name' => 'string',
|
||||||
'icon' => 'string',
|
'icon' => 'string',
|
||||||
'link_type' => 'int',
|
'link_to' => 'string',
|
||||||
'link' => 'string',
|
'link' => 'string',
|
||||||
'sort' => 'int',
|
'sort' => 'int',
|
||||||
'blank' => 'int',
|
'blank' => 'int',
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class CreateSysNavigationItem extends Migrator
|
|||||||
->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('icon', 'string', ['limit' => 64, 'null' => true, 'default' => null, 'comment' => '图标'])
|
->addColumn('icon', 'string', ['limit' => 64, 'null' => true, 'default' => null, 'comment' => '图标'])
|
||||||
->addColumn('link_to', 'string', ['limit' => 64, 'null' => false, 'comment' => '链接到(类型): article:文章, goods_category:商品分类, goods:商品, link:链接'])
|
->addColumn('link_to', 'string', ['limit' => 64, 'null' => false, 'comment' => '链接到(类型): article:文章, article_category:文章分类, product:产品, product_category:产品分类, custom:自定义链接'])
|
||||||
->addColumn('link', 'string', ['limit' => 255, 'null' => false, 'comment' => '链接'])
|
->addColumn('link', 'string', ['limit' => 255, 'null' => false, 'comment' => '链接'])
|
||||||
->addColumn('sort', 'integer', ['limit' => 11, 'null' => false, 'default' => 0, 'comment' => '排序'])
|
->addColumn('sort', 'integer', ['limit' => 11, 'null' => false, 'default' => 0, 'comment' => '排序'])
|
||||||
->addColumn('blank', 'boolean', ['limit' => 1, 'null' => false, 'default' => 0, 'comment' => '是否新窗口打开, 0否, 1是'])
|
->addColumn('blank', 'boolean', ['limit' => 1, 'null' => false, 'default' => 0, 'comment' => '是否新窗口打开, 0否, 1是'])
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class CreateSysBannerItem extends Migrator
|
|||||||
->addColumn('type', 'string', ['limit' => 16, 'null' => false, 'comment' => '类型: image为图片, video为视频'])
|
->addColumn('type', 'string', ['limit' => 16, 'null' => false, 'comment' => '类型: image为图片, video为视频'])
|
||||||
->addColumn('image', 'string', ['limit' => 255, 'null' => false, 'comment' => '图片'])
|
->addColumn('image', 'string', ['limit' => 255, 'null' => false, 'comment' => '图片'])
|
||||||
->addColumn('video', 'string', ['limit' => 255, 'null' => false, 'comment' => '视频'])
|
->addColumn('video', 'string', ['limit' => 255, 'null' => false, 'comment' => '视频'])
|
||||||
->addColumn('link_to', 'string', ['limit' => 64, 'null' => false, 'comment' => '链接到(类型): article:文章, goods_category:商品分类, goods:商品, custom:自定义链接'])
|
->addColumn('link_to', 'string', ['limit' => 64, 'null' => false, 'comment' => '链接到(类型): article:文章, article_category:文章分类, product:产品, product_category:产品分类, custom:自定义链接'])
|
||||||
->addColumn('link', 'string', ['limit' => 255, 'null' => false, 'comment' => '链接'])
|
->addColumn('link', 'string', ['limit' => 255, 'null' => false, 'comment' => '链接'])
|
||||||
->addColumn('sort', 'integer', ['limit' => 11, 'null' => false, 'default' => 0, 'comment' => '排序'])
|
->addColumn('sort', 'integer', ['limit' => 11, 'null' => false, 'default' => 0, 'comment' => '排序'])
|
||||||
->addColumn('status', 'boolean', ['limit' => 1, 'null' => false, 'default' => 1, 'comment' => '-1为禁用, 1为启用'])
|
->addColumn('status', 'boolean', ['limit' => 1, 'null' => false, 'default' => 1, 'comment' => '-1为禁用, 1为启用'])
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use think\migration\Migrator;
|
|
||||||
|
|
||||||
class SysNavigationLinkType extends Migrator
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Change Method.
|
|
||||||
*
|
|
||||||
* Write your reversible migrations using this method.
|
|
||||||
*
|
|
||||||
* More information on writing migrations is available here:
|
|
||||||
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
|
|
||||||
*
|
|
||||||
* The following commands can be used in this method and Phinx will
|
|
||||||
* automatically reverse them when rolling back:
|
|
||||||
*
|
|
||||||
* createTable
|
|
||||||
* renameTable
|
|
||||||
* addColumn
|
|
||||||
* renameColumn
|
|
||||||
* addIndex
|
|
||||||
* addForeignKey
|
|
||||||
*
|
|
||||||
* Remember to call "create()" or "update()" and NOT "save()" when working
|
|
||||||
* with the Table class.
|
|
||||||
*/
|
|
||||||
public function change()
|
|
||||||
{
|
|
||||||
$table = $this->table('sys_navigation_link_type', ['engine' => 'InnoDB', 'comment' => '系统导航链接类型']);
|
|
||||||
$table->addColumn('type_name', 'string', ['limit' => 64, 'null' => false, 'comment' => '类型名称'])
|
|
||||||
->addColumn('sort', 'integer', ['limit' => 11, 'null' => false, 'default' => 0, 'comment' => '排序'])
|
|
||||||
->create();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user