|
@@ -28,16 +28,17 @@ class NewsLogic extends BaseLogic |
|
@@ -28,16 +28,17 @@ class NewsLogic extends BaseLogic |
|
28
|
* @author :liyuhang
|
28
|
* @author :liyuhang
|
|
29
|
* @method
|
29
|
* @method
|
|
30
|
*/
|
30
|
*/
|
|
31
|
- public function news_get_category_list(){
|
31
|
+ public function news_get_category_list()
|
|
|
|
32
|
+ {
|
|
32
|
$this->map['status'] = 0;
|
33
|
$this->map['status'] = 0;
|
|
33
|
$this->map['project_id'] = $this->user['project_id'];
|
34
|
$this->map['project_id'] = $this->user['project_id'];
|
|
34
|
$newsCategoryModel = new NewsCategoryModel();
|
35
|
$newsCategoryModel = new NewsCategoryModel();
|
|
35
|
- $cate_list = $newsCategoryModel->list($this->map,'sort');
|
|
|
|
36
|
- if($cate_list === false){
|
|
|
|
37
|
- $this->fail('error',Code::USER_ERROR);
|
36
|
+ $cate_list = $newsCategoryModel->list($this->map, 'sort');
|
|
|
|
37
|
+ if ($cate_list === false) {
|
|
|
|
38
|
+ $this->fail('error', Code::USER_ERROR);
|
|
38
|
}
|
39
|
}
|
|
39
|
$list = [];
|
40
|
$list = [];
|
|
40
|
- foreach ($cate_list as $v){
|
41
|
+ foreach ($cate_list as $v) {
|
|
41
|
$v = (array)$v;
|
42
|
$v = (array)$v;
|
|
42
|
if ($v['pid'] == 0) {
|
43
|
if ($v['pid'] == 0) {
|
|
43
|
$v['sub'] = _get_child($v['id'], $cate_list);
|
44
|
$v['sub'] = _get_child($v['id'], $cate_list);
|
|
@@ -54,28 +55,29 @@ class NewsLogic extends BaseLogic |
|
@@ -54,28 +55,29 @@ class NewsLogic extends BaseLogic |
|
54
|
* @method :post
|
55
|
* @method :post
|
|
55
|
* @time :2023/9/7 11:02
|
56
|
* @time :2023/9/7 11:02
|
|
56
|
*/
|
57
|
*/
|
|
57
|
- public function newsSave(){
|
58
|
+ public function newsSave()
|
|
|
|
59
|
+ {
|
|
58
|
//拼接参数
|
60
|
//拼接参数
|
|
59
|
DB::beginTransaction();
|
61
|
DB::beginTransaction();
|
|
60
|
try {
|
62
|
try {
|
|
61
|
$this->param = $this->paramProcessing($this->param);
|
63
|
$this->param = $this->paramProcessing($this->param);
|
|
62
|
- if(isset($this->param['id']) && !empty($this->param['id'])){
|
64
|
+ if (isset($this->param['id']) && !empty($this->param['id'])) {
|
|
63
|
//是否更新路由
|
65
|
//是否更新路由
|
|
64
|
- $id = $this->editNewsRoute($this->param['id'],$this->param['url']);
|
|
|
|
65
|
- $this->edit($this->param,['id'=>$this->param['id']]);
|
|
|
|
66
|
- }else{
|
66
|
+ $id = $this->editNewsRoute($this->param['id'], $this->param['url']);
|
|
|
|
67
|
+ $this->edit($this->param, ['id' => $this->param['id']]);
|
|
|
|
68
|
+ } else {
|
|
67
|
$id = $this->model->addReturnId($this->param);
|
69
|
$id = $this->model->addReturnId($this->param);
|
|
68
|
}
|
70
|
}
|
|
69
|
//更新路由
|
71
|
//更新路由
|
|
70
|
$route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $id, $this->user['project_id']);
|
72
|
$route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_NEWS, $id, $this->user['project_id']);
|
|
71
|
- $this->edit(['url'=>$route],['id'=>$id]);
|
73
|
+ $this->edit(['url' => $route], ['id' => $id]);
|
|
72
|
DB::commit();
|
74
|
DB::commit();
|
|
73
|
- }catch (\Exception $e){
|
75
|
+ } catch (\Exception $e) {
|
|
74
|
DB::rollBack();
|
76
|
DB::rollBack();
|
|
75
|
$this->fail('添加失败');
|
77
|
$this->fail('添加失败');
|
|
76
|
}
|
78
|
}
|
|
77
|
//通知更新
|
79
|
//通知更新
|
|
78
|
- $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_NEWS, 'route'=>$route]);
|
80
|
+ $this->updateNotify(['project_id' => $this->user['project_id'], 'type' => RouteMap::SOURCE_NEWS, 'route' => $route]);
|
|
79
|
return $this->success();
|
81
|
return $this->success();
|
|
80
|
}
|
82
|
}
|
|
81
|
|
83
|
|
|
@@ -86,13 +88,14 @@ class NewsLogic extends BaseLogic |
|
@@ -86,13 +88,14 @@ class NewsLogic extends BaseLogic |
|
86
|
* @method :post
|
88
|
* @method :post
|
|
87
|
* @time :2023/9/7 11:05
|
89
|
* @time :2023/9/7 11:05
|
|
88
|
*/
|
90
|
*/
|
|
89
|
- public function editNewsRoute($id,$route){
|
91
|
+ public function editNewsRoute($id, $route)
|
|
|
|
92
|
+ {
|
|
90
|
//生成一条删除路由记录
|
93
|
//生成一条删除路由记录
|
|
91
|
- $info = $this->model->read(['id'=>$id],['id','url']);
|
|
|
|
92
|
- if($info['url'] != $route){
|
94
|
+ $info = $this->model->read(['id' => $id], ['id', 'url']);
|
|
|
|
95
|
+ if ($info['url'] != $route) {
|
|
93
|
$data = [
|
96
|
$data = [
|
|
94
|
- 'source'=>RouteMap::SOURCE_NEWS,
|
|
|
|
95
|
- 'route'=>$info['url'],
|
97
|
+ 'source' => RouteMap::SOURCE_NEWS,
|
|
|
|
98
|
+ 'route' => $info['url'],
|
|
96
|
];
|
99
|
];
|
|
97
|
$this->setRouteDeleteSave($data);
|
100
|
$this->setRouteDeleteSave($data);
|
|
98
|
}
|
101
|
}
|
|
@@ -106,10 +109,11 @@ class NewsLogic extends BaseLogic |
|
@@ -106,10 +109,11 @@ class NewsLogic extends BaseLogic |
|
106
|
* @author :liyuhang
|
109
|
* @author :liyuhang
|
|
107
|
* @method
|
110
|
* @method
|
|
108
|
*/
|
111
|
*/
|
|
109
|
- public function edit_seo(){
|
112
|
+ public function edit_seo()
|
|
|
|
113
|
+ {
|
|
110
|
$this->param['operator_id'] = $this->user['id'];
|
114
|
$this->param['operator_id'] = $this->user['id'];
|
|
111
|
- $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
|
|
|
|
112
|
- if($rs === false){
|
115
|
+ $rs = $this->model->edit($this->param, ['id' => $this->param['id']]);
|
|
|
|
116
|
+ if ($rs === false) {
|
|
113
|
$this->fail('error');
|
117
|
$this->fail('error');
|
|
114
|
}
|
118
|
}
|
|
115
|
return $this->success();
|
119
|
return $this->success();
|
|
@@ -122,10 +126,11 @@ class NewsLogic extends BaseLogic |
|
@@ -122,10 +126,11 @@ class NewsLogic extends BaseLogic |
|
122
|
* @author :liyuhang
|
126
|
* @author :liyuhang
|
|
123
|
* @method
|
127
|
* @method
|
|
124
|
*/
|
128
|
*/
|
|
125
|
- public function news_status(){
|
129
|
+ public function news_status()
|
|
|
|
130
|
+ {
|
|
126
|
$this->param['operator_id'] = $this->user['id'];
|
131
|
$this->param['operator_id'] = $this->user['id'];
|
|
127
|
- $rs = $this->model->edit($this->param,['id'=>['in',$this->param['id']]]);
|
|
|
|
128
|
- if($rs === false){
|
132
|
+ $rs = $this->model->edit($this->param, ['id' => ['in', $this->param['id']]]);
|
|
|
|
133
|
+ if ($rs === false) {
|
|
129
|
$this->fail('error');
|
134
|
$this->fail('error');
|
|
130
|
}
|
135
|
}
|
|
131
|
return $this->success();
|
136
|
return $this->success();
|
|
@@ -138,7 +143,8 @@ class NewsLogic extends BaseLogic |
|
@@ -138,7 +143,8 @@ class NewsLogic extends BaseLogic |
|
138
|
* @author :liyuhang
|
143
|
* @author :liyuhang
|
|
139
|
* @method
|
144
|
* @method
|
|
140
|
*/
|
145
|
*/
|
|
141
|
- public function newsInfo(){
|
146
|
+ public function newsInfo()
|
|
|
|
147
|
+ {
|
|
142
|
$info = $this->model->read($this->param);
|
148
|
$info = $this->model->read($this->param);
|
|
143
|
$info['image_link'] = getImageUrl($info['image']);
|
149
|
$info['image_link'] = getImageUrl($info['image']);
|
|
144
|
$newsCategoryLogic = new NewsCategoryLogic();
|
150
|
$newsCategoryLogic = new NewsCategoryLogic();
|
|
@@ -152,15 +158,16 @@ class NewsLogic extends BaseLogic |
|
@@ -152,15 +158,16 @@ class NewsLogic extends BaseLogic |
|
152
|
* @author :liyuhang
|
158
|
* @author :liyuhang
|
|
153
|
* @method
|
159
|
* @method
|
|
154
|
*/
|
160
|
*/
|
|
155
|
- public function newsDel(){
|
161
|
+ public function newsDel()
|
|
|
|
162
|
+ {
|
|
156
|
DB::beginTransaction();
|
163
|
DB::beginTransaction();
|
|
157
|
try {
|
164
|
try {
|
|
158
|
- foreach ($this->param['id'] as $id){
|
165
|
+ foreach ($this->param['id'] as $id) {
|
|
159
|
$this->delRoute($id);
|
166
|
$this->delRoute($id);
|
|
160
|
- $this->model->del(['id'=>$id]);
|
167
|
+ $this->model->del(['id' => $id]);
|
|
161
|
}
|
168
|
}
|
|
162
|
DB::commit();
|
169
|
DB::commit();
|
|
163
|
- }catch (Exception $e){
|
170
|
+ } catch (Exception $e) {
|
|
164
|
DB::rollBack();
|
171
|
DB::rollBack();
|
|
165
|
$this->fail('error');
|
172
|
$this->fail('error');
|
|
166
|
}
|
173
|
}
|
|
@@ -173,18 +180,19 @@ class NewsLogic extends BaseLogic |
|
@@ -173,18 +180,19 @@ class NewsLogic extends BaseLogic |
|
173
|
* @method :post
|
180
|
* @method :post
|
|
174
|
* @time :2023/6/13 11:30
|
181
|
* @time :2023/6/13 11:30
|
|
175
|
*/
|
182
|
*/
|
|
176
|
- public function paramProcessing($param){
|
|
|
|
177
|
- if(isset($this->param['id'])){
|
183
|
+ public function paramProcessing($param)
|
|
|
|
184
|
+ {
|
|
|
|
185
|
+ if (isset($this->param['id'])) {
|
|
178
|
$param['operator_id'] = $this->user['id'];
|
186
|
$param['operator_id'] = $this->user['id'];
|
|
179
|
- if(isset($param['category_id']) && !empty($param['category_id'])){
|
|
|
|
180
|
- $param['category_id'] = ','.trim($param['category_id'],',').',';
|
187
|
+ if (isset($param['category_id']) && !empty($param['category_id'])) {
|
|
|
|
188
|
+ $param['category_id'] = ',' . trim($param['category_id'], ',') . ',';
|
|
181
|
}
|
189
|
}
|
|
182
|
- }else{
|
190
|
+ } else {
|
|
183
|
$param['create_id'] = $this->user['id'];
|
191
|
$param['create_id'] = $this->user['id'];
|
|
184
|
$param['operator_id'] = $this->user['id'];
|
192
|
$param['operator_id'] = $this->user['id'];
|
|
185
|
$param['project_id'] = $this->user['project_id'];
|
193
|
$param['project_id'] = $this->user['project_id'];
|
|
186
|
- if(isset($param['category_id']) && !empty($param['category_id'])){
|
|
|
|
187
|
- $param['category_id'] = ','.$param['category_id'].',';
|
194
|
+ if (isset($param['category_id']) && !empty($param['category_id'])) {
|
|
|
|
195
|
+ $param['category_id'] = ',' . $param['category_id'] . ',';
|
|
188
|
}
|
196
|
}
|
|
189
|
}
|
197
|
}
|
|
190
|
return $this->success($param);
|
198
|
return $this->success($param);
|
|
@@ -197,14 +205,15 @@ class NewsLogic extends BaseLogic |
|
@@ -197,14 +205,15 @@ class NewsLogic extends BaseLogic |
|
197
|
* @method :post
|
205
|
* @method :post
|
|
198
|
* @time :2023/6/19 9:42
|
206
|
* @time :2023/6/19 9:42
|
|
199
|
*/
|
207
|
*/
|
|
200
|
- public function getStatusNumber(){
|
208
|
+ public function getStatusNumber()
|
|
|
|
209
|
+ {
|
|
201
|
//三种状态 0:草稿 1:发布 2:回收站
|
210
|
//三种状态 0:草稿 1:发布 2:回收站
|
|
202
|
- $data = ['dra'=>0,'pub'=>1,'del'=>2,'tal'=>3];
|
|
|
|
203
|
- foreach ($data as $k => $v){
|
|
|
|
204
|
- if($v == 3){
|
|
|
|
205
|
- $data[$k] = $this->model->where(['project_id'=>$this->user['project_id']])->count();
|
|
|
|
206
|
- }else{
|
|
|
|
207
|
- $data[$k] = $this->model->where(['status'=>$v,'project_id'=>$this->user['project_id']])->count();
|
211
|
+ $data = ['dra' => 0, 'pub' => 1, 'del' => 2, 'tal' => 3];
|
|
|
|
212
|
+ foreach ($data as $k => $v) {
|
|
|
|
213
|
+ if ($v == 3) {
|
|
|
|
214
|
+ $data[$k] = $this->model->where(['project_id' => $this->user['project_id']])->count();
|
|
|
|
215
|
+ } else {
|
|
|
|
216
|
+ $data[$k] = $this->model->where(['status' => $v, 'project_id' => $this->user['project_id']])->count();
|
|
208
|
}
|
217
|
}
|
|
209
|
}
|
218
|
}
|
|
210
|
return $this->success($data);
|
219
|
return $this->success($data);
|
|
@@ -217,9 +226,10 @@ class NewsLogic extends BaseLogic |
|
@@ -217,9 +226,10 @@ class NewsLogic extends BaseLogic |
|
217
|
* @method :post
|
226
|
* @method :post
|
|
218
|
* @time :2023/8/19 11:16
|
227
|
* @time :2023/8/19 11:16
|
|
219
|
*/
|
228
|
*/
|
|
220
|
- public function setSort(){
|
|
|
|
221
|
- $rs = $this->model->edit(['sort'=>$this->param['sort']],['id'=>$this->param['id']]);
|
|
|
|
222
|
- if($rs === false){
|
229
|
+ public function setSort()
|
|
|
|
230
|
+ {
|
|
|
|
231
|
+ $rs = $this->model->edit(['sort' => $this->param['sort']], ['id' => $this->param['id']]);
|
|
|
|
232
|
+ if ($rs === false) {
|
|
223
|
$this->fail('error');
|
233
|
$this->fail('error');
|
|
224
|
}
|
234
|
}
|
|
225
|
return $this->success();
|
235
|
return $this->success();
|
|
@@ -232,16 +242,28 @@ class NewsLogic extends BaseLogic |
|
@@ -232,16 +242,28 @@ class NewsLogic extends BaseLogic |
|
232
|
* @method :post
|
242
|
* @method :post
|
|
233
|
* @time :2023/9/7 10:50
|
243
|
* @time :2023/9/7 10:50
|
|
234
|
*/
|
244
|
*/
|
|
235
|
- public function delRoute($id){
|
245
|
+ public function delRoute($id)
|
|
|
|
246
|
+ {
|
|
236
|
//删除路由映射
|
247
|
//删除路由映射
|
|
237
|
RouteMap::delRoute(RouteMap::SOURCE_NEWS, $id, $this->user['project_id']);
|
248
|
RouteMap::delRoute(RouteMap::SOURCE_NEWS, $id, $this->user['project_id']);
|
|
238
|
//生成一条删除路由记录
|
249
|
//生成一条删除路由记录
|
|
239
|
- $info = $this->model->read(['id'=>$id],['id','url']);
|
250
|
+ $info = $this->model->read(['id' => $id], ['id', 'url']);
|
|
240
|
$data = [
|
251
|
$data = [
|
|
241
|
- 'source'=>RouteMap::SOURCE_NEWS,
|
|
|
|
242
|
- 'route'=>$info['url'],
|
252
|
+ 'source' => RouteMap::SOURCE_NEWS,
|
|
|
|
253
|
+ 'route' => $info['url'],
|
|
243
|
];
|
254
|
];
|
|
244
|
$this->setRouteDeleteSave($data);
|
255
|
$this->setRouteDeleteSave($data);
|
|
245
|
return $this->success();
|
256
|
return $this->success();
|
|
246
|
}
|
257
|
}
|
|
|
|
258
|
+
|
|
|
|
259
|
+ public function importNews($project_id, $user_id, $data)
|
|
|
|
260
|
+ {
|
|
|
|
261
|
+ $category_id = '';
|
|
|
|
262
|
+ if (!empty($data[2])) {
|
|
|
|
263
|
+ //处理分类
|
|
|
|
264
|
+ $newsCategoryLogic = new NewsCategoryLogic();
|
|
|
|
265
|
+ $category_id = $newsCategoryLogic->importNewsCategory($project_id, $user_id, $data[2]);
|
|
|
|
266
|
+ }
|
|
|
|
267
|
+ dd($category_id);
|
|
|
|
268
|
+ }
|
|
247
|
} |
269
|
} |