|
...
|
...
|
@@ -32,10 +32,30 @@ class NewsCategoryLogic extends BaseLogic |
|
|
|
public function info_news_category(){
|
|
|
|
$info = $this->model->read($this->param);
|
|
|
|
$info['url'] = $this->user['domain'] . $info['alias'];
|
|
|
|
if(!empty($info['banner_image'])){
|
|
|
|
$info['banner_image'] = getImageUrl($info['banner_image'],$this->user['storage_type'] ?? 0,$this->user['project_location']);
|
|
|
|
}
|
|
|
|
return $this->success($info);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存处理字段
|
|
|
|
* @name :handleParam
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/9/13 9:15
|
|
|
|
*/
|
|
|
|
public function handleParam($param)
|
|
|
|
{
|
|
|
|
if(isset($param['banner_image']) && !empty($param['banner_image'])){
|
|
|
|
$param['banner_image'] = str_replace_url($param['banner_image']);
|
|
|
|
}
|
|
|
|
if(isset($param['image']) && !empty($param['image'])){
|
|
|
|
$param['image'] = str_replace_url($param['image']);
|
|
|
|
}
|
|
|
|
return $this->success($param);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @remark :保存数据
|
|
|
|
* @name :newsCategorySave
|
|
|
|
* @author :lyh
|
|
...
|
...
|
@@ -45,27 +65,27 @@ class NewsCategoryLogic extends BaseLogic |
|
|
|
public function newsCategorySave(){
|
|
|
|
//验证名称是否存在
|
|
|
|
$this->verifyParamName($this->param['name']);
|
|
|
|
DB::beginTransaction();
|
|
|
|
try {
|
|
|
|
if(isset($this->param['id']) && !empty($this->param['id'])){
|
|
|
|
$id = $this->param['id'];
|
|
|
|
$this->param['alias'] = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']);
|
|
|
|
$route = $this->param['alias'];
|
|
|
|
$this->param['operator_id'] = $this->user['id'];
|
|
|
|
$this->edit($this->param,['id'=>$id]);
|
|
|
|
}else{
|
|
|
|
if(!isset($this->param['alias']) || empty($this->param['alias'])){
|
|
|
|
$this->param['alias'] = Translate::tran($this->param['name'], 'en');
|
|
|
|
$this->param = $this->handleParam($this->param);
|
|
|
|
if(isset($this->param['id']) && !empty($this->param['id'])){
|
|
|
|
$id = $this->param['id'];
|
|
|
|
$this->param['alias'] = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']);
|
|
|
|
$route = $this->param['alias'];
|
|
|
|
if(empty($route)){
|
|
|
|
$this->fail('alias路由不能为空');
|
|
|
|
}
|
|
|
|
$this->param['operator_id'] = $this->user['id'];
|
|
|
|
$this->edit($this->param,['id'=>$id]);
|
|
|
|
}else{
|
|
|
|
if(!isset($this->param['alias']) || empty($this->param['alias'])){
|
|
|
|
$this->param['alias'] = Translate::tran($this->param['name'], 'en');
|
|
|
|
if(empty($this->param['alias'])){
|
|
|
|
$this->fail('路由翻译错误,请手动输入路由');
|
|
|
|
}
|
|
|
|
$this->param = $this->addParamProcessing($this->param);
|
|
|
|
$id = $this->model->addReturnId($this->param);
|
|
|
|
$route = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']);
|
|
|
|
$this->model->edit(['alias'=>$route],['id'=>$id]);
|
|
|
|
}
|
|
|
|
DB::commit();
|
|
|
|
}catch (\Exception $e){
|
|
|
|
DB::rollBack();
|
|
|
|
$this->fail('系统错误,请联系管理员');
|
|
|
|
$this->param = $this->addParamProcessing($this->param);
|
|
|
|
$id = $this->model->addReturnId($this->param);
|
|
|
|
$route = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']);
|
|
|
|
$this->model->edit(['alias'=>$route],['id'=>$id]);
|
|
|
|
}
|
|
|
|
$this->addUpdateNotify(RouteMap::SOURCE_NEWS_CATE,$route);
|
|
|
|
$this->curlDelRoute(['new_route'=>$route]);
|
...
|
...
|
|