|
...
|
...
|
@@ -11,6 +11,7 @@ namespace App\Http\Logic\Bside\CustomModule; |
|
|
|
|
|
|
|
use App\Http\Logic\Bside\BaseLogic;
|
|
|
|
use App\Models\CustomModule\CustomModuleCategory;
|
|
|
|
use App\Models\CustomModule\CustomModuleContent;
|
|
|
|
use App\Models\RouteMap\RouteMap;
|
|
|
|
|
|
|
|
class CustomModuleCategoryLogic extends BaseLogic
|
|
...
|
...
|
@@ -41,7 +42,7 @@ class CustomModuleCategoryLogic extends BaseLogic |
|
|
|
$menu = array();
|
|
|
|
$list = $this->model->list($this->param);
|
|
|
|
if(!empty($list)){
|
|
|
|
foreach ($list as $k => $v){
|
|
|
|
foreach ($list as $v){
|
|
|
|
if($v['pid'] == 0){
|
|
|
|
$v['sub'] = _get_child($v['id'],$list);
|
|
|
|
$menu[] = $v;
|
|
...
|
...
|
@@ -110,7 +111,9 @@ class CustomModuleCategoryLogic extends BaseLogic |
|
|
|
public function categoryAdd(){
|
|
|
|
try {
|
|
|
|
$id = $this->model->addReturnId($this->param);
|
|
|
|
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'], $id, $this->user['project_id']);
|
|
|
|
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'],
|
|
|
|
$id, $this->user['project_id']);
|
|
|
|
$this->handleAddSon($id);
|
|
|
|
$this->addUpdateNotify(RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'],$route);
|
|
|
|
$this->edit(['url' => $route], ['id' => $id]);
|
|
|
|
}catch (\Exception $e){
|
|
...
|
...
|
@@ -127,7 +130,8 @@ class CustomModuleCategoryLogic extends BaseLogic |
|
|
|
* @time :2023/12/5 10:55
|
|
|
|
*/
|
|
|
|
public function categoryEdit(){
|
|
|
|
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'], $this->param['id'], $this->user['project_id']);
|
|
|
|
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'],
|
|
|
|
$this->param['id'], $this->user['project_id']);
|
|
|
|
$this->editNewsRoute($this->param['id'],$route);
|
|
|
|
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
|
|
|
|
if($rs === false){
|
|
...
|
...
|
@@ -160,24 +164,23 @@ class CustomModuleCategoryLogic extends BaseLogic |
|
|
|
* @method :post
|
|
|
|
* @time :2023/6/13 11:34
|
|
|
|
*/
|
|
|
|
public function addProcessingSon($cate_id){
|
|
|
|
public function handleAddSon($cate_id){
|
|
|
|
if(isset($this->param['pid']) && !empty($this->param['pid'])) {
|
|
|
|
$this->param['pid'] = 0;
|
|
|
|
}
|
|
|
|
//判断为子分类时
|
|
|
|
if($this->param['pid'] != 0) {
|
|
|
|
//查看当前上级分类下是否有其他分类
|
|
|
|
$cate_info = $this->model->read(['pid' => $this->param['pid'], 'id' => ['!=', $cate_id]]);
|
|
|
|
$cate_info = $this->model->read(['pid' => $this->param['pid'], 'id' => ['!=', $cate_id]],['id']);
|
|
|
|
if ($cate_info === false) {
|
|
|
|
//查看当前上一级分类下是否有关联模块内容
|
|
|
|
$newsModel = new NewsModel();
|
|
|
|
$news_count = $newsModel->where('category_id','like', '%,' . $this->param['pid'] . ',%')->count();
|
|
|
|
$contentModel = new CustomModuleContent();
|
|
|
|
$news_count = $contentModel->where('category_id','like', '%,' . $this->param['pid'] . ',%')->count();
|
|
|
|
if ($news_count > 0) {
|
|
|
|
$replacement = ',' . $cate_id . ',';
|
|
|
|
$old = ',' . $this->param['pid'] . ',';
|
|
|
|
$replacement = $this->handleStr($cate_id);
|
|
|
|
$old = $this->handleStr($this->param['pid']);
|
|
|
|
//更新所有商品到当前分类
|
|
|
|
$newsModel->where('category_id', 'like', '%' . $old . '%')
|
|
|
|
->update(['category_id' => DB::raw("REPLACE(category_id, '$old', '$replacement')")]);
|
|
|
|
$contentModel->where('category_id', 'like', '%' . $old . '%')->update(['category_id' => DB::raw("REPLACE(category_id, '$old', '$replacement')")]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
...
|
...
|
@@ -185,6 +188,17 @@ class CustomModuleCategoryLogic extends BaseLogic |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :处理字符串
|
|
|
|
* @name :handleStr
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/5 18:03
|
|
|
|
*/
|
|
|
|
public function handleStr($str){
|
|
|
|
return ',' . $str . ',';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :删除数据
|
|
|
|
* @name :ModuleDel
|
|
|
|
* @author :lyh
|
...
|
...
|
|