NavController.php
3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
namespace App\Http\Controllers\Bside\Nav;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Nav\NavLogic;
use App\Http\Requests\Bside\Nav\NavRequest;
use App\Models\Nav\BNav;
/**
* 导航栏目 b端编辑 c端显示
* @author:dc
* @time 2023/5/8 16:31
* Class NavController
* @package App\Http\Controllers\Bside
*/
class NavController extends BaseController
{
/**
* @remark :获取列表数据
* @name :index
* @author :lyh
* @method :post
* @time :2023/12/4 15:00
*/
public function index(BNav $nav){
$this->map['project_id'] = $this->user['project_id'];
$lists = $nav->list($this->map,$this->order = ['sort','id']);
$data = array();
foreach ($lists as $v){
$v = (array)$v;
if ($v['pid'] == 0) {
$v['sub'] = _get_child($v['id'], $lists);
$data[] = $v;
}
}
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :获取当前id下的所有子集
* @name :getSubList
* @author :lyh
* @method :post
* @time :2023/12/4 15:04
*/
public function getSubList(NavLogic $logic){
$data = $logic->getSubList();
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :保存数据
* @name :save
* @author :lyh
* @method :post
* @time :2023/8/21 11:32
*/
public function save(NavRequest $request,NavLogic $logic){
$request->validated();
$logic->navSave();
$this->response('success');
}
/**
* @remark :删除菜单
* @name :delete
* @author :lyh
* @method :post
* @time :2023/8/23 11:09
*/
public function delete(NavLogic $logic){
$this->request->validate([
'id'=>'required',
],[
'id.required' => '产品ID不能为空',
]);
$logic->navDelete();
$this->response('success');
}
/**
* @author:dc
* @time 2023/5/9 16:14
*/
public function urls(){
// todo::需要配合 c端来
$data = [
['url'=>'index', 'name'=>'首页'],
['url'=>'news', 'name'=>'新闻'],
['url'=>'products', 'name'=>'产品'],
['url'=>'search', 'name'=>'搜索页'],
['url'=>'blog', 'name'=>'博客']
];
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :排序
* @name :sort
* @author :lyh
* @method :post
* @time :2023/8/22 9:49
*/
public function sort(NavLogic $navLogic){
$this->request->validate([
'id'=>'required',
'sort'=>'required'
],[
'id.required' => '产品ID不能为空',
'sort.required'=>'排序字段不能为空'
]);
$navLogic->navSort();
$this->response('success');
}
/**
* 一键导入子菜单
* @author zbj
* @date 2023/11/21
*/
public function import(NavLogic $navLogic){
$this->request->validate([
'id'=>'required',
],[
'id.required' => 'ID不能为空',
]);
$navLogic->importNav();
$this->response('success');
}
}