作者 lyh

gx

@@ -22,7 +22,12 @@ class CustomModuleCategoryController extends BaseController @@ -22,7 +22,12 @@ class CustomModuleCategoryController extends BaseController
22 * @method :post 22 * @method :post
23 * @time :2023/12/4 15:43 23 * @time :2023/12/4 15:43
24 */ 24 */
25 - public function list(CustomModuleCategory $customModuleCategory){ 25 + public function lists(CustomModuleCategory $customModuleCategory){
  26 + $this->request->validate([
  27 + 'module_id'=>['required'],
  28 + ],[
  29 + 'module_id.required' => 'module_id不能为空',
  30 + ]);
26 $this->map['project_id'] = $this->user['project_id']; 31 $this->map['project_id'] = $this->user['project_id'];
27 $lists = $customModuleCategory->lists($this->map,$this->page,$this->row,$this->order); 32 $lists = $customModuleCategory->lists($this->map,$this->page,$this->row,$this->order);
28 $this->response('success',Code::SUCCESS,$lists); 33 $this->response('success',Code::SUCCESS,$lists);
@@ -37,9 +42,13 @@ class CustomModuleCategoryController extends BaseController @@ -37,9 +42,13 @@ class CustomModuleCategoryController extends BaseController
37 */ 42 */
38 public function info(CustomModuleCategoryLogic $logic){ 43 public function info(CustomModuleCategoryLogic $logic){
39 $this->request->validate([ 44 $this->request->validate([
40 - 'id'=>['required'], 45 + 'name'=>['required'],
  46 + 'route'=>['required'],
  47 + 'module_id'=>['required']
41 ],[ 48 ],[
42 - 'id.required' => 'ID不能为空', 49 + 'name.required' => '分类名称不能为空',
  50 + 'route.required' => '分类路由不能为空',
  51 + 'module_id.required' => '所选模块id不能为空'
43 ]); 52 ]);
44 $info = $logic->getCustomModuleCategoryInfo(); 53 $info = $logic->getCustomModuleCategoryInfo();
45 $this->response('success',Code::SUCCESS,$info); 54 $this->response('success',Code::SUCCESS,$info);
@@ -30,7 +30,7 @@ class CustomModuleController extends BaseController @@ -30,7 +30,7 @@ class CustomModuleController extends BaseController
30 * @method :post 30 * @method :post
31 * @time :2023/12/4 15:43 31 * @time :2023/12/4 15:43
32 */ 32 */
33 - public function list(CustomModule $customModule){ 33 + public function lists(CustomModule $customModule){
34 $this->map['project_id'] = $this->user['project_id']; 34 $this->map['project_id'] = $this->user['project_id'];
35 $lists = $customModule->lists($this->map,$this->page,$this->row,$this->order); 35 $lists = $customModule->lists($this->map,$this->page,$this->row,$this->order);
36 $this->response('success',Code::SUCCESS,$lists); 36 $this->response('success',Code::SUCCESS,$lists);
@@ -61,10 +61,22 @@ class CustomModuleController extends BaseController @@ -61,10 +61,22 @@ class CustomModuleController extends BaseController
61 * @time :2023/12/4 15:45 61 * @time :2023/12/4 15:45
62 */ 62 */
63 public function save(CustomModuleLogic $logic){ 63 public function save(CustomModuleLogic $logic){
  64 + $this->request->validate([
  65 + 'name'=>['required'],
  66 + ],[
  67 + 'name.required' => '模块名称不能为空',
  68 + ]);
64 $logic->customModuleSave(); 69 $logic->customModuleSave();
65 $this->response('success'); 70 $this->response('success');
66 } 71 }
67 72
  73 + /**
  74 + * @remark :删除
  75 + * @name :del
  76 + * @author :lyh
  77 + * @method :post
  78 + * @time :2023/12/5 9:53
  79 + */
68 public function del(CustomModuleLogic $logic){ 80 public function del(CustomModuleLogic $logic){
69 $this->request->validate([ 81 $this->request->validate([
70 'id'=>['required'], 82 'id'=>['required'],
@@ -195,6 +195,9 @@ class ImageController extends Controller @@ -195,6 +195,9 @@ class ImageController extends Controller
195 //保存路径 195 //保存路径
196 $url = $this->config['root'].$this->path; 196 $url = $this->config['root'].$this->path;
197 $image_type = $files->getClientOriginalExtension(); 197 $image_type = $files->getClientOriginalExtension();
  198 + if(strlen($image_type) > 7){
  199 + $this->response('不支持当前格式',Code::SYSTEM_ERROR);
  200 + }
198 $fileName = uniqid().rand(10000,99999).'.'.$image_type; 201 $fileName = uniqid().rand(10000,99999).'.'.$image_type;
199 //上传到cos 202 //上传到cos
200 if($this->upload_location == 1){ 203 if($this->upload_location == 1){
@@ -11,6 +11,8 @@ namespace App\Http\Logic\Bside\CustomModule; @@ -11,6 +11,8 @@ 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\CustomModule; 13 use App\Models\CustomModule\CustomModule;
  14 +use App\Models\CustomModule\CustomModuleCategory;
  15 +use App\Models\CustomModule\CustomModuleContent;
14 16
15 class CustomModuleLogic extends BaseLogic 17 class CustomModuleLogic extends BaseLogic
16 { 18 {
@@ -29,7 +31,11 @@ class CustomModuleLogic extends BaseLogic @@ -29,7 +31,11 @@ class CustomModuleLogic extends BaseLogic
29 * @time :2023/12/4 16:10 31 * @time :2023/12/4 16:10
30 */ 32 */
31 public function getCustomModuleInfo(){ 33 public function getCustomModuleInfo(){
32 - 34 + $info = $this->model->read($this->param);
  35 + if($info === false){
  36 + $this->fail('当前数据不存在或已被删除');
  37 + }
  38 + return $this->success($info);
33 } 39 }
34 40
35 /** 41 /**
@@ -40,7 +46,42 @@ class CustomModuleLogic extends BaseLogic @@ -40,7 +46,42 @@ class CustomModuleLogic extends BaseLogic
40 * @time :2023/12/4 15:47 46 * @time :2023/12/4 15:47
41 */ 47 */
42 public function customModuleSave(){ 48 public function customModuleSave(){
  49 + if(isset($this->param['id']) && !empty($this->param['id'])){
  50 + $this->moduleEdit();
  51 + }else{
  52 + $this->moduleAdd();
  53 + }
  54 + return $this->success();
  55 + }
  56 +
  57 + /**
  58 + * @remark :新增
  59 + * @name :moduleAdd
  60 + * @author :lyh
  61 + * @method :post
  62 + * @time :2023/12/5 9:39
  63 + */
  64 + public function moduleAdd(){
  65 + $rs = $this->model->add($this->param);
  66 + if($rs === false){
  67 + $this->fail('系统错误,请联系管理员');
  68 + }
  69 + return $this->success();
  70 + }
43 71
  72 + /**
  73 + * @remark :编辑
  74 + * @name :moduleEdit
  75 + * @author :lyh
  76 + * @method :post
  77 + * @time :2023/12/5 9:39
  78 + */
  79 + public function moduleEdit(){
  80 + $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
  81 + if($rs === false){
  82 + $this->fail('系统错误,请联系管理员');
  83 + }
  84 + return $this->success();
44 } 85 }
45 86
46 /** 87 /**
@@ -51,6 +92,21 @@ class CustomModuleLogic extends BaseLogic @@ -51,6 +92,21 @@ class CustomModuleLogic extends BaseLogic
51 * @time :2023/12/4 15:47 92 * @time :2023/12/4 15:47
52 */ 93 */
53 public function customModuleDel(){ 94 public function customModuleDel(){
54 - 95 + //查看当前模块是否拥有数据
  96 + $contentModel = new CustomModuleContent();
  97 + $contentInfo = $contentModel->read(['module_id'=>$this->param['id']],['id']);
  98 + if($contentInfo !== false){
  99 + $this->fail('当前模块拥有内容不允许删除');
  100 + }
  101 + $categoryModel = new CustomModuleCategory();
  102 + $categoryInfo = $categoryModel->read(['module_id'=>$this->param['id']],['id']);
  103 + if($categoryInfo !== false){
  104 + $this->fail('当前模块拥有分类不允许删除');
  105 + }
  106 + $rs = $this->model->del($this->param);
  107 + if($rs === false){
  108 + $this->fail('系统错误,请联系管理员');
  109 + }
  110 + return $this->success();
55 } 111 }
56 } 112 }
@@ -422,6 +422,19 @@ Route::middleware(['bloginauth'])->group(function () { @@ -422,6 +422,19 @@ Route::middleware(['bloginauth'])->group(function () {
422 Route::prefix('language')->group(function () { 422 Route::prefix('language')->group(function () {
423 Route::any('/', [\App\Http\Controllers\Bside\Setting\LanguageController::class, 'lists'])->name('language_lists'); 423 Route::any('/', [\App\Http\Controllers\Bside\Setting\LanguageController::class, 'lists'])->name('language_lists');
424 }); 424 });
  425 +
  426 + //自定义模板
  427 + Route::prefix('custom')->group(function () {
  428 + Route::any('/', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'lists'])->name('custom_lists');
  429 + Route::any('/save', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'save'])->name('custom_save');
  430 + Route::any('/del', [\App\Http\Controllers\Bside\CustomModule\CustomModuleController::class, 'del'])->name('custom_del');
  431 +
  432 + Route::prefix('category')->group(function () {
  433 + Route::any('/', [\App\Http\Controllers\Bside\CustomModule\CustomModuleCategoryController::class, 'lists'])->name('custom_lists');
  434 + Route::any('/save', [\App\Http\Controllers\Bside\CustomModule\CustomModuleCategoryController::class, 'save'])->name('custom_save');
  435 + Route::any('/del', [\App\Http\Controllers\Bside\CustomModule\CustomModuleCategoryController::class, 'del'])->name('custom_del');
  436 + });
  437 + });
425 }); 438 });
426 //无需登录验证的路由组 439 //无需登录验证的路由组
427 Route::group([], function () { 440 Route::group([], function () {