dataLists(new DeptLists()); } /** * @notes 添加部门 * @return \think\response\Json * @author 段誉 * @date 2022/5/25 18:40 */ public function add() { $params = (new DeptValidate())->post()->goCheck('add'); DeptLogic::add($params); return $this->success('添加成功', [], 1, 1); } /** * @notes 编辑部门 * @return \think\response\Json * @author 段誉 * @date 2022/5/25 18:41 */ public function edit() { $params = (new DeptValidate())->post()->goCheck('edit'); $result = DeptLogic::edit($params); if (true === $result) { return $this->success('编辑成功', [], 1, 1); } return $this->fail(DeptLogic::getError()); } /** * @notes 删除部门 * @return \think\response\Json * @author 段誉 * @date 2022/5/25 18:41 */ public function delete() { $params = (new DeptValidate())->post()->goCheck('delete'); $result = DeptLogic::delete($params); return $result ? $this->success('删除成功', [], 1, 1) : $this->fail(DeptLogic::getError()); } /** * @notes 获取部门详情 * @return \think\response\Json * @author 段誉 * @date 2022/5/25 18:41 */ public function detail() { $params = (new DeptValidate())->goCheck('detail'); $result = DeptLogic::detail($params); return $this->data($result); } //某个组织下面的部门 public function listToOrg(): \think\response\Json { $params = $this->request->get(['org_id']); if(empty($params['org_id'])){ return $this->fail('参数错误'); } $data = Dept::field('id,name,leader,mobile,status')->where('org_id',$params['org_id'])->select()->toArray(); return $this->success('请求成功',$data); } }