NewsController.php
3.8 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
142
143
144
145
<?php
namespace App\Http\Controllers\Bside\News;
use App\Enums\Common\Code;
use App\Helper\Common;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\News\NewsCategoryLogic;
use App\Http\Logic\Bside\News\NewsLogic;
use App\Http\Requests\Bside\News\NewsRequest;
use App\Models\News\News as NewsModel;
use Illuminate\Http\Request;
/**
* @name:新闻管理
*/
class NewsController extends BaseController
{
/**
* @name :获取新闻列表
* @return json
* @author :liyuhang
* @method
*/
public function lists(NewsModel $news,NewsCategoryLogic $newsCategoryLogic){
$this->map['project_id'] = $this->user['project_id'];
$lists = $news->lists($this->map,$this->page,$this->row,$this->order);
if(!empty($lists['list'])){
foreach ($lists['list'] as $k => $v){
$v = $newsCategoryLogic->get_category_name($v);
$lists['list'][$k] = $v;
}
}
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @name :添加新闻时获取分类列表
* @return void
* @author :liyuhang
* @method
*/
public function get_category_list(NewsLogic $newsLogic){
$list = $newsLogic->news_get_category_list();
$this->response('success',Code::SUCCESS,$list);
}
/**
* @name :获取详情
* @return void
* @author :liyuhang
* @method
*/
public function info(NewsLogic $newsLogic){
$this->request->validate([
'id'=>['required'],
],[
'id.required' => 'ID不能为空',
]);
$info = $newsLogic->news_info();
$this->response('success',Code::SUCCESS,$info);
}
/**
* @name :添加新闻
* @return json
* @author :liyuhang
* @method
*/
public function add(NewsRequest $newsRequest,NewsLogic $newsLogic){
$newsRequest->validated();
$newsLogic->news_add();
$this->response('success');
}
/**
* @name :编辑
* @return void
* @author :liyuhang
* @method
*/
public function edit(NewsRequest $newsRequest,NewsLogic $newsLogic){
$newsRequest->validate([
'id'=>['required'],
],[
'id.required' => 'ID不能为空',
]);
$newsLogic->news_edit();
$this->response('success');
}
/**
* @name :编辑新闻seo
* @return void
* @author :liyuhang
* @method
*/
public function edit_seo(NewsLogic $newsLogic){
$this->request->validate([
'id'=>['required'],
'seo_title'=>['required'],
'seo_description'=>['required'],
'seo_keywords'=>['required'],
],[
'id.required' => 'ID不能为空',
'seo_title.required' => 'seo_title不能为空',
'seo_description.required' => 'seo_description不能为空',
'seo_keywords.required' => 'seo_description不能为空',
]);
$newsLogic->edit_seo();
$this->response('success');
}
/**
* @name :编辑状态/与排序
* @return void
* @author :liyuhang
* @method
*/
public function status(NewsLogic $newsLogic){
$this->request->validate([
'id'=>['required'],
],[
'id.required' => 'ID不能为空',
]);
$newsLogic->news_status();
//TODO::写入日志
$this->response('success');
}
/**
* @name :删除新闻(逻辑删除)
* @return void
* @author :liyuhang
* @method
*/
public function del(NewsLogic $newsLogic){
$this->request->validate([
'id'=>['required'],
],[
'id.required' => 'ID不能为空',
]);
$newsLogic->news_del();
//TODO::清空相关资源/写入日志
$this->response('success');
}
}