|
@@ -54,12 +54,8 @@ class NewsLogic extends BaseLogic |
|
@@ -54,12 +54,8 @@ class NewsLogic extends BaseLogic |
|
54
|
* @method
|
54
|
* @method
|
|
55
|
*/
|
55
|
*/
|
|
56
|
public function news_add(){
|
56
|
public function news_add(){
|
|
57
|
- $this->param['create_id'] = $this->user['id'];
|
|
|
|
58
|
- $this->param['operator_id'] = $this->user['id'];
|
|
|
|
59
|
- $this->param['project_id'] = $this->user['project_id'];
|
|
|
|
60
|
- $this->param['created_at'] = date('Y-m-d H:i:s',time());
|
|
|
|
61
|
- $this->param['updated_at'] = date('Y-m-d H:i:s',time());
|
|
|
|
62
|
- $this->param['category_id'] = ','.trim($this->param['category_id'],',').',';
|
57
|
+ //拼接参数
|
|
|
|
58
|
+ $this->param = $this->paramProcessing($this->param);
|
|
63
|
DB::beginTransaction();
|
59
|
DB::beginTransaction();
|
|
64
|
try {
|
60
|
try {
|
|
65
|
if(isset($this->param['image'])){
|
61
|
if(isset($this->param['image'])){
|
|
@@ -83,16 +79,8 @@ class NewsLogic extends BaseLogic |
|
@@ -83,16 +79,8 @@ class NewsLogic extends BaseLogic |
|
83
|
* @method
|
79
|
* @method
|
|
84
|
*/
|
80
|
*/
|
|
85
|
public function news_edit(){
|
81
|
public function news_edit(){
|
|
86
|
- $condition = [
|
|
|
|
87
|
- 'id'=>['!=',$this->param['id']],
|
|
|
|
88
|
- 'name'=>$this->param['name']
|
|
|
|
89
|
- ];
|
|
|
|
90
|
- $info = $this->model->read($condition);
|
|
|
|
91
|
- if($info !== false){
|
|
|
|
92
|
- $this->fail('当前名称已存在');
|
|
|
|
93
|
- }
|
|
|
|
94
|
- $this->param['operator_id'] = $this->user['id'];
|
|
|
|
95
|
- $this->param['category_id'] = ','.trim($this->param['category_id'],',').',';
|
82
|
+ //拼接参数
|
|
|
|
83
|
+ $this->param = $this->paramProcessing($this->param);
|
|
96
|
DB::beginTransaction();
|
84
|
DB::beginTransaction();
|
|
97
|
try {
|
85
|
try {
|
|
98
|
//上传图片
|
86
|
//上传图片
|
|
@@ -177,7 +165,6 @@ class NewsLogic extends BaseLogic |
|
@@ -177,7 +165,6 @@ class NewsLogic extends BaseLogic |
|
177
|
foreach ($ids as $id){
|
165
|
foreach ($ids as $id){
|
|
178
|
RouteMap::delRoute(RouteMap::SOURCE_NEWS, $id, $this->user['project_id']);
|
166
|
RouteMap::delRoute(RouteMap::SOURCE_NEWS, $id, $this->user['project_id']);
|
|
179
|
}
|
167
|
}
|
|
180
|
-
|
|
|
|
181
|
DB::commit();
|
168
|
DB::commit();
|
|
182
|
}catch (Exception $e){
|
169
|
}catch (Exception $e){
|
|
183
|
DB::rollBack();
|
170
|
DB::rollBack();
|
|
@@ -186,4 +173,24 @@ class NewsLogic extends BaseLogic |
|
@@ -186,4 +173,24 @@ class NewsLogic extends BaseLogic |
|
186
|
return $this->success();
|
173
|
return $this->success();
|
|
187
|
}
|
174
|
}
|
|
188
|
|
175
|
|
|
|
|
176
|
+ /**
|
|
|
|
177
|
+ * @name :(参数处理)paramProcessing
|
|
|
|
178
|
+ * @author :lyh
|
|
|
|
179
|
+ * @method :post
|
|
|
|
180
|
+ * @time :2023/6/13 11:30
|
|
|
|
181
|
+ */
|
|
|
|
182
|
+ public function paramProcessing($param){
|
|
|
|
183
|
+ if(isset($this->param['id'])){
|
|
|
|
184
|
+ $param['operator_id'] = $this->user['id'];
|
|
|
|
185
|
+ $param['category_id'] = ','.trim($this->param['category_id'],',').',';
|
|
|
|
186
|
+ }else{
|
|
|
|
187
|
+ $this->param['create_id'] = $this->user['id'];
|
|
|
|
188
|
+ $this->param['operator_id'] = $this->user['id'];
|
|
|
|
189
|
+ $this->param['project_id'] = $this->user['project_id'];
|
|
|
|
190
|
+ $this->param['created_at'] = date('Y-m-d H:i:s',time());
|
|
|
|
191
|
+ $this->param['updated_at'] = date('Y-m-d H:i:s',time());
|
|
|
|
192
|
+ $this->param['category_id'] = ','.$this->param['category_id'].',';
|
|
|
|
193
|
+ }
|
|
|
|
194
|
+ return $this->success($param);
|
|
|
|
195
|
+ }
|
|
189
|
} |
196
|
} |