正在显示
10 个修改的文件
包含
437 行增加
和
20 行删除
| @@ -11,6 +11,7 @@ namespace App\Http\Controllers\Bside\CustomModule; | @@ -11,6 +11,7 @@ namespace App\Http\Controllers\Bside\CustomModule; | ||
| 11 | 11 | ||
| 12 | use App\Http\Controllers\Bside\BaseController; | 12 | use App\Http\Controllers\Bside\BaseController; |
| 13 | use App\Http\Logic\Bside\CustomModule\CustomModuleContentLogic; | 13 | use App\Http\Logic\Bside\CustomModule\CustomModuleContentLogic; |
| 14 | +use App\Models\CustomModule\CustomModuleCategory; | ||
| 14 | use App\Models\CustomModule\CustomModuleContent; | 15 | use App\Models\CustomModule\CustomModuleContent; |
| 15 | 16 | ||
| 16 | class CustomModuleContentController extends BaseController | 17 | class CustomModuleContentController extends BaseController |
| @@ -34,6 +35,19 @@ class CustomModuleContentController extends BaseController | @@ -34,6 +35,19 @@ class CustomModuleContentController extends BaseController | ||
| 34 | } | 35 | } |
| 35 | 36 | ||
| 36 | /** | 37 | /** |
| 38 | + * @remark :添加/编辑内容时获取分类 | ||
| 39 | + * @name :getCategoryList | ||
| 40 | + * @author :lyh | ||
| 41 | + * @method :post | ||
| 42 | + * @time :2023/12/7 15:19 | ||
| 43 | + */ | ||
| 44 | + public function getCategoryList(){ | ||
| 45 | + $categoryModel = new CustomModuleCategory(); | ||
| 46 | + $list = $categoryModel->list(['project_id'=>$this->user['project_id'],'module_id'=>$this->param['module_id']],['id','name']); | ||
| 47 | + $this->response('success',Code::SUCCESS,$list); | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + /** | ||
| 37 | * @remark :获取当前数据详情 | 51 | * @remark :获取当前数据详情 |
| 38 | * @name :info | 52 | * @name :info |
| 39 | * @author :lyh | 53 | * @author :lyh |
| @@ -46,7 +60,7 @@ class CustomModuleContentController extends BaseController | @@ -46,7 +60,7 @@ class CustomModuleContentController extends BaseController | ||
| 46 | ],[ | 60 | ],[ |
| 47 | 'id.required' => 'ID不能为空', | 61 | 'id.required' => 'ID不能为空', |
| 48 | ]); | 62 | ]); |
| 49 | - $info = $logic->getCustomModuleContentInfo(); | 63 | + $info = $logic->getContentInfo(); |
| 50 | $this->response('success',Code::SUCCESS,$info); | 64 | $this->response('success',Code::SUCCESS,$info); |
| 51 | } | 65 | } |
| 52 | 66 | ||
| @@ -67,7 +81,7 @@ class CustomModuleContentController extends BaseController | @@ -67,7 +81,7 @@ class CustomModuleContentController extends BaseController | ||
| 67 | 'route.required' => '分类路由不能为空', | 81 | 'route.required' => '分类路由不能为空', |
| 68 | 'module_id.required' => '所选模块id不能为空' | 82 | 'module_id.required' => '所选模块id不能为空' |
| 69 | ]); | 83 | ]); |
| 70 | - $logic->customModuleContentSave(); | 84 | + $logic->contentSave(); |
| 71 | $this->response('success'); | 85 | $this->response('success'); |
| 72 | } | 86 | } |
| 73 | 87 | ||
| @@ -84,7 +98,7 @@ class CustomModuleContentController extends BaseController | @@ -84,7 +98,7 @@ class CustomModuleContentController extends BaseController | ||
| 84 | ],[ | 98 | ],[ |
| 85 | 'id.required' => 'ID不能为空', | 99 | 'id.required' => 'ID不能为空', |
| 86 | ]); | 100 | ]); |
| 87 | - $logic->customModuleContentDel(); | 101 | + $logic->contentDel(); |
| 88 | $this->response('success'); | 102 | $this->response('success'); |
| 89 | } | 103 | } |
| 90 | } | 104 | } |
| @@ -22,9 +22,15 @@ class CustomModuleExtentController extends BaseController | @@ -22,9 +22,15 @@ class CustomModuleExtentController 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(CustomModuleExtend $customModuleExtend){ | 25 | + public function lists(CustomModuleExtend $customModuleExtend){ |
| 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 = $customModuleExtend->lists($this->map,$this->page,$this->row,$this->order); | 32 | + $filed = ['id','title','status','type','operator_id','project_id','module_id','created_at','updated_at']; |
| 33 | + $lists = $customModuleExtend->lists($this->map,$this->page,$this->row,$this->order,$filed); | ||
| 28 | $this->response('success',Code::SUCCESS,$lists); | 34 | $this->response('success',Code::SUCCESS,$lists); |
| 29 | } | 35 | } |
| 30 | 36 | ||
| @@ -41,7 +47,7 @@ class CustomModuleExtentController extends BaseController | @@ -41,7 +47,7 @@ class CustomModuleExtentController extends BaseController | ||
| 41 | ],[ | 47 | ],[ |
| 42 | 'id.required' => 'ID不能为空', | 48 | 'id.required' => 'ID不能为空', |
| 43 | ]); | 49 | ]); |
| 44 | - $info = $logic->getCustomModuleExtendInfo(); | 50 | + $info = $logic->getExtendInfo(); |
| 45 | $this->response('success',Code::SUCCESS,$info); | 51 | $this->response('success',Code::SUCCESS,$info); |
| 46 | } | 52 | } |
| 47 | 53 | ||
| @@ -53,7 +59,7 @@ class CustomModuleExtentController extends BaseController | @@ -53,7 +59,7 @@ class CustomModuleExtentController extends BaseController | ||
| 53 | * @time :2023/12/4 15:45 | 59 | * @time :2023/12/4 15:45 |
| 54 | */ | 60 | */ |
| 55 | public function save(CustomModuleExtendLogic $logic){ | 61 | public function save(CustomModuleExtendLogic $logic){ |
| 56 | - $logic->customModuleExtendSave(); | 62 | + $logic->extendSave(); |
| 57 | $this->response('success'); | 63 | $this->response('success'); |
| 58 | } | 64 | } |
| 59 | 65 | ||
| @@ -70,7 +76,7 @@ class CustomModuleExtentController extends BaseController | @@ -70,7 +76,7 @@ class CustomModuleExtentController extends BaseController | ||
| 70 | ],[ | 76 | ],[ |
| 71 | 'id.required' => 'ID不能为空', | 77 | 'id.required' => 'ID不能为空', |
| 72 | ]); | 78 | ]); |
| 73 | - $logic->customModuleExtendDel(); | 79 | + $logic->extendDel(); |
| 74 | $this->response('success'); | 80 | $this->response('success'); |
| 75 | } | 81 | } |
| 76 | } | 82 | } |
| @@ -93,6 +93,7 @@ class CustomModuleCategoryLogic extends BaseLogic | @@ -93,6 +93,7 @@ class CustomModuleCategoryLogic extends BaseLogic | ||
| 93 | * @time :2023/12/4 15:47 | 93 | * @time :2023/12/4 15:47 |
| 94 | */ | 94 | */ |
| 95 | public function categorySave(){ | 95 | public function categorySave(){ |
| 96 | + $this->param = $this->handleParam($this->param); | ||
| 96 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 97 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 97 | $this->categoryEdit(); | 98 | $this->categoryEdit(); |
| 98 | }else{ | 99 | }else{ |
| @@ -102,6 +103,21 @@ class CustomModuleCategoryLogic extends BaseLogic | @@ -102,6 +103,21 @@ class CustomModuleCategoryLogic extends BaseLogic | ||
| 102 | } | 103 | } |
| 103 | 104 | ||
| 104 | /** | 105 | /** |
| 106 | + * @name :(参数处理)paramProcessing | ||
| 107 | + * @author :lyh | ||
| 108 | + * @method :post | ||
| 109 | + * @time :2023/6/13 11:30 | ||
| 110 | + */ | ||
| 111 | + public function handleParam($param) | ||
| 112 | + { | ||
| 113 | + $param['operator_id'] = $this->user['id']; | ||
| 114 | + if(!isset($param['id']) || empty($param['id'])){ | ||
| 115 | + $param['project_id'] = $this->user['project_id']; | ||
| 116 | + } | ||
| 117 | + return $this->success($param); | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + /** | ||
| 105 | * @remark :添加分类 | 121 | * @remark :添加分类 |
| 106 | * @name :categoryAdd | 122 | * @name :categoryAdd |
| 107 | * @author :lyh | 123 | * @author :lyh |
| @@ -116,7 +132,7 @@ class CustomModuleCategoryLogic extends BaseLogic | @@ -116,7 +132,7 @@ class CustomModuleCategoryLogic extends BaseLogic | ||
| 116 | $this->handleAddSon($id); | 132 | $this->handleAddSon($id); |
| 117 | $this->addUpdateNotify(RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'],$route); | 133 | $this->addUpdateNotify(RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'],$route); |
| 118 | $this->curlDelRoute(['new_route'=>$route]); | 134 | $this->curlDelRoute(['new_route'=>$route]); |
| 119 | - $this->edit(['url' => $route], ['id' => $id]); | 135 | + $this->edit(['route' => $route], ['id' => $id]); |
| 120 | //处理上级分类商品 | 136 | //处理上级分类商品 |
| 121 | $this->handleAddSon($id); | 137 | $this->handleAddSon($id); |
| 122 | }catch (\Exception $e){ | 138 | }catch (\Exception $e){ |
| @@ -136,7 +152,7 @@ class CustomModuleCategoryLogic extends BaseLogic | @@ -136,7 +152,7 @@ class CustomModuleCategoryLogic extends BaseLogic | ||
| 136 | $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'], | 152 | $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'], |
| 137 | $this->param['id'], $this->user['project_id']); | 153 | $this->param['id'], $this->user['project_id']); |
| 138 | $this->editHandleCategory($this->param['id'],$this->param['pid']); | 154 | $this->editHandleCategory($this->param['id'],$this->param['pid']); |
| 139 | - $this->editNewsRoute($this->param['id'],$route); | 155 | + $this->editRoute($this->param['id'],$route); |
| 140 | $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | 156 | $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); |
| 141 | if($rs === false){ | 157 | if($rs === false){ |
| 142 | $this->fail('系统错误,请连续管理员'); | 158 | $this->fail('系统错误,请连续管理员'); |
| @@ -193,7 +209,7 @@ class CustomModuleCategoryLogic extends BaseLogic | @@ -193,7 +209,7 @@ class CustomModuleCategoryLogic extends BaseLogic | ||
| 193 | * @method :post | 209 | * @method :post |
| 194 | * @time :2023/9/7 11:05 | 210 | * @time :2023/9/7 11:05 |
| 195 | */ | 211 | */ |
| 196 | - public function editNewsRoute($id, $route) | 212 | + public function editRoute($id, $route) |
| 197 | { | 213 | { |
| 198 | //生成一条删除路由记录 | 214 | //生成一条删除路由记录 |
| 199 | $info = $this->model->read(['id' => $id], ['id', 'route']); | 215 | $info = $this->model->read(['id' => $id], ['id', 'route']); |
| @@ -10,7 +10,15 @@ | @@ -10,7 +10,15 @@ | ||
| 10 | namespace App\Http\Logic\Bside\CustomModule; | 10 | 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\CustomModuleContent; | 14 | use App\Models\CustomModule\CustomModuleContent; |
| 15 | +use App\Models\CustomModule\CustomModuleExtend; | ||
| 16 | +use App\Models\CustomModule\CustomModuleExtentContent; | ||
| 17 | +use App\Models\Product\Extend; | ||
| 18 | +use App\Models\Product\ExtendInfo; | ||
| 19 | +use App\Models\RouteMap\RouteMap; | ||
| 20 | +use Illuminate\Support\Facades\DB; | ||
| 21 | +use mysql_xdevapi\Exception; | ||
| 14 | 22 | ||
| 15 | class CustomModuleContentLogic extends BaseLogic | 23 | class CustomModuleContentLogic extends BaseLogic |
| 16 | { | 24 | { |
| @@ -28,23 +36,253 @@ class CustomModuleContentLogic extends BaseLogic | @@ -28,23 +36,253 @@ class CustomModuleContentLogic extends BaseLogic | ||
| 28 | * @method :post | 36 | * @method :post |
| 29 | * @time :2023/12/4 16:10 | 37 | * @time :2023/12/4 16:10 |
| 30 | */ | 38 | */ |
| 31 | - public function getCustomModuleContentInfo(){ | 39 | + public function getContentInfo(){ |
| 32 | $info = $this->model->read($this->param); | 40 | $info = $this->model->read($this->param); |
| 33 | if($info === false){ | 41 | if($info === false){ |
| 34 | $this->fail('当前数据不存在或已被删除'); | 42 | $this->fail('当前数据不存在或已被删除'); |
| 35 | } | 43 | } |
| 44 | + $info['extend'] = $this->getExtendInfo($info['module_id'],$info['id']); | ||
| 36 | return $this->success($info); | 45 | return $this->success($info); |
| 37 | } | 46 | } |
| 38 | 47 | ||
| 39 | /** | 48 | /** |
| 49 | + * @remark :获取扩展字段详情 | ||
| 50 | + * @name :getExtendInfo | ||
| 51 | + * @author :lyh | ||
| 52 | + * @method :post | ||
| 53 | + * @time :2023/11/14 9:45 | ||
| 54 | + */ | ||
| 55 | + public function getExtendInfo($module_id,$content_id){ | ||
| 56 | + $extendModel = new CustomModuleExtend(); | ||
| 57 | + $list = $extendModel->list(['module_id'=>$module_id],'id',['id','type','key','title']); | ||
| 58 | + if(empty($list)){ | ||
| 59 | + return []; | ||
| 60 | + } | ||
| 61 | + $extendContentModel = new CustomModuleExtentContent(); | ||
| 62 | + foreach ($list as $k=>$v){ | ||
| 63 | + $info = $extendContentModel->read(['key'=>$v['key'],'content_id'=>$content_id]); | ||
| 64 | + if($info == false){ | ||
| 65 | + if($v['type'] == 3 || $v['type'] == 4){ | ||
| 66 | + $v['values'] = []; | ||
| 67 | + }else{ | ||
| 68 | + $v['values'] = ''; | ||
| 69 | + } | ||
| 70 | + }else{ | ||
| 71 | + $v = $this->setTypValues($v,$info); | ||
| 72 | + } | ||
| 73 | + $list[$k] = $v; | ||
| 74 | + } | ||
| 75 | + return $this->success($list); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + /** | ||
| 79 | + * @remark :扩展字段根据type返回类型 | ||
| 80 | + * @name :setTypValues | ||
| 81 | + * @author :lyh | ||
| 82 | + * @method :post | ||
| 83 | + * @time :2023/12/6 14:43 | ||
| 84 | + */ | ||
| 85 | + public function setTypValues($v,$info){ | ||
| 86 | + if($v['type'] == 3){ | ||
| 87 | + $arr = json_decode($info['values']); | ||
| 88 | + foreach ($arr as $k1=>$v1){ | ||
| 89 | + $v1 = (array)$v1; | ||
| 90 | + $v1['url'] = getImageUrl($v1['url']); | ||
| 91 | + $arr[$k1] = $v1; | ||
| 92 | + } | ||
| 93 | + $v['values'] = $arr; | ||
| 94 | + }elseif($v['type'] == 4){ | ||
| 95 | + $arr1 = json_decode($info['values']); | ||
| 96 | + foreach ($arr1 as $k1=>$v1){ | ||
| 97 | + $v1 = getFileUrl($v1); | ||
| 98 | + $arr1[$k1] = $v1; | ||
| 99 | + } | ||
| 100 | + $v['values'] = $arr1; | ||
| 101 | + }else{ | ||
| 102 | + $v['values'] = $info['values']; | ||
| 103 | + } | ||
| 104 | + return $this->success($v); | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + /** | ||
| 40 | * @remark :保存数据 | 108 | * @remark :保存数据 |
| 41 | * @name :ModuleSave | 109 | * @name :ModuleSave |
| 42 | * @author :lyh | 110 | * @author :lyh |
| 43 | * @method :post | 111 | * @method :post |
| 44 | * @time :2023/12/4 15:47 | 112 | * @time :2023/12/4 15:47 |
| 45 | */ | 113 | */ |
| 46 | - public function customModuleContentSave(){ | 114 | + public function contentSave(){ |
| 115 | + $extend = $this->handleExtent(); | ||
| 116 | + $this->param = $this->handleParam($this->param); | ||
| 117 | + if(isset($this->param['id']) && !empty($this->param['id'])){ | ||
| 118 | + $id = $this->contentEdit(); | ||
| 119 | + }else{ | ||
| 120 | + $id = $this->contentAdd(); | ||
| 121 | + } | ||
| 122 | + //保存扩展字段 | ||
| 123 | + $this->saveExtendInfo($id,$extend); | ||
| 124 | + return $this->success(); | ||
| 125 | + } | ||
| 126 | + | ||
| 127 | + /** | ||
| 128 | + * @remark :处理扩展字段 | ||
| 129 | + * @name :handleExtent | ||
| 130 | + * @author :lyh | ||
| 131 | + * @method :post | ||
| 132 | + * @time :2023/12/6 15:06 | ||
| 133 | + */ | ||
| 134 | + public function handleExtent(){ | ||
| 135 | + //扩展字段 | ||
| 136 | + $extend = []; | ||
| 137 | + if(!empty($this->param['extend'])){ | ||
| 138 | + $extend = $this->param['extend']; | ||
| 139 | + unset($this->param['extend']); | ||
| 140 | + } | ||
| 141 | + return $extend; | ||
| 142 | + } | ||
| 143 | + | ||
| 144 | + /** | ||
| 145 | + * @remark :添加数据 | ||
| 146 | + * @name :contentAdd | ||
| 147 | + * @author :lyh | ||
| 148 | + * @method :post | ||
| 149 | + * @time :2023/12/7 15:04 | ||
| 150 | + */ | ||
| 151 | + public function contentAdd(){ | ||
| 152 | + try { | ||
| 153 | + $id = $this->model->addReturnId($this->param); | ||
| 154 | + $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE.$this->param['module_id'], | ||
| 155 | + $id, $this->user['project_id']); | ||
| 156 | + $this->addUpdateNotify(RouteMap::SOURCE_MODULE.$this->param['module_id'],$route); | ||
| 157 | + $this->curlDelRoute(['new_route'=>$route]); | ||
| 158 | + $this->edit(['route' => $route], ['id' => $id]); | ||
| 159 | + }catch (\Exception $e){ | ||
| 160 | + $this->fail('系统错误,请联系管理员'); | ||
| 161 | + } | ||
| 162 | + return $id; | ||
| 163 | + } | ||
| 164 | + | ||
| 165 | + /** | ||
| 166 | + * @remark :编辑数据 | ||
| 167 | + * @name :contentEdit | ||
| 168 | + * @author :lyh | ||
| 169 | + * @method :post | ||
| 170 | + * @time :2023/12/7 15:04 | ||
| 171 | + */ | ||
| 172 | + public function contentEdit(){ | ||
| 173 | + $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE.$this->param['module_id'], | ||
| 174 | + $this->param['id'], $this->user['project_id']); | ||
| 175 | + $this->editRoute($this->param['id'],$route); | ||
| 176 | + $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 177 | + if($rs === false){ | ||
| 178 | + $this->fail('系统错误,请连续管理员'); | ||
| 179 | + } | ||
| 180 | + return $this->param['id']; | ||
| 181 | + } | ||
| 182 | + | ||
| 183 | + /** | ||
| 184 | + * @name :(参数处理)paramProcessing | ||
| 185 | + * @author :lyh | ||
| 186 | + * @method :post | ||
| 187 | + * @time :2023/6/13 11:30 | ||
| 188 | + */ | ||
| 189 | + public function handleParam($param) | ||
| 190 | + { | ||
| 191 | + $param['operator_id'] = $this->user['id']; | ||
| 192 | + if(!isset($param['id']) || empty($param['id'])){ | ||
| 193 | + $param['project_id'] = $this->user['project_id']; | ||
| 194 | + } | ||
| 195 | + if(isset($param['category_id']) && !empty($param['category_id'])){ | ||
| 196 | + $param['category_id'] = $this->getLastCategory($param['category_id']); | ||
| 197 | + } | ||
| 198 | + return $this->success($param); | ||
| 199 | + } | ||
| 47 | 200 | ||
| 201 | + /** | ||
| 202 | + * @remark :查看是否编辑路由 | ||
| 203 | + * @name :editCategoryRoute | ||
| 204 | + * @author :lyh | ||
| 205 | + * @method :post | ||
| 206 | + * @time :2023/9/7 11:05 | ||
| 207 | + */ | ||
| 208 | + public function editRoute($id, $route) | ||
| 209 | + { | ||
| 210 | + //生成一条删除路由记录 | ||
| 211 | + $info = $this->model->read(['id' => $id], ['id', 'route']); | ||
| 212 | + if ($info['route'] != $route) { | ||
| 213 | + $this->addUpdateNotify(RouteMap::SOURCE_MODULE.$this->param['module_id'],$route); | ||
| 214 | + $this->curlDelRoute(['route'=>$info['route'],'new_route'=>$route]); | ||
| 215 | + } | ||
| 216 | + return true; | ||
| 217 | + } | ||
| 218 | + | ||
| 219 | + /** | ||
| 220 | + * @remark :获取最后一级分类id | ||
| 221 | + * @name :getLastCategory | ||
| 222 | + * @author :lyh | ||
| 223 | + * @method :post | ||
| 224 | + * @time :2023/10/20 9:02 | ||
| 225 | + */ | ||
| 226 | + public function getLastCategory($category){ | ||
| 227 | + $str = ''; | ||
| 228 | + $cateModel = new CustomModuleCategory(); | ||
| 229 | + foreach ($category as $v){ | ||
| 230 | + $info = $cateModel->read(['pid'=>$v]); | ||
| 231 | + if($info === false){ | ||
| 232 | + $str .= $v.','; | ||
| 233 | + } | ||
| 234 | + } | ||
| 235 | + return ','.$str; | ||
| 236 | + } | ||
| 237 | + | ||
| 238 | + /** | ||
| 239 | + * @remark :保存扩展字段 | ||
| 240 | + * @name :saveExtend | ||
| 241 | + * @author :lyh | ||
| 242 | + * @method :post | ||
| 243 | + * @time :2023/11/9 15:02 | ||
| 244 | + */ | ||
| 245 | + public function saveExtendInfo($content_id,$extend){ | ||
| 246 | + //先删除以前的数据 | ||
| 247 | + $extendInfoModel = new ExtendInfo(); | ||
| 248 | + $extendInfoModel->del(['content_id'=>$content_id]); | ||
| 249 | + if(empty($extend)) { | ||
| 250 | + return $this->success(); | ||
| 251 | + } | ||
| 252 | + foreach ($extend as $v){ | ||
| 253 | + if(empty($v['values'])){ | ||
| 254 | + continue; | ||
| 255 | + } | ||
| 256 | + $v = $this->saveHandleExtend($v,$content_id); | ||
| 257 | + $extendInfoModel->add($v); | ||
| 258 | + } | ||
| 259 | + return $this->success(); | ||
| 260 | + } | ||
| 261 | + | ||
| 262 | + /** | ||
| 263 | + * @remark :保存扩展字段时处理数据 | ||
| 264 | + * @name :saveHandleExtend | ||
| 265 | + * @author :lyh | ||
| 266 | + * @method :post | ||
| 267 | + * @time :2023/12/6 15:11 | ||
| 268 | + */ | ||
| 269 | + public function saveHandleExtend(&$v,$content_id){ | ||
| 270 | + if($v['type'] == 3){ | ||
| 271 | + foreach ($v['values'] as $k1=>$v1){ | ||
| 272 | + $v1['url'] = str_replace_url($v1['url']); | ||
| 273 | + $v['values'][$k1] = $v1; | ||
| 274 | + } | ||
| 275 | + $v['values'] = json_encode($v['values']); | ||
| 276 | + }elseif ($v['type'] == 4){ | ||
| 277 | + foreach ($v['values'] as $k1=>$v1){ | ||
| 278 | + $v1 = str_replace_url($v1); | ||
| 279 | + $v['values'][$k1] = $v1; | ||
| 280 | + } | ||
| 281 | + $v['values'] = json_encode($v['values']); | ||
| 282 | + } | ||
| 283 | + $v['project_id'] = $this->user['project_id']; | ||
| 284 | + $v['content_id'] = $content_id; | ||
| 285 | + return $this->success($v); | ||
| 48 | } | 286 | } |
| 49 | 287 | ||
| 50 | /** | 288 | /** |
| @@ -54,7 +292,34 @@ class CustomModuleContentLogic extends BaseLogic | @@ -54,7 +292,34 @@ class CustomModuleContentLogic extends BaseLogic | ||
| 54 | * @method :post | 292 | * @method :post |
| 55 | * @time :2023/12/4 15:47 | 293 | * @time :2023/12/4 15:47 |
| 56 | */ | 294 | */ |
| 57 | - public function customModuleContentDel(){ | 295 | + public function contentDel(){ |
| 296 | + DB::beginTransaction(); | ||
| 297 | + try { | ||
| 298 | + foreach ($this->param['id'] as $id) { | ||
| 299 | + $this->delRoute($id); | ||
| 300 | + $this->model->del(['id' => $id]); | ||
| 301 | + } | ||
| 302 | + DB::commit(); | ||
| 303 | + } catch (Exception $e) { | ||
| 304 | + DB::rollBack(); | ||
| 305 | + $this->fail('系统错误,请联系管理员'); | ||
| 306 | + } | ||
| 307 | + return $this->success(); | ||
| 308 | + } | ||
| 58 | 309 | ||
| 310 | + /** | ||
| 311 | + * @remark :删除路由 | ||
| 312 | + * @name :delRoute | ||
| 313 | + * @author :lyh | ||
| 314 | + * @method :post | ||
| 315 | + * @time :2023/9/7 10:50 | ||
| 316 | + */ | ||
| 317 | + public function delRoute($id) | ||
| 318 | + { | ||
| 319 | + RouteMap::delRoute(RouteMap::SOURCE_MODULE.$this->param['module_id'], $id, $this->user['project_id']); | ||
| 320 | + //通知 | ||
| 321 | + $info = $this->model->read(['id' => $id], ['id', 'url']); | ||
| 322 | + $this->curlDelRoute(['route'=>$info['url']]); | ||
| 323 | + return $this->success(); | ||
| 59 | } | 324 | } |
| 60 | } | 325 | } |
| @@ -28,8 +28,12 @@ class CustomModuleExtendLogic extends BaseLogic | @@ -28,8 +28,12 @@ class CustomModuleExtendLogic extends BaseLogic | ||
| 28 | * @method :post | 28 | * @method :post |
| 29 | * @time :2023/12/4 16:10 | 29 | * @time :2023/12/4 16:10 |
| 30 | */ | 30 | */ |
| 31 | - public function getCustomModuleExtendInfo(){ | ||
| 32 | - | 31 | + public function getExtendInfo(){ |
| 32 | + $info = $this->model->read($this->param,['id','title','status','type','operator_id','project_id','module_id']); | ||
| 33 | + if($info === false){ | ||
| 34 | + $this->fail('当前数据不存在或者已被删除'); | ||
| 35 | + } | ||
| 36 | + return $this->success($info); | ||
| 33 | } | 37 | } |
| 34 | 38 | ||
| 35 | /** | 39 | /** |
| @@ -39,8 +43,68 @@ class CustomModuleExtendLogic extends BaseLogic | @@ -39,8 +43,68 @@ class CustomModuleExtendLogic extends BaseLogic | ||
| 39 | * @method :post | 43 | * @method :post |
| 40 | * @time :2023/12/4 15:47 | 44 | * @time :2023/12/4 15:47 |
| 41 | */ | 45 | */ |
| 42 | - public function customModuleExtendSave(){ | 46 | + public function extendSave(){ |
| 47 | + if(isset($this->param['id']) && !empty($this->param['id'])){ | ||
| 48 | + $this->extendEdit(); | ||
| 49 | + }else{ | ||
| 50 | + $this->extendAdd(); | ||
| 51 | + } | ||
| 52 | + return $this->success(); | ||
| 53 | + } | ||
| 43 | 54 | ||
| 55 | + /** | ||
| 56 | + * @remark :添加 | ||
| 57 | + * @name :extendAdd | ||
| 58 | + * @author :lyh | ||
| 59 | + * @method :post | ||
| 60 | + * @time :2023/12/7 14:09 | ||
| 61 | + */ | ||
| 62 | + public function extendAdd(){ | ||
| 63 | + $info = $this->model->read(['title'=>$this->param['title']]); | ||
| 64 | + if($info !== false){ | ||
| 65 | + $this->fail('当前扩展名称已存在'); | ||
| 66 | + } | ||
| 67 | + $key = 'pd_extended_field_'; | ||
| 68 | + $this->param['key'] = $this->getKey($key); | ||
| 69 | + $this->param['project_id'] = $this->user['project_id']; | ||
| 70 | + $this->param['operator_id'] = $this->user['id']; | ||
| 71 | + $rs = $this->model->add($this->param); | ||
| 72 | + if($rs === false){ | ||
| 73 | + $this->fail('系统错误,请联系管理员'); | ||
| 74 | + } | ||
| 75 | + return $this->success(); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + /** | ||
| 79 | + * @remark :获取唯一key | ||
| 80 | + * @name :getKey | ||
| 81 | + * @author :lyh | ||
| 82 | + * @method :post | ||
| 83 | + * @time :2023/11/9 15:55 | ||
| 84 | + */ | ||
| 85 | + public function getKey($key,$i = 1){ | ||
| 86 | + $info = $this->model->read(['key'=>$key.$i]); | ||
| 87 | + if($info !== false){ | ||
| 88 | + return $this->getKey($key,$i+1); | ||
| 89 | + }else{ | ||
| 90 | + return $key.$i; | ||
| 91 | + } | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + /** | ||
| 95 | + * @remark :编辑 | ||
| 96 | + * @name :extendEdit | ||
| 97 | + * @author :lyh | ||
| 98 | + * @method :post | ||
| 99 | + * @time :2023/12/7 14:09 | ||
| 100 | + */ | ||
| 101 | + public function extendEdit(){ | ||
| 102 | + $this->param['operator_id'] = $this->user['id']; | ||
| 103 | + $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 104 | + if($rs === false){ | ||
| 105 | + $this->fail('系统错误,请联系管理员'); | ||
| 106 | + } | ||
| 107 | + return $this->success(); | ||
| 44 | } | 108 | } |
| 45 | 109 | ||
| 46 | /** | 110 | /** |
| @@ -50,7 +114,11 @@ class CustomModuleExtendLogic extends BaseLogic | @@ -50,7 +114,11 @@ class CustomModuleExtendLogic extends BaseLogic | ||
| 50 | * @method :post | 114 | * @method :post |
| 51 | * @time :2023/12/4 15:47 | 115 | * @time :2023/12/4 15:47 |
| 52 | */ | 116 | */ |
| 53 | - public function customModuleExtendDel(){ | ||
| 54 | - | 117 | + public function extendDel(){ |
| 118 | + $rs = $this->model->del($this->param); | ||
| 119 | + if($rs === false){ | ||
| 120 | + $this->fail('系统错误,请联系管理员'); | ||
| 121 | + } | ||
| 122 | + return $this->success(); | ||
| 55 | } | 123 | } |
| 56 | } | 124 | } |
| @@ -46,6 +46,7 @@ class CustomModuleLogic extends BaseLogic | @@ -46,6 +46,7 @@ class CustomModuleLogic extends BaseLogic | ||
| 46 | * @time :2023/12/4 15:47 | 46 | * @time :2023/12/4 15:47 |
| 47 | */ | 47 | */ |
| 48 | public function customModuleSave(){ | 48 | public function customModuleSave(){ |
| 49 | + $this->param = $this->handleParam($this->param); | ||
| 49 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 50 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 50 | $this->moduleEdit(); | 51 | $this->moduleEdit(); |
| 51 | }else{ | 52 | }else{ |
| @@ -55,6 +56,21 @@ class CustomModuleLogic extends BaseLogic | @@ -55,6 +56,21 @@ class CustomModuleLogic extends BaseLogic | ||
| 55 | } | 56 | } |
| 56 | 57 | ||
| 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->user['id']; | ||
| 67 | + if(!isset($param['id']) || empty($param['id'])){ | ||
| 68 | + $param['project_id'] = $this->user['project_id']; | ||
| 69 | + } | ||
| 70 | + return $this->success($param); | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + /** | ||
| 58 | * @remark :新增 | 74 | * @remark :新增 |
| 59 | * @name :moduleAdd | 75 | * @name :moduleAdd |
| 60 | * @author :lyh | 76 | * @author :lyh |
| @@ -62,7 +78,6 @@ class CustomModuleLogic extends BaseLogic | @@ -62,7 +78,6 @@ class CustomModuleLogic extends BaseLogic | ||
| 62 | * @time :2023/12/5 9:39 | 78 | * @time :2023/12/5 9:39 |
| 63 | */ | 79 | */ |
| 64 | public function moduleAdd(){ | 80 | public function moduleAdd(){ |
| 65 | - $this->param['project_id'] = $this->user['project_id']; | ||
| 66 | $rs = $this->model->add($this->param); | 81 | $rs = $this->model->add($this->param); |
| 67 | if($rs === false){ | 82 | if($rs === false){ |
| 68 | $this->fail('系统错误,请联系管理员'); | 83 | $this->fail('系统错误,请联系管理员'); |
| @@ -106,6 +106,7 @@ class ProductLogic extends BaseLogic | @@ -106,6 +106,7 @@ class ProductLogic extends BaseLogic | ||
| 106 | } | 106 | } |
| 107 | return $category_ids; | 107 | return $category_ids; |
| 108 | } | 108 | } |
| 109 | + | ||
| 109 | /** | 110 | /** |
| 110 | * @remark :新增时处理字段 | 111 | * @remark :新增时处理字段 |
| 111 | * @name :addHandleParam | 112 | * @name :addHandleParam |
| @@ -9,6 +9,7 @@ | @@ -9,6 +9,7 @@ | ||
| 9 | 9 | ||
| 10 | namespace App\Models\CustomModule; | 10 | namespace App\Models\CustomModule; |
| 11 | 11 | ||
| 12 | +use App\Helper\Arr; | ||
| 12 | use App\Models\Base; | 13 | use App\Models\Base; |
| 13 | 14 | ||
| 14 | class CustomModuleContent extends Base | 15 | class CustomModuleContent extends Base |
| @@ -16,4 +17,8 @@ class CustomModuleContent extends Base | @@ -16,4 +17,8 @@ class CustomModuleContent extends Base | ||
| 16 | protected $table = 'gl_custom_module_content'; | 17 | protected $table = 'gl_custom_module_content'; |
| 17 | //连接数据库 | 18 | //连接数据库 |
| 18 | protected $connection = 'custom_mysql'; | 19 | protected $connection = 'custom_mysql'; |
| 20 | + | ||
| 21 | + public function getCategoryIdAttribute($value){ | ||
| 22 | + return Arr::setToArr(trim($value,',')); | ||
| 23 | + } | ||
| 19 | } | 24 | } |
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :CustomModuleExtentContent.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2023/12/7 14:38 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Models\CustomModule; | ||
| 11 | + | ||
| 12 | +use App\Models\Base; | ||
| 13 | + | ||
| 14 | +class CustomModuleExtentContent extends Base | ||
| 15 | +{ | ||
| 16 | + protected $table = 'gl_custom_module_extent_content'; | ||
| 17 | + //连接数据库 | ||
| 18 | + protected $connection = 'custom_mysql'; | ||
| 19 | +} |
| @@ -440,10 +440,18 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -440,10 +440,18 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 440 | 440 | ||
| 441 | Route::prefix('content')->group(function () { | 441 | Route::prefix('content')->group(function () { |
| 442 | Route::any('/', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'lists'])->name('custom_content_lists'); | 442 | Route::any('/', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'lists'])->name('custom_content_lists'); |
| 443 | + Route::any('/getCategoryList', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'getCategoryList'])->name('custom_content_getCategoryList'); | ||
| 443 | Route::any('/info', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'info'])->name('custom_content_info'); | 444 | Route::any('/info', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'info'])->name('custom_content_info'); |
| 444 | Route::any('/save', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'save'])->name('custom_content_save'); | 445 | Route::any('/save', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'save'])->name('custom_content_save'); |
| 445 | Route::any('/del', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'del'])->name('custom_content_del'); | 446 | Route::any('/del', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'del'])->name('custom_content_del'); |
| 446 | }); | 447 | }); |
| 448 | + | ||
| 449 | + Route::prefix('extend')->group(function () { | ||
| 450 | + Route::any('/', [\App\Http\Controllers\Bside\CustomModule\CustomModuleExtentController::class, 'lists'])->name('custom_extend_lists'); | ||
| 451 | + Route::any('/info', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'info'])->name('custom_extend_info'); | ||
| 452 | + Route::any('/save', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'save'])->name('custom_extend_save'); | ||
| 453 | + Route::any('/del', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'del'])->name('custom_extend_del'); | ||
| 454 | + }); | ||
| 447 | }); | 455 | }); |
| 448 | }); | 456 | }); |
| 449 | //无需登录验证的路由组 | 457 | //无需登录验证的路由组 |
-
请 注册 或 登录 后发表评论