|
@@ -135,6 +135,7 @@ class CustomModuleCategoryLogic extends BaseLogic |
|
@@ -135,6 +135,7 @@ class CustomModuleCategoryLogic extends BaseLogic |
|
135
|
public function categoryEdit(){
|
135
|
public function categoryEdit(){
|
|
136
|
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'],
|
136
|
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'],
|
|
137
|
$this->param['id'], $this->user['project_id']);
|
137
|
$this->param['id'], $this->user['project_id']);
|
|
|
|
138
|
+ $this->editHandleCategory($this->param['id'],$this->param['pid']);
|
|
138
|
$this->editNewsRoute($this->param['id'],$route);
|
139
|
$this->editNewsRoute($this->param['id'],$route);
|
|
139
|
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
|
140
|
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
|
|
140
|
if($rs === false){
|
141
|
if($rs === false){
|
|
@@ -153,12 +154,12 @@ class CustomModuleCategoryLogic extends BaseLogic |
|
@@ -153,12 +154,12 @@ class CustomModuleCategoryLogic extends BaseLogic |
|
153
|
public function editHandleCategory($id,$pid){
|
154
|
public function editHandleCategory($id,$pid){
|
|
154
|
$info = $this->model->read(['id'=>$id],['id','pid']);
|
155
|
$info = $this->model->read(['id'=>$id],['id','pid']);
|
|
155
|
if($info['pid'] != $pid){
|
156
|
if($info['pid'] != $pid){
|
|
156
|
- //修改勒上级,先查看上级是否拥有博客
|
157
|
+ //修改勒上级,先查看上级是否拥有产品
|
|
157
|
$contentModel = new CustomModuleContent();
|
158
|
$contentModel = new CustomModuleContent();
|
|
158
|
- $newsCount = $contentModel->formatQuery(['category_id'=>['like','%,'.$pid.',%']])->count();
|
159
|
+ $contentCount = $contentModel->formatQuery(['category_id'=>['like','%,'.$pid.',%']])->count();
|
|
|
|
160
|
+ if($contentCount > 0){
|
|
159
|
//随机获取最后一级id
|
161
|
//随机获取最后一级id
|
|
160
|
$replacement = $this->getLastId($id);
|
162
|
$replacement = $this->getLastId($id);
|
|
161
|
- if($newsCount > 0){
|
|
|
|
162
|
//存在博客时,移动所有博客到当前分类最后一级
|
163
|
//存在博客时,移动所有博客到当前分类最后一级
|
|
163
|
$contentModel->where('category_id', 'like', '%,' . $pid . ',%')->where('category_id', 'like', '%,' . $replacement . ',%')
|
164
|
$contentModel->where('category_id', 'like', '%,' . $pid . ',%')->where('category_id', 'like', '%,' . $replacement . ',%')
|
|
164
|
->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',')")]);
|
165
|
->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',')")]);
|
|
@@ -170,6 +171,22 @@ class CustomModuleCategoryLogic extends BaseLogic |
|
@@ -170,6 +171,22 @@ class CustomModuleCategoryLogic extends BaseLogic |
|
170
|
}
|
171
|
}
|
|
171
|
|
172
|
|
|
172
|
/**
|
173
|
/**
|
|
|
|
174
|
+ * @remark :随机获取当前id下最后一级的id
|
|
|
|
175
|
+ * @name :getLastId
|
|
|
|
176
|
+ * @author :lyh
|
|
|
|
177
|
+ * @method :post
|
|
|
|
178
|
+ * @time :2023/10/20 9:45
|
|
|
|
179
|
+ */
|
|
|
|
180
|
+ public function getLastId($id){
|
|
|
|
181
|
+ $info = $this->model->read(['pid'=>$id],['id']);
|
|
|
|
182
|
+ if($info !== false){
|
|
|
|
183
|
+ return $this->getLastId($info['id']);
|
|
|
|
184
|
+ }else{
|
|
|
|
185
|
+ return $id;
|
|
|
|
186
|
+ }
|
|
|
|
187
|
+ }
|
|
|
|
188
|
+
|
|
|
|
189
|
+ /**
|
|
173
|
* @remark :查看是否编辑路由
|
190
|
* @remark :查看是否编辑路由
|
|
174
|
* @name :editCategoryRoute
|
191
|
* @name :editCategoryRoute
|
|
175
|
* @author :lyh
|
192
|
* @author :lyh
|