正在显示
3 个修改的文件
包含
224 行增加
和
0 行删除
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :CustomModuleController.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2023/12/4 15:42 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Http\Controllers\Aside\CustomModule; | ||
| 11 | + | ||
| 12 | +use App\Enums\Common\Code; | ||
| 13 | +use App\Http\Controllers\Aside\BaseController; | ||
| 14 | +use App\Http\Logic\Aside\CustomModule\CustomModuleLogic; | ||
| 15 | +use App\Models\CustomModule\CustomModule; | ||
| 16 | + | ||
| 17 | +/** | ||
| 18 | + * @remark :自定义模块 | ||
| 19 | + * @name :CustomModuleController | ||
| 20 | + * @author :lyh | ||
| 21 | + * @method :post | ||
| 22 | + * @time :2023/12/4 15:42 | ||
| 23 | + */ | ||
| 24 | +class CustomModuleController extends BaseController | ||
| 25 | +{ | ||
| 26 | + /** | ||
| 27 | + * @remark :获取自定义模块列表 | ||
| 28 | + * @name :ModuleList | ||
| 29 | + * @author :lyh | ||
| 30 | + * @method :post | ||
| 31 | + * @time :2023/12/4 15:43 | ||
| 32 | + */ | ||
| 33 | + public function lists(CustomModule $customModule){ | ||
| 34 | + $this->map['status'] = 0; | ||
| 35 | + $lists = $customModule->lists($this->map,$this->page,$this->row,$this->order); | ||
| 36 | + $this->response('success',Code::SUCCESS,$lists); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + /** | ||
| 40 | + * @remark :获取当前数据详情 | ||
| 41 | + * @name :info | ||
| 42 | + * @author :lyh | ||
| 43 | + * @method :post | ||
| 44 | + * @time :2023/12/4 16:09 | ||
| 45 | + */ | ||
| 46 | + public function info(CustomModuleLogic $logic){ | ||
| 47 | + $this->request->validate([ | ||
| 48 | + 'id'=>['required'], | ||
| 49 | + ],[ | ||
| 50 | + 'id.required' => 'ID不能为空', | ||
| 51 | + ]); | ||
| 52 | + $info = $logic->getCustomModuleInfo(); | ||
| 53 | + $this->response('success',Code::SUCCESS,$info); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + /** | ||
| 57 | + * @remark :保存数据 | ||
| 58 | + * @name :save | ||
| 59 | + * @author :lyh | ||
| 60 | + * @method :post | ||
| 61 | + * @time :2023/12/4 15:45 | ||
| 62 | + */ | ||
| 63 | + public function save(CustomModuleLogic $logic){ | ||
| 64 | + $this->request->validate([ | ||
| 65 | + 'name'=>['required'], | ||
| 66 | + ],[ | ||
| 67 | + 'name.required' => '模块名称不能为空', | ||
| 68 | + ]); | ||
| 69 | + $logic->customModuleSave(); | ||
| 70 | + $this->response('success'); | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + /** | ||
| 74 | + * @remark :删除 | ||
| 75 | + * @name :del | ||
| 76 | + * @author :lyh | ||
| 77 | + * @method :post | ||
| 78 | + * @time :2023/12/5 9:53 | ||
| 79 | + */ | ||
| 80 | + public function del(CustomModuleLogic $logic){ | ||
| 81 | + $this->request->validate([ | ||
| 82 | + 'id'=>['required'], | ||
| 83 | + ],[ | ||
| 84 | + 'id.required' => 'ID不能为空', | ||
| 85 | + ]); | ||
| 86 | + $logic->customModuleDel(); | ||
| 87 | + $this->response('success'); | ||
| 88 | + } | ||
| 89 | +} |
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :CustomModuleLogic.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2023/12/4 15:46 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Http\Logic\Aside\CustomModule; | ||
| 11 | + | ||
| 12 | +use App\Http\Logic\Aside\BaseLogic; | ||
| 13 | +use App\Models\CustomModule\CustomModule; | ||
| 14 | +use App\Models\CustomModule\CustomModuleCategory; | ||
| 15 | +use App\Models\CustomModule\CustomModuleContent; | ||
| 16 | + | ||
| 17 | +class CustomModuleLogic extends BaseLogic | ||
| 18 | +{ | ||
| 19 | + public function __construct() | ||
| 20 | + { | ||
| 21 | + parent::__construct(); | ||
| 22 | + $this->param = $this->requestAll; | ||
| 23 | + $this->model = new CustomModule(); | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * @remark :获取当前数据详情 | ||
| 28 | + * @name :getCustomModuleInfo | ||
| 29 | + * @author :lyh | ||
| 30 | + * @method :post | ||
| 31 | + * @time :2023/12/4 16:10 | ||
| 32 | + */ | ||
| 33 | + public function getCustomModuleInfo(){ | ||
| 34 | + $info = $this->model->read($this->param); | ||
| 35 | + if($info === false){ | ||
| 36 | + $this->fail('当前数据不存在或已被删除'); | ||
| 37 | + } | ||
| 38 | + return $this->success($info); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + /** | ||
| 42 | + * @remark :保存数据 | ||
| 43 | + * @name :ModuleSave | ||
| 44 | + * @author :lyh | ||
| 45 | + * @method :post | ||
| 46 | + * @time :2023/12/4 15:47 | ||
| 47 | + */ | ||
| 48 | + public function customModuleSave(){ | ||
| 49 | + $this->param = $this->handleParam($this->param); | ||
| 50 | + if(isset($this->param['id']) && !empty($this->param['id'])){ | ||
| 51 | + $this->moduleEdit(); | ||
| 52 | + }else{ | ||
| 53 | + $this->moduleAdd(); | ||
| 54 | + } | ||
| 55 | + return $this->success(); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + /** | ||
| 59 | + * @name :(参数处理)paramProcessing | ||
| 60 | + * @author :lyh | ||
| 61 | + * @method :post | ||
| 62 | + * @time :2023/6/13 11:30 | ||
| 63 | + */ | ||
| 64 | + public function handleParam($param) | ||
| 65 | + { | ||
| 66 | + $param['operator_id'] = $this->manager['id']; | ||
| 67 | + if(!isset($param['id']) || empty($param['id'])){ | ||
| 68 | + $param['project_id'] = $this->param['project_id']; | ||
| 69 | + } | ||
| 70 | + return $this->success($param); | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + /** | ||
| 74 | + * @remark :新增 | ||
| 75 | + * @name :moduleAdd | ||
| 76 | + * @author :lyh | ||
| 77 | + * @method :post | ||
| 78 | + * @time :2023/12/5 9:39 | ||
| 79 | + */ | ||
| 80 | + public function moduleAdd(){ | ||
| 81 | + $rs = $this->model->add($this->param); | ||
| 82 | + if($rs === false){ | ||
| 83 | + $this->fail('系统错误,请联系管理员'); | ||
| 84 | + } | ||
| 85 | + return $this->success(); | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + /** | ||
| 89 | + * @remark :编辑 | ||
| 90 | + * @name :moduleEdit | ||
| 91 | + * @author :lyh | ||
| 92 | + * @method :post | ||
| 93 | + * @time :2023/12/5 9:39 | ||
| 94 | + */ | ||
| 95 | + public function moduleEdit(){ | ||
| 96 | + $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 97 | + if($rs === false){ | ||
| 98 | + $this->fail('系统错误,请联系管理员'); | ||
| 99 | + } | ||
| 100 | + return $this->success(); | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + /** | ||
| 104 | + * @remark :删除数据 | ||
| 105 | + * @name :ModuleDel | ||
| 106 | + * @author :lyh | ||
| 107 | + * @method :post | ||
| 108 | + * @time :2023/12/4 15:47 | ||
| 109 | + */ | ||
| 110 | + public function customModuleDel(){ | ||
| 111 | + //查看当前模块是否拥有数据 | ||
| 112 | + $contentModel = new CustomModuleContent(); | ||
| 113 | + $contentInfo = $contentModel->read(['module_id'=>$this->param['id']],['id']); | ||
| 114 | + if($contentInfo !== false){ | ||
| 115 | + $this->fail('当前模块拥有内容不允许删除'); | ||
| 116 | + } | ||
| 117 | + $categoryModel = new CustomModuleCategory(); | ||
| 118 | + $categoryInfo = $categoryModel->read(['module_id'=>$this->param['id']],['id']); | ||
| 119 | + if($categoryInfo !== false){ | ||
| 120 | + $this->fail('当前模块拥有分类不允许删除'); | ||
| 121 | + } | ||
| 122 | + $rs = $this->model->del($this->param); | ||
| 123 | + if($rs === false){ | ||
| 124 | + $this->fail('系统错误,请联系管理员'); | ||
| 125 | + } | ||
| 126 | + return $this->success(); | ||
| 127 | + } | ||
| 128 | +} |
| @@ -301,6 +301,13 @@ Route::middleware(['aloginauth'])->group(function () { | @@ -301,6 +301,13 @@ Route::middleware(['aloginauth'])->group(function () { | ||
| 301 | Route::any('/getTimeZone', [Aside\Optimize\InquiryInfoController::class, 'getTimeZone'])->name('admin.inquiry_getTimeZone'); | 301 | Route::any('/getTimeZone', [Aside\Optimize\InquiryInfoController::class, 'getTimeZone'])->name('admin.inquiry_getTimeZone'); |
| 302 | Route::any('/getInternalCount', [Aside\Optimize\InquiryInfoController::class, 'getInternalCount'])->name('admin.inquiry_getInternalCount'); | 302 | Route::any('/getInternalCount', [Aside\Optimize\InquiryInfoController::class, 'getInternalCount'])->name('admin.inquiry_getInternalCount'); |
| 303 | }); | 303 | }); |
| 304 | + | ||
| 305 | + Route::prefix('custom_module')->group(function () { | ||
| 306 | + Route::any('/', [\App\Http\Controllers\Aside\CustomModule\CustomModuleController::class, 'lists'])->name('custom_lists'); | ||
| 307 | + Route::any('/save', [\App\Http\Controllers\Aside\CustomModule\CustomModuleController::class, 'save'])->name('custom_save'); | ||
| 308 | + Route::any('/del', [\App\Http\Controllers\Aside\CustomModule\CustomModuleController::class, 'del'])->name('custom_del'); | ||
| 309 | + }); | ||
| 310 | + | ||
| 304 | // 公共主题模版 | 311 | // 公共主题模版 |
| 305 | Route::prefix('template')->group(function () { | 312 | Route::prefix('template')->group(function () { |
| 306 | Route::any('/', [Aside\Template\ATemplateController::class, 'lists'])->name('admin.ATemplate_lists'); | 313 | Route::any('/', [Aside\Template\ATemplateController::class, 'lists'])->name('admin.ATemplate_lists'); |
-
请 注册 或 登录 后发表评论