作者 lyh

gx

@@ -42,13 +42,9 @@ class CustomModuleCategoryController extends BaseController @@ -42,13 +42,9 @@ class CustomModuleCategoryController extends BaseController
42 */ 42 */
43 public function info(CustomModuleCategoryLogic $logic){ 43 public function info(CustomModuleCategoryLogic $logic){
44 $this->request->validate([ 44 $this->request->validate([
45 - 'name'=>['required'],  
46 - 'route'=>['required'],  
47 - 'module_id'=>['required'] 45 + 'id'=>['required'],
48 ],[ 46 ],[
49 - 'name.required' => '分类名称不能为空',  
50 - 'route.required' => '分类路由不能为空',  
51 - 'module_id.required' => '所选模块id不能为空' 47 + 'id.required' => '主键不能为空',
52 ]); 48 ]);
53 $info = $logic->getCustomModuleCategoryInfo(); 49 $info = $logic->getCustomModuleCategoryInfo();
54 $this->response('success',Code::SUCCESS,$info); 50 $this->response('success',Code::SUCCESS,$info);
@@ -62,6 +58,15 @@ class CustomModuleCategoryController extends BaseController @@ -62,6 +58,15 @@ class CustomModuleCategoryController extends BaseController
62 * @time :2023/12/4 15:45 58 * @time :2023/12/4 15:45
63 */ 59 */
64 public function save(CustomModuleCategoryLogic $logic){ 60 public function save(CustomModuleCategoryLogic $logic){
  61 + $this->request->validate([
  62 + 'name'=>['required'],
  63 + 'route'=>['required'],
  64 + 'module_id'=>['required']
  65 + ],[
  66 + 'name.required' => '分类名称不能为空',
  67 + 'route.required' => '分类路由不能为空',
  68 + 'module_id.required' => '所选模块id不能为空'
  69 + ]);
65 $logic->customModuleCategorySave(); 70 $logic->customModuleCategorySave();
66 $this->response('success'); 71 $this->response('success');
67 } 72 }
@@ -11,6 +11,7 @@ namespace App\Http\Logic\Bside\CustomModule; @@ -11,6 +11,7 @@ namespace App\Http\Logic\Bside\CustomModule;
11 11
12 use App\Http\Logic\Bside\BaseLogic; 12 use App\Http\Logic\Bside\BaseLogic;
13 use App\Models\CustomModule\CustomModuleCategory; 13 use App\Models\CustomModule\CustomModuleCategory;
  14 +use App\Models\RouteMap\RouteMap;
14 15
15 class CustomModuleCategoryLogic extends BaseLogic 16 class CustomModuleCategoryLogic extends BaseLogic
16 { 17 {
@@ -29,7 +30,11 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -29,7 +30,11 @@ class CustomModuleCategoryLogic extends BaseLogic
29 * @time :2023/12/4 16:10 30 * @time :2023/12/4 16:10
30 */ 31 */
31 public function getCustomModuleCategoryInfo(){ 32 public function getCustomModuleCategoryInfo(){
32 - 33 + $info = $this->model->read($this->param);
  34 + if($info === false){
  35 + $this->fail('当前数据不存在或已被删除');
  36 + }
  37 + return $this->success($info);
33 } 38 }
34 39
35 /** 40 /**
@@ -40,7 +45,47 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -40,7 +45,47 @@ class CustomModuleCategoryLogic extends BaseLogic
40 * @time :2023/12/4 15:47 45 * @time :2023/12/4 15:47
41 */ 46 */
42 public function customModuleCategorySave(){ 47 public function customModuleCategorySave(){
  48 + if(isset($this->param['id']) && !empty($this->param['id'])){
  49 + $this->categoryEdit();
  50 + }else{
  51 + $this->categoryAdd();
  52 + }
  53 + return $this->success();
  54 + }
  55 +
  56 + /**
  57 + * @remark :添加分类
  58 + * @name :categoryAdd
  59 + * @author :lyh
  60 + * @method :post
  61 + * @time :2023/12/5 10:55
  62 + */
  63 + public function categoryAdd(){
  64 + try {
  65 + $id = $this->model->addReturnId($this->param);
  66 + $route = RouteMap::setRoute($this->param['route'], 'module-'.$this->param['module_id'], $id, $this->user['project_id']);
  67 + $this->addUpdateNotify(RouteMap::SOURCE_NEWS,$route);
  68 + $this->edit(['url' => $route], ['id' => $id]);
  69 + }catch (\Exception $e){
  70 + $this->fail('系统错误,请联系管理员');
  71 + }
43 72
  73 + return $this->success();
  74 + }
  75 +
  76 + /**
  77 + * @remark :编辑分类
  78 + * @name :categoryEdit
  79 + * @author :lyh
  80 + * @method :post
  81 + * @time :2023/12/5 10:55
  82 + */
  83 + public function categoryEdit(){
  84 + $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
  85 + if($rs === false){
  86 + $this->fail('系统错误,请连续管理员');
  87 + }
  88 + return $this->success();
44 } 89 }
45 90
46 /** 91 /**
@@ -51,6 +96,10 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -51,6 +96,10 @@ class CustomModuleCategoryLogic extends BaseLogic
51 * @time :2023/12/4 15:47 96 * @time :2023/12/4 15:47
52 */ 97 */
53 public function customModuleCategoryDel(){ 98 public function customModuleCategoryDel(){
54 - 99 + $rs = $this->model->del($this->param);
  100 + if($rs === false){
  101 + $this->fail('系统错误,请连续管理员');
  102 + }
  103 + return $this->success();
55 } 104 }
56 } 105 }
@@ -38,6 +38,11 @@ class RouteMap extends Base @@ -38,6 +38,11 @@ class RouteMap extends Base
38 38
39 const SOURCE_NAV = 'nav'; 39 const SOURCE_NAV = 'nav';
40 40
  41 + //自定义模块
  42 + const SOURCE_MODULE = 'module_';
  43 +
  44 + //自定义模块分类
  45 + const SOURCE_MODULE_CATE = 'module_cate_';
41 /** 46 /**
42 * 生成路由标识 47 * 生成路由标识
43 * @param $title 48 * @param $title