This commit is contained in:
weiz 2024-03-04 14:32:43 +08:00
parent 9937c217a2
commit 7bb9aea11d
2 changed files with 21 additions and 0 deletions

View File

@ -76,6 +76,22 @@ class MaterialClassifyController extends BaseAdminController
}
return $this->fail(MaterialClassifyLogic::getError());
}
/**
* @notes 删除工料分类
* @return \think\response\Json
* @author likeadmin
* @date 2024/03/04 14:00
*/
public function delete()
{
$params = (new MaterialClassifyValidate())->post()->goCheck('delete');
$result = MaterialClassifyLogic::delete($params);
if (true === $result) {
return $this->success('删除成功', [], 1, 1);
}
return $this->fail(MaterialClassifyLogic::getError());
}
/**

View File

@ -89,6 +89,11 @@ class MaterialClassifyLogic extends BaseLogic
*/
public static function delete(array $params): bool
{
$data = MaterialClassify::where('pid',$params['id'])->findOrEmpty();
if(!$data->isEmpty()){
self::setError('当前分类下存在子分类,须先删除子分类');
return false;
}
return MaterialClassify::destroy($params['id']);
}