作者 lyh

gx

... ... @@ -42,13 +42,9 @@ class CustomModuleCategoryController extends BaseController
*/
public function info(CustomModuleCategoryLogic $logic){
$this->request->validate([
'name'=>['required'],
'route'=>['required'],
'module_id'=>['required']
'id'=>['required'],
],[
'name.required' => '分类名称不能为空',
'route.required' => '分类路由不能为空',
'module_id.required' => '所选模块id不能为空'
'id.required' => '主键不能为空',
]);
$info = $logic->getCustomModuleCategoryInfo();
$this->response('success',Code::SUCCESS,$info);
... ... @@ -62,6 +58,15 @@ class CustomModuleCategoryController extends BaseController
* @time :2023/12/4 15:45
*/
public function save(CustomModuleCategoryLogic $logic){
$this->request->validate([
'name'=>['required'],
'route'=>['required'],
'module_id'=>['required']
],[
'name.required' => '分类名称不能为空',
'route.required' => '分类路由不能为空',
'module_id.required' => '所选模块id不能为空'
]);
$logic->customModuleCategorySave();
$this->response('success');
}
... ...
... ... @@ -11,6 +11,7 @@ namespace App\Http\Logic\Bside\CustomModule;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\CustomModule\CustomModuleCategory;
use App\Models\RouteMap\RouteMap;
class CustomModuleCategoryLogic extends BaseLogic
{
... ... @@ -29,7 +30,11 @@ class CustomModuleCategoryLogic extends BaseLogic
* @time :2023/12/4 16:10
*/
public function getCustomModuleCategoryInfo(){
$info = $this->model->read($this->param);
if($info === false){
$this->fail('当前数据不存在或已被删除');
}
return $this->success($info);
}
/**
... ... @@ -40,7 +45,47 @@ class CustomModuleCategoryLogic extends BaseLogic
* @time :2023/12/4 15:47
*/
public function customModuleCategorySave(){
if(isset($this->param['id']) && !empty($this->param['id'])){
$this->categoryEdit();
}else{
$this->categoryAdd();
}
return $this->success();
}
/**
* @remark :添加分类
* @name :categoryAdd
* @author :lyh
* @method :post
* @time :2023/12/5 10:55
*/
public function categoryAdd(){
try {
$id = $this->model->addReturnId($this->param);
$route = RouteMap::setRoute($this->param['route'], 'module-'.$this->param['module_id'], $id, $this->user['project_id']);
$this->addUpdateNotify(RouteMap::SOURCE_NEWS,$route);
$this->edit(['url' => $route], ['id' => $id]);
}catch (\Exception $e){
$this->fail('系统错误,请联系管理员');
}
return $this->success();
}
/**
* @remark :编辑分类
* @name :categoryEdit
* @author :lyh
* @method :post
* @time :2023/12/5 10:55
*/
public function categoryEdit(){
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
if($rs === false){
$this->fail('系统错误,请连续管理员');
}
return $this->success();
}
/**
... ... @@ -51,6 +96,10 @@ class CustomModuleCategoryLogic extends BaseLogic
* @time :2023/12/4 15:47
*/
public function customModuleCategoryDel(){
$rs = $this->model->del($this->param);
if($rs === false){
$this->fail('系统错误,请连续管理员');
}
return $this->success();
}
}
... ...
... ... @@ -38,6 +38,11 @@ class RouteMap extends Base
const SOURCE_NAV = 'nav';
//自定义模块
const SOURCE_MODULE = 'module_';
//自定义模块分类
const SOURCE_MODULE_CATE = 'module_cate_';
/**
* 生成路由标识
* @param $title
... ...