|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @remark :
|
|
|
|
* @name :CustomModuleLogic.php
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/4 15:46
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Http\Logic\Aside\CustomModule;
|
|
|
|
|
|
|
|
use App\Http\Logic\Aside\BaseLogic;
|
|
|
|
use App\Models\CustomModule\CustomModule;
|
|
|
|
use App\Models\CustomModule\CustomModuleCategory;
|
|
|
|
use App\Models\CustomModule\CustomModuleContent;
|
|
|
|
|
|
|
|
class CustomModuleLogic extends BaseLogic
|
|
|
|
{
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
$this->param = $this->requestAll;
|
|
|
|
$this->model = new CustomModule();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取当前数据详情
|
|
|
|
* @name :getCustomModuleInfo
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/4 16:10
|
|
|
|
*/
|
|
|
|
public function getCustomModuleInfo(){
|
|
|
|
$info = $this->model->read($this->param);
|
|
|
|
if($info === false){
|
|
|
|
$this->fail('当前数据不存在或已被删除');
|
|
|
|
}
|
|
|
|
return $this->success($info);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存数据
|
|
|
|
* @name :ModuleSave
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/4 15:47
|
|
|
|
*/
|
|
|
|
public function customModuleSave(){
|
|
|
|
$this->param = $this->handleParam($this->param);
|
|
|
|
if(isset($this->param['id']) && !empty($this->param['id'])){
|
|
|
|
$this->moduleEdit();
|
|
|
|
}else{
|
|
|
|
$this->moduleAdd();
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name :(参数处理)paramProcessing
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/6/13 11:30
|
|
|
|
*/
|
|
|
|
public function handleParam($param)
|
|
|
|
{
|
|
|
|
$param['operator_id'] = $this->manager['id'];
|
|
|
|
if(!isset($param['id']) || empty($param['id'])){
|
|
|
|
$param['project_id'] = $this->param['project_id'];
|
|
|
|
}
|
|
|
|
return $this->success($param);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :新增
|
|
|
|
* @name :moduleAdd
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/5 9:39
|
|
|
|
*/
|
|
|
|
public function moduleAdd(){
|
|
|
|
$rs = $this->model->add($this->param);
|
|
|
|
if($rs === false){
|
|
|
|
$this->fail('系统错误,请联系管理员');
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :编辑
|
|
|
|
* @name :moduleEdit
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/5 9:39
|
|
|
|
*/
|
|
|
|
public function moduleEdit(){
|
|
|
|
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
|
|
|
|
if($rs === false){
|
|
|
|
$this->fail('系统错误,请联系管理员');
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :删除数据
|
|
|
|
* @name :ModuleDel
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/4 15:47
|
|
|
|
*/
|
|
|
|
public function customModuleDel(){
|
|
|
|
//查看当前模块是否拥有数据
|
|
|
|
$contentModel = new CustomModuleContent();
|
|
|
|
$contentInfo = $contentModel->read(['module_id'=>$this->param['id']],['id']);
|
|
|
|
if($contentInfo !== false){
|
|
|
|
$this->fail('当前模块拥有内容不允许删除');
|
|
|
|
}
|
|
|
|
$categoryModel = new CustomModuleCategory();
|
|
|
|
$categoryInfo = $categoryModel->read(['module_id'=>$this->param['id']],['id']);
|
|
|
|
if($categoryInfo !== false){
|
|
|
|
$this->fail('当前模块拥有分类不允许删除');
|
|
|
|
}
|
|
|
|
$rs = $this->model->del($this->param);
|
|
|
|
if($rs === false){
|
|
|
|
$this->fail('系统错误,请联系管理员');
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|