作者 lyh

gx

... ... @@ -43,7 +43,7 @@ class DeptController extends BaseController
public function save(DeptRequest $request, DeptLogic $logic)
{
$request->validated();
$logic->save($this->param);
$logic->deptSave();
$this->response('success');
}
... ...
... ... @@ -25,9 +25,28 @@ class BaseLogic extends Logic
public function __construct()
{
$this->request = request();
$this->requestAll = $this->request->all();
$this->requestAll = $this->getParam();
$this->manager = Cache::get(Common::MANAGE_TOKEN . $this->request->header('token'));
}
/**
* @remark :请求参数处理
* @name :getParam
* @author :lyh
* @method :post
* @time :2023/6/17 16:34
*/
public function getParam(){
$requestAll = $this->request->all();
foreach ($requestAll as $k => $v){
if(is_array($v)){
continue;
}else{
if(empty($v) && ($v != 0)){
unset($requestAll[$k]);
}
}
}
return $this->success($requestAll);
}
}
... ...
... ... @@ -17,23 +17,36 @@ class DeptLogic extends BaseLogic
public function __construct()
{
parent::__construct();
$this->param = $this->requestAll;
$this->model = new Dept();
}
public function save($param){
if(!empty($param['pid'])){
if(!empty($param['id']) && $param['pid'] == $param['id']){
$this->fail('上级部门不能是本部门');
}
$p_cate = $this->getCacheInfo($param['pid']);
if(!$p_cate){
$this->fail('上级部门不存在');
/**
* @remark :保存
* @name :save
* @author :lyh
* @method :post
* @time :2023/8/28 15:10
*/
public function deptSave(){
if(isset($this->param['id']) && !empty($this->param['id'])){
if($this->param['pid'] == $this->param['id']){
$this->fail('当前上级分类不能为自己');
}
$this->model->edit($this->param,['id'=>$this->param]);
}else{
$this->model->add($this->param);
}
return parent::save($param);
return $this->success();
}
/**
* @remark :删除
* @name :delete
* @author :lyh
* @method :post
* @time :2023/8/28 15:22
*/
public function delete($ids, $map = []){
$ids= array_filter(Arr::splitFilterToArray($ids), 'intval');
foreach ($ids as $id){
... ...
... ... @@ -30,7 +30,7 @@ class BaseLogic extends Logic
public function __construct()
{
$this->request = request();
$this->requestAll = request()->all();
$this->requestAll = $this->getParam();
$this->user = Cache::get(request()->header('token'));
if(!empty($this->user)){
$this->project = Cache::get('user-'.$this->user['project_id']);
... ... @@ -38,6 +38,27 @@ class BaseLogic extends Logic
}
/**
* @remark :请求参数处理
* @name :getParam
* @author :lyh
* @method :post
* @time :2023/6/17 16:34
*/
public function getParam(){
$requestAll = $this->request->all();
foreach ($requestAll as $k => $v){
if(is_array($v)){
continue;
}else{
if(empty($v) && ($v != 0)){
unset($requestAll[$k]);
}
}
}
return $this->success($requestAll);
}
/**
* 列表
* @param array $map
* @param array $sort
... ...