|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Logic\Bside\Blog;
|
|
|
|
|
|
|
|
use App\Http\Logic\Bside\BaseLogic;
|
|
|
|
use App\Models\Blog\BlogExtend;
|
|
|
|
use App\Models\Blog\BlogExtendInfo;
|
|
|
|
|
|
|
|
class BlogExtendLogic extends BaseLogic
|
|
|
|
{
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
$this->model = new BlogExtend();
|
|
|
|
$this->param = $this->requestAll;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :列表页
|
|
|
|
* @name :list
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/5/26 15:17
|
|
|
|
*/
|
|
|
|
public function list($map){
|
|
|
|
$map['status'] = 1;
|
|
|
|
$data = $this->model->list($map);
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存扩展字段
|
|
|
|
* @name :extendSave
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/5/26 15:13
|
|
|
|
* @param :id->主键;title->名称
|
|
|
|
*/
|
|
|
|
public function extendSave(){
|
|
|
|
if(isset($this->param['id']) && !empty($this->param['id'])){
|
|
|
|
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
|
|
|
|
}else{
|
|
|
|
$info = $this->model->read(['title'=>$this->param['title']]);
|
|
|
|
if($info !== false){
|
|
|
|
$this->fail('当前扩展名称已存在');
|
|
|
|
}
|
|
|
|
$this->param['key'] = $this->model->getKey();
|
|
|
|
$this->param['project_id'] = $this->user['project_id'];
|
|
|
|
$rs = $this->model->add($this->param);
|
|
|
|
}
|
|
|
|
if($rs === false){
|
|
|
|
$this->fail('error');
|
|
|
|
}
|
|
|
|
return $this->success($this->param);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :修改状态
|
|
|
|
* @name :extendStatus
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/5/27 9:20
|
|
|
|
*/
|
|
|
|
public function extendStatus(){
|
|
|
|
$result = $this->model->edit(['status'=>$this->param['status']],['id'=>$this->param['id']]);
|
|
|
|
return $this->success(['result'=>$result]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :删除字段
|
|
|
|
* @name :extendDel
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/5/26 15:45
|
|
|
|
* @param :id->主键
|
|
|
|
*/
|
|
|
|
public function extendDel(){
|
|
|
|
$info = $this->model->read(['id'=>$this->param['id']]);
|
|
|
|
//查看当前扩展字段是否设置了值
|
|
|
|
$extendInfoModel = new BlogExtendInfo();
|
|
|
|
$extendInfo = $extendInfoModel->read(['key'=>$info['key']]);
|
|
|
|
if($extendInfo !== false){
|
|
|
|
$this->fail('当前扩展字段已有产品在使用,不允许删除');
|
|
|
|
}
|
|
|
|
$this->model->del(['id'=>$this->param['id']]);
|
|
|
|
}
|
|
|
|
|
|
|
|
} |
...
|
...
|
|