|
...
|
...
|
@@ -105,29 +105,13 @@ class NewsCategoryController extends BaseController |
|
|
|
* @author :liyuhang
|
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
public function del(Request $request,NewsCategoryModel $newsCategory,NewsModel $news){
|
|
|
|
public function del(Request $request,NewsCategoryLogic $newsCategoryLogic){
|
|
|
|
$request->validate([
|
|
|
|
'id'=>['required'],
|
|
|
|
],[
|
|
|
|
'id.required' => 'ID不能为空',
|
|
|
|
]);
|
|
|
|
foreach ($this->param['id'] as $v){
|
|
|
|
//查询是否有子分类
|
|
|
|
$rs = $newsCategory->read(['pid'=>$v],['id']);
|
|
|
|
if($rs !== false){
|
|
|
|
$this->response('当前分类拥有子分类不允许删除',Code::USER_ERROR);
|
|
|
|
}
|
|
|
|
//查看当前分内下是否有商品
|
|
|
|
$rs = $news->read(['category_id'=>$v],['id']);
|
|
|
|
if($rs !== false){
|
|
|
|
$this->response('当前分类拥有商品',Code::USER_ERROR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$this->param['id'] = ['in',$this->param['id']];
|
|
|
|
$rs = $newsCategory->del($this->param);
|
|
|
|
if($rs === false){
|
|
|
|
$this->response('error',Code::USER_ERROR);
|
|
|
|
}
|
|
|
|
$newsCategoryLogic->del_news_category();
|
|
|
|
$this->response('success');
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|