feat: 新增导航相关接口

This commit is contained in:
2025-03-01 18:05:35 +08:00
parent d21a69d99d
commit b5dae966e6
10 changed files with 252 additions and 3 deletions

View File

@@ -0,0 +1,46 @@
<?php
declare (strict_types = 1);
namespace app\admin\model\v1;
use think\Model;
/**
* 导航数据模型
* @mixin \think\Model
*/
class SysNavigationItemModel extends Model
{
// 关联导航
public function navigation()
{
return $this->belongsTo(SysNavigationModel::class, 'nav_id', 'id');
}
// 名称搜索
public function searchNameAttr($query, $value, $data)
{
if (empty($value)) return;
$query->where('name', 'like', "%{$value}%");
}
// 新增时间搜索
public function searchCreatedAtAttr($query, $value, $data)
{
if (empty($value)) return;
if (is_array($value)) {
if (count($value) > 1) {
$query->whereBetweenTime('created_at', $value[0], $value[1]);
} else {
$query->whereTime('created_at', '>=', $value[0]);
}
}
}
// 导航查询
public function scopeNavId($query, $value)
{
if (empty($value)) return;
$query->where('nav_id', '=', $value);
}
}

View File

@@ -0,0 +1,15 @@
<?php
declare (strict_types = 1);
namespace app\admin\model\v1;
use app\common\model\SysNavigationLinkTypeBaseModel;
/**
* 导航链接类型模型
* @mixin \think\Model
*/
class SysNavigationLinkTypeModel extends SysNavigationLinkTypeBaseModel
{
//
}

View File

@@ -0,0 +1,15 @@
<?php
declare (strict_types = 1);
namespace app\admin\model\v1;
use app\common\model\SysNavigationBaseModel;
/**
* 导航模型
* @mixin \think\Model
*/
class SysNavigationModel extends SysNavigationBaseModel
{
//
}