作者 lyh

gx

... ... @@ -41,12 +41,9 @@ class ProductController extends BaseController
public function index(Product $product)
{
$this->map = $this->searchParam();
$filed = ['id', 'project_id', 'title', 'sort' ,'thumb', 'gallery' ,'product_type' , 'route' ,
'category_id', 'keyword_id', 'status', 'created_uid', 'created_at', 'updated_at'];
$lists = $product->product_lists($this->map,$this->page,$this->row,$this->order = ['sort','id'],$filed);
if(!empty($lists) && !empty($lists['list'])){
$cate_data = $this->getCategoryList();//分类
$key_data = $this->getKeywordsList();//关键字
... ...
... ... @@ -96,7 +96,7 @@ class BlogCategoryLogic extends BaseLogic
}
//查询当前分类下是否有商品
$blogModel = new BlogModel();
$info = $blogModel->read(['id'=>['like','%,'.$id.',%']]);
$info = $blogModel->read(['id'=>['like','%,'.$id.',%']],['id']);
if($info !== false){
$this->fail('当前分类下已存在博客,请先把博客移除当前分类,在修改');
}
... ... @@ -160,7 +160,7 @@ class BlogCategoryLogic extends BaseLogic
}
//查看当前分内下是否有博客
$blogModel = new BlogModel();
$rs = $blogModel->read(['category_id'=>$id],['id']);
$rs = $blogModel->read(['category_id'=>['like','%,'.$id.',%']],['id']);
if($rs !== false){
$this->response('当前分类拥有博客,不允许删除');
}
... ...
... ... @@ -39,11 +39,11 @@ class NewsCategoryLogic extends BaseLogic
}
/**
* @name :详情
* @return array
* @throws \App\Exceptions\BsideGlobalException
* @author :liyuhang
* @method
* @remark :获取详情
* @name :info_news_category
* @author :lyh
* @method :post
* @time :2023/10/19 16:04
*/
public function info_news_category(){
$info = $this->model->read($this->param);
... ... @@ -118,9 +118,6 @@ class NewsCategoryLogic extends BaseLogic
*/
public function verifyEditParam($id,$pid){
$info = $this->model->read(['id'=>$id]);
if($info['id'] == $pid){
$this->fail('不能成为自己的上级');
}
if($info['pid'] != $pid){
$info = $this->model->read(['pid'=>$id]);
if($info !== false){
... ... @@ -166,7 +163,7 @@ class NewsCategoryLogic extends BaseLogic
$newsModel = new NewsModel();
$rs = $newsModel->read(['category_id'=>$id],['id']);
if($rs !== false){
$this->fail('当前分类拥有商品');
$this->fail('当前分类拥有商品,不允许删除');
}
$this->delRoute($id);
$this->model->del(['id'=>$id]);
... ... @@ -181,13 +178,44 @@ class NewsCategoryLogic extends BaseLogic
* @time :2023/6/13 9:09
*/
public function categoryTopList(){
$map = [
'project_id'=>$this->user['project_id'],
'pid'=>0,
'status'=>0,
];
$list = $this->model->list($map);
return $this->success($list);
$this->param['project_id'] = $this->user['project_id'];
$this->param['status'] = 0;
if(isset($this->param['id']) && !empty($this->param['id'])){
$str = [];
//排序掉当前id下所有子集
$str = $this->getAllSub($this->param['id'],$str);
$str[] = (int)$this->param['id'];
$this->param['id'] = ['not in',$str];
}
$menu = array();
$list = $this->model->list($this->param);
if(!empty($list)){
foreach ($list as $k => $v){
if($v['pid'] == 0){
$v['sub'] = _get_child($v['id'],$list);
$menu[] = $v;
}
}
}
return $this->success($menu);
}
/**
* @remark :获取当前id下所有子集
* @name :getAllSub
* @author :lyh
* @method :post
* @time :2023/10/18 15:10
*/
public function getAllSub($id,&$str = []){
$list = $this->model->list(['pid'=>$id,'status'=>0],['id','pid']);
if(!empty($list)){
foreach ($list as $v){
$str[] = $v['id'];
$this->getAllSub($v['id'],$str);
}
}
return $str;
}
/**
... ...
... ... @@ -66,10 +66,10 @@ class CategoryLogic extends BaseLogic
* @time :2023/8/21 17:14
*/
public function categorySave(){
$this->handleEditParam($this->param);
DB::beginTransaction();
try {
if(isset($this->param['id']) && !empty($this->param['id'])){
$this->handleEditParam($this->param);
//是否编辑路由
$id = $this->editCategoryRoute($this->param['id'],$this->param['route']);
$this->model->edit($this->param,['id'=>$this->param['id']]);
... ... @@ -125,6 +125,11 @@ class CategoryLogic extends BaseLogic
if(in_array($param['pid'], $category_ids)){
$this->fail('上级分类不能是本分类或子分类');
}
$productModel = new Product();
$rs = $productModel->read(['category_id'=>['like','%,'.$param['id'].',%']],['id']);
if($rs !== false){
$this->response('当前分类拥有产品,不允许修改级别');
}
return $this->success();
}
... ...