|
@@ -4,18 +4,97 @@ namespace App\Http\Controllers\Bside\News; |
|
@@ -4,18 +4,97 @@ namespace App\Http\Controllers\Bside\News; |
|
4
|
|
4
|
|
|
5
|
use App\Enums\Common\Code;
|
5
|
use App\Enums\Common\Code;
|
|
6
|
use App\Http\Controllers\Bside\BaseController;
|
6
|
use App\Http\Controllers\Bside\BaseController;
|
|
|
|
7
|
+use App\Http\Requests\Bside\News\NewsCategoryRequest;
|
|
7
|
use App\Models\News\NewsCategory as NewsCategoryModel;
|
8
|
use App\Models\News\NewsCategory as NewsCategoryModel;
|
|
|
|
9
|
+use Illuminate\Http\Request;
|
|
8
|
|
10
|
|
|
9
|
class NewsCategoryController extends BaseController
|
11
|
class NewsCategoryController extends BaseController
|
|
10
|
{
|
12
|
{
|
|
11
|
/**
|
13
|
/**
|
|
12
|
- * @name :新闻列表
|
|
|
|
13
|
- * @return void
|
14
|
+ * @name :新闻分类列表
|
|
|
|
15
|
+ * @return json
|
|
14
|
* @author :liyuhang
|
16
|
* @author :liyuhang
|
|
15
|
* @method
|
17
|
* @method
|
|
16
|
*/
|
18
|
*/
|
|
17
|
- public function lists(NewsCategoryModel $newsCategoryModel){
|
|
|
|
18
|
- $lists = $newsCategoryModel->lists($this->map,$this->page,$this->row);
|
19
|
+ public function lists(NewsCategoryModel $newsCategory){
|
|
|
|
20
|
+ $lists = $newsCategory->lists($this->map,$this->page,$this->row);
|
|
19
|
$this->response('success',Code::SUCCESS,$lists);
|
21
|
$this->response('success',Code::SUCCESS,$lists);
|
|
20
|
}
|
22
|
}
|
|
|
|
23
|
+
|
|
|
|
24
|
+ /**
|
|
|
|
25
|
+ * @name :添加分类
|
|
|
|
26
|
+ * @return json
|
|
|
|
27
|
+ * @author :liyuhang
|
|
|
|
28
|
+ * @method
|
|
|
|
29
|
+ */
|
|
|
|
30
|
+ public function add(NewsCategoryRequest $request,NewsCategoryModel $newsCategory){
|
|
|
|
31
|
+ $request->validated();
|
|
|
|
32
|
+ $rs = $newsCategory->add($this->param);
|
|
|
|
33
|
+ if($rs === false){
|
|
|
|
34
|
+ $this->response('error',Code::USER_ERROR);
|
|
|
|
35
|
+ }
|
|
|
|
36
|
+ $this->response('success',Code::SUCCESS);
|
|
|
|
37
|
+ }
|
|
|
|
38
|
+
|
|
|
|
39
|
+ /**
|
|
|
|
40
|
+ * @name :编辑分类
|
|
|
|
41
|
+ * @return void
|
|
|
|
42
|
+ * @author :liyuhang
|
|
|
|
43
|
+ * @method
|
|
|
|
44
|
+ */
|
|
|
|
45
|
+ public function edit(NewsCategoryRequest $request,NewsCategoryModel $newsCategory){
|
|
|
|
46
|
+ $request->validate([
|
|
|
|
47
|
+ 'id'=>['required']
|
|
|
|
48
|
+ ],[
|
|
|
|
49
|
+ 'id.required' => 'ID不能为空'
|
|
|
|
50
|
+ ]);
|
|
|
|
51
|
+ $rs = $newsCategory->edit($this->param,['id'=>$this->param['id']]);
|
|
|
|
52
|
+ if($rs === false){
|
|
|
|
53
|
+ $this->response('error',Code::USER_ERROR);
|
|
|
|
54
|
+ }
|
|
|
|
55
|
+ $this->response('success',Code::SUCCESS);
|
|
|
|
56
|
+ }
|
|
|
|
57
|
+
|
|
|
|
58
|
+ /**
|
|
|
|
59
|
+ * @name :编辑状态
|
|
|
|
60
|
+ * @return void
|
|
|
|
61
|
+ * @author :liyuhang
|
|
|
|
62
|
+ * @method
|
|
|
|
63
|
+ */
|
|
|
|
64
|
+ public function status(Request $request,NewsCategoryModel $newsCategory){
|
|
|
|
65
|
+ $request->validate([
|
|
|
|
66
|
+ 'id'=>['required'],
|
|
|
|
67
|
+ 'status'=>['required'],
|
|
|
|
68
|
+ ],[
|
|
|
|
69
|
+ 'id.required' => 'ID不能为空',
|
|
|
|
70
|
+ 'status.required' => 'status不能为空'
|
|
|
|
71
|
+ ]);
|
|
|
|
72
|
+ $rs = $newsCategory->edit(['status'=>$this->param['status']],['id'=>$this->param['id']]);
|
|
|
|
73
|
+ if($rs === false){
|
|
|
|
74
|
+ $this->response('error',Code::USER_ERROR);
|
|
|
|
75
|
+ }
|
|
|
|
76
|
+ $this->response('success');
|
|
|
|
77
|
+ }
|
|
|
|
78
|
+
|
|
|
|
79
|
+ /**
|
|
|
|
80
|
+ * @name :删除分类
|
|
|
|
81
|
+ * @return void
|
|
|
|
82
|
+ * @author :liyuhang
|
|
|
|
83
|
+ * @method
|
|
|
|
84
|
+ */
|
|
|
|
85
|
+ public function del(Request $request,NewsCategoryModel $newsCategory){
|
|
|
|
86
|
+ $request->validate([
|
|
|
|
87
|
+ 'id'=>['required'],
|
|
|
|
88
|
+ ],[
|
|
|
|
89
|
+ 'id.required' => 'ID不能为空',
|
|
|
|
90
|
+ ]);
|
|
|
|
91
|
+ //查询是否有子分类
|
|
|
|
92
|
+ $id = $newsCategory->read(['pid'=>$this->param['id']],['id']);
|
|
|
|
93
|
+ var_dump($id);
|
|
|
|
94
|
+ die();
|
|
|
|
95
|
+ if($id === false){
|
|
|
|
96
|
+
|
|
|
|
97
|
+ }
|
|
|
|
98
|
+ //查看当前分内下是否有商品
|
|
|
|
99
|
+ }
|
|
21
|
} |
100
|
} |