正在显示
4 个修改的文件
包含
118 行增加
和
5 行删除
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :BTemplateModuleProjectController.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2023/11/14 14:34 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Http\Controllers\Bside\Template; | ||
| 11 | + | ||
| 12 | +use App\Enums\Common\Code; | ||
| 13 | +use App\Http\Controllers\Bside\BaseController; | ||
| 14 | +use App\Http\Logic\Bside\BTemplate\BTemplateModuleProjectLogic; | ||
| 15 | +use App\Models\Template\BModuleProject; | ||
| 16 | + | ||
| 17 | +class BTemplateModuleProjectController extends BaseController | ||
| 18 | +{ | ||
| 19 | + /** | ||
| 20 | + * @remark :获取私有化模块列表 | ||
| 21 | + * @name :lists | ||
| 22 | + * @author :lyh | ||
| 23 | + * @method :post | ||
| 24 | + * @time :2023/11/14 14:34 | ||
| 25 | + */ | ||
| 26 | + public function lists(BModuleProject $BModuleProject){ | ||
| 27 | + $list = $BModuleProject->list($this->map); | ||
| 28 | + $this->response('success',Code::SUCCESS,$list); | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * @remark :保存私有化左侧模块 | ||
| 33 | + * @name :save | ||
| 34 | + * @author :lyh | ||
| 35 | + * @method :post | ||
| 36 | + * @time :2023/11/14 14:38 | ||
| 37 | + */ | ||
| 38 | + public function save(BTemplateModuleProjectLogic $logic){ | ||
| 39 | + $this->request->validate([ | ||
| 40 | + 'name'=>'required', | ||
| 41 | + 'html'=>'required', | ||
| 42 | + ],[ | ||
| 43 | + 'name.required' => '模板名称不能为空', | ||
| 44 | + 'html.required' => 'html不能为空', | ||
| 45 | + ]); | ||
| 46 | + $logic->moduleProjectSave(); | ||
| 47 | + return $this->response('success'); | ||
| 48 | + } | ||
| 49 | +} |
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :BTemplateModuleProjectLogic.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2023/11/14 14:41 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Http\Logic\Bside\BTemplate; | ||
| 11 | + | ||
| 12 | +use App\Http\Logic\Bside\BaseLogic; | ||
| 13 | +use App\Models\Template\BModuleProject; | ||
| 14 | + | ||
| 15 | +class BTemplateModuleProjectLogic extends BaseLogic | ||
| 16 | +{ | ||
| 17 | + public function __construct() | ||
| 18 | + { | ||
| 19 | + parent::__construct(); | ||
| 20 | + $this->model = new BModuleProject(); | ||
| 21 | + $this->param = $this->requestAll; | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * @remark :保存私有化左侧模块1 | ||
| 26 | + * @name :moduleProjectSave | ||
| 27 | + * @author :lyh | ||
| 28 | + * @method :post | ||
| 29 | + * @time :2023/11/14 14:46 | ||
| 30 | + */ | ||
| 31 | + public function moduleProjectSave(){ | ||
| 32 | + try { | ||
| 33 | + $this->param['operator_id'] = $this->user['id']; | ||
| 34 | + $this->param['project_id'] = $this->user['project_id']; | ||
| 35 | + $this->model->add($this->param); | ||
| 36 | + }catch (\Exception $e){ | ||
| 37 | + $this->fail('系统错误,请联系管理员'); | ||
| 38 | + } | ||
| 39 | + return $this->success(); | ||
| 40 | + } | ||
| 41 | +} |
| @@ -38,7 +38,7 @@ class ExtendLogic extends BaseLogic | @@ -38,7 +38,7 @@ class ExtendLogic extends BaseLogic | ||
| 38 | if($info !== false){ | 38 | if($info !== false){ |
| 39 | $this->fail('当前扩展名称已存在'); | 39 | $this->fail('当前扩展名称已存在'); |
| 40 | } | 40 | } |
| 41 | - $key = trim(strtolower(preg_replace('/[\W]+/', '-', trim(Translate::tran($this->param['title'], 'en')))), '-'); | 41 | + $key = 'pd_extended_field_'; |
| 42 | $this->param['key'] = $this->getKey($key); | 42 | $this->param['key'] = $this->getKey($key); |
| 43 | $this->param['project_id'] = $this->user['project_id']; | 43 | $this->param['project_id'] = $this->user['project_id']; |
| 44 | $rs = $this->model->add($this->param); | 44 | $rs = $this->model->add($this->param); |
| @@ -56,11 +56,10 @@ class ExtendLogic extends BaseLogic | @@ -56,11 +56,10 @@ class ExtendLogic extends BaseLogic | ||
| 56 | * @method :post | 56 | * @method :post |
| 57 | * @time :2023/11/9 15:55 | 57 | * @time :2023/11/9 15:55 |
| 58 | */ | 58 | */ |
| 59 | - public function getKey($key){ | ||
| 60 | - $info = $this->model->read(['key'=>$key]); | 59 | + public function getKey($key,$i = 1){ |
| 60 | + $info = $this->model->read(['key'=>$key.$i]); | ||
| 61 | if($info !== false){ | 61 | if($info !== false){ |
| 62 | - $key .= '-'.rand(1, 100); | ||
| 63 | - return $this->getKey($key); | 62 | + return $this->getKey($key,$i+1); |
| 64 | } | 63 | } |
| 65 | return $key; | 64 | return $key; |
| 66 | } | 65 | } |
app/Models/Template/BModuleProject.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :BModuleProject.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2023/11/14 14:31 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Models\Template; | ||
| 11 | + | ||
| 12 | +use App\Models\Base; | ||
| 13 | + | ||
| 14 | +/** | ||
| 15 | + * @remark :私有化左侧模块 | ||
| 16 | + * @name :BModuleProject | ||
| 17 | + * @author :lyh | ||
| 18 | + * @method :post | ||
| 19 | + * @time :2023/11/14 14:33 | ||
| 20 | + */ | ||
| 21 | +class BModuleProject extends Base | ||
| 22 | +{ | ||
| 23 | + protected $table = 'gl_public_template_module_project'; | ||
| 24 | +} |
-
请 注册 或 登录 后发表评论