|
...
|
...
|
@@ -54,12 +54,8 @@ class NewsLogic extends BaseLogic |
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
public function news_add(){
|
|
|
|
$this->param['create_id'] = $this->user['id'];
|
|
|
|
$this->param['operator_id'] = $this->user['id'];
|
|
|
|
$this->param['project_id'] = $this->user['project_id'];
|
|
|
|
$this->param['created_at'] = date('Y-m-d H:i:s',time());
|
|
|
|
$this->param['updated_at'] = date('Y-m-d H:i:s',time());
|
|
|
|
$this->param['category_id'] = ','.trim($this->param['category_id'],',').',';
|
|
|
|
//拼接参数
|
|
|
|
$this->param = $this->paramProcessing($this->param);
|
|
|
|
DB::beginTransaction();
|
|
|
|
try {
|
|
|
|
if(isset($this->param['image'])){
|
|
...
|
...
|
@@ -83,16 +79,8 @@ class NewsLogic extends BaseLogic |
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
public function news_edit(){
|
|
|
|
$condition = [
|
|
|
|
'id'=>['!=',$this->param['id']],
|
|
|
|
'name'=>$this->param['name']
|
|
|
|
];
|
|
|
|
$info = $this->model->read($condition);
|
|
|
|
if($info !== false){
|
|
|
|
$this->fail('当前名称已存在');
|
|
|
|
}
|
|
|
|
$this->param['operator_id'] = $this->user['id'];
|
|
|
|
$this->param['category_id'] = ','.trim($this->param['category_id'],',').',';
|
|
|
|
//拼接参数
|
|
|
|
$this->param = $this->paramProcessing($this->param);
|
|
|
|
DB::beginTransaction();
|
|
|
|
try {
|
|
|
|
//上传图片
|
|
...
|
...
|
@@ -177,7 +165,6 @@ class NewsLogic extends BaseLogic |
|
|
|
foreach ($ids as $id){
|
|
|
|
RouteMap::delRoute(RouteMap::SOURCE_NEWS, $id, $this->user['project_id']);
|
|
|
|
}
|
|
|
|
|
|
|
|
DB::commit();
|
|
|
|
}catch (Exception $e){
|
|
|
|
DB::rollBack();
|
|
...
|
...
|
@@ -186,4 +173,24 @@ class NewsLogic extends BaseLogic |
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name :(参数处理)paramProcessing
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/6/13 11:30
|
|
|
|
*/
|
|
|
|
public function paramProcessing($param){
|
|
|
|
if(isset($this->param['id'])){
|
|
|
|
$param['operator_id'] = $this->user['id'];
|
|
|
|
$param['category_id'] = ','.trim($this->param['category_id'],',').',';
|
|
|
|
}else{
|
|
|
|
$this->param['create_id'] = $this->user['id'];
|
|
|
|
$this->param['operator_id'] = $this->user['id'];
|
|
|
|
$this->param['project_id'] = $this->user['project_id'];
|
|
|
|
$this->param['created_at'] = date('Y-m-d H:i:s',time());
|
|
|
|
$this->param['updated_at'] = date('Y-m-d H:i:s',time());
|
|
|
|
$this->param['category_id'] = ','.$this->param['category_id'].',';
|
|
|
|
}
|
|
|
|
return $this->success($param);
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|